fs

package
v0.1.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 20, 2024 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package fs provides a virtual filesystem interface for SCALIBR scans and related helper functions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FS

type FS interface {
	fs.FS
	fs.ReadDirFS
	fs.StatFS
}

FS is a filesystem interface that allows the opening of files, reading of directories, and performing stat on files.

FS implementations may return ErrNotImplemented for `Open`, `ReadDir` and `Stat`. Extractor implementations must decide whether the error is fatal or can be ignored.

FS implementations MUST implement io.ReaderAt for opened files to enable random access.

func DirFS

func DirFS(root string) FS

DirFS returns an FS implementation that accesses the real filesystem at the given root.

type ScanRoot

type ScanRoot struct {
	// A virtual filesystem for file access, rooted at the scan root.
	FS FS
	// The path of the scan root. Empty if this is a virtual filesystem and the
	// scanning environment doesn't support the DirectFS requirement.
	Path string
}

ScanRoot defines a root directory to start a scan from. mounted to a local dir.

func RealFSScanRoot

func RealFSScanRoot(path string) *ScanRoot

RealFSScanRoot returns a ScanRoot array the given root path on the real filesystem SCALIBR is running on.

func RealFSScanRoots

func RealFSScanRoots(path string) []*ScanRoot

RealFSScanRoots returns a one-element ScanRoot array representing the given root path on the real filesystem SCALIBR is running on.

func (*ScanRoot) IsVirtual

func (r *ScanRoot) IsVirtual() bool

IsVirtual returns true if the scan root represents the root of a virtual filesystem, i.e. one with no real location on the disk of the scanned host.

func (*ScanRoot) WithAbsolutePath

func (r *ScanRoot) WithAbsolutePath() (*ScanRoot, error)

WithAbsolutePath returns a copy of the ScanRoot with the Path set an absolute path.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL