Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewVirtioFsBackend ¶
Types ¶
type AbstractDir ¶
type AbstractDir interface {
// Stat returns the directory mode.
Stat() (mode fs.FileMode)
// ModTime returns the directory's modified time.
ModTime() time.Time
// ReadDir returns all entries in the directory.
ReadDir() ([]AbstractDirEntry, error)
// Lookup returns the entry for the given name, or nil if not found.
Lookup(name string) (AbstractEntry, error)
}
AbstractDir represents a directory with custom listing and lookup. Implement this interface to provide directories backed by host directories, etc.
type AbstractDirEntry ¶
AbstractDirEntry describes an entry returned by AbstractDir.ReadDir.
type AbstractEntry ¶
type AbstractEntry struct {
File AbstractFile
Dir AbstractDir
Symlink AbstractSymlink
}
AbstractEntry is returned by AbstractDir.Lookup. Exactly one of File, Dir, or Symlink should be non-nil.
type AbstractFile ¶
type AbstractFile interface {
// Stat returns the file size and mode.
Stat() (size uint64, mode fs.FileMode)
// ModTime returns the file's modified time.
ModTime() time.Time
// ReadAt reads up to size bytes starting at offset off.
ReadAt(off uint64, size uint32) ([]byte, error)
// WriteAt writes data at offset off. Returns error if not writable.
WriteAt(off uint64, data []byte) error
// Truncate sets the file size. Returns error if not supported.
Truncate(size uint64) error
}
AbstractFile represents a file with custom read/write operations. Implement this interface to provide files backed by host files, network resources, etc.
type AbstractOwner ¶
type AbstractOwner interface {
Owner() (uid, gid uint32)
}
AbstractOwner is an optional interface that AbstractFile and AbstractDir implementations can provide to expose ownership information (uid/gid).
type AbstractSymlink ¶
type AbstractSymlink interface {
// Stat returns the symlink's mode (permission bits are used; file type is ignored).
Stat() fs.FileMode
// ModTime returns the modified time for the symlink.
ModTime() time.Time
// Target returns the symlink target.
Target() string
}
AbstractSymlink represents a symlink (read-only) with a target string. Ownership information can be exposed by also implementing AbstractOwner.
type BytesFile ¶ added in v0.0.2
type BytesFile struct {
// contains filtered or unexported fields
}
BytesFile implements AbstractFile for read-only in-memory file content. This is useful for exposing static content like kernel modules.
func NewBytesFile ¶ added in v0.0.2
NewBytesFile creates a new BytesFile with the given content and mode.
type ExportedNode ¶ added in v0.0.2
type ExportedNode struct {
ID uint64
Name string
Parent uint64
Mode fs.FileMode
Size uint64
IsModified bool
HasBlocks bool
HasAbstract bool
SymlinkTarget string
}
ExportedNode contains node information for external access (testing).
type ModuleFile ¶ added in v0.0.2
type ModuleFile struct {
Path string // relative path within lib/modules/<version>/
Data []byte // file content
Mode fs.FileMode // file mode
}
ModuleFile represents a kernel module file to be added to the VFS.
type OSDirBackend ¶ added in v0.0.2
type OSDirBackend struct {
// contains filtered or unexported fields
}
OSDirBackend implements AbstractDir by wrapping a host directory path. This allows exposing host directories to guests via virtio-fs.
func NewOSDirBackend ¶ added in v0.0.2
func NewOSDirBackend(hostPath string, readOnly bool) (*OSDirBackend, error)
NewOSDirBackend creates a new OS directory backend wrapping the given host path. If readOnly is true, all write operations will return errors.
func (*OSDirBackend) Lookup ¶ added in v0.0.2
func (d *OSDirBackend) Lookup(name string) (AbstractEntry, error)
Lookup implements AbstractDir.
func (*OSDirBackend) ModTime ¶ added in v0.0.2
func (d *OSDirBackend) ModTime() time.Time
ModTime implements AbstractDir.
func (*OSDirBackend) ReadDir ¶ added in v0.0.2
func (d *OSDirBackend) ReadDir() ([]AbstractDirEntry, error)
ReadDir implements AbstractDir.
func (*OSDirBackend) Stat ¶ added in v0.0.2
func (d *OSDirBackend) Stat() fs.FileMode
Stat implements AbstractDir.
type SnapshotOptions ¶ added in v0.0.2
type SnapshotOptions struct {
// Excludes contains path patterns to exclude from the snapshot.
// Patterns use glob-style matching (*, ?, []).
Excludes []string
}
SnapshotOptions configures snapshot capture behavior.
type VirtioFsBackend ¶
type VirtioFsBackend interface {
virtio.FsBackend
AddAbstractFile(filePath string, file AbstractFile) error
AddAbstractDir(dirPath string, dir AbstractDir) error
SetAbstractRoot(dir AbstractDir) error
// AddKernelModules adds kernel module files at /lib/modules/<version>/.
AddKernelModules(version string, files []ModuleFile) error
// CaptureLayer captures all filesystem modifications as a layer.
CaptureLayer(opts *SnapshotOptions) (*fslayer.LayerData, error)
// FreezeCurrentLayer marks the current state as a layer boundary.
FreezeCurrentLayer() uint64
}
VirtioFsBackend provides additional methods beyond the FsBackend interface.
func NewVirtioFsBackendWithAbstract ¶
func NewVirtioFsBackendWithAbstract() VirtioFsBackend
NewVirtioFsBackendWithAbstract returns a VirtioFsBackend that supports adding abstract files/dirs.