vfs

package
v0.18.1 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseFS

type BaseFS interface {
	fs.FS
	fs.ReadDirFS
	fs.ReadFileFS
	fs.StatFS

	Create(path string) (io.WriteCloser, error)
	Remove(path string) error
	RemoveAll(path string) error
}

BaseFS is the required interfaces for an underlay filesystem which is used with VFS.

func DirFS

func DirFS(path string) (BaseFS, error)

DirFS is a DirFS implementation that is suitable for use as a BaseFS.

type INode

type INode struct {
	Filename      string
	Children      map[string]*INode
	UnderlayINode unix.Stat_t
}

An INode contains overlay metadata for a filesystem entry that would otherwise be represented by a traditional inode on disk.

func (*INode) Chmod

func (i *INode) Chmod(path string, mode fs.FileMode) error

Chmod updates the permissions on an INode.

func (*INode) Chown

func (i *INode) Chown(path string, uid, gid uint32) error

Chown updates the ownership on an INode.

func (*INode) Create

func (i *INode) Create(path string) (*INode, error)

Create creates a new underlay INode.

func (INode) Info

func (i INode) Info() (os.FileInfo, error)

func (INode) IsDir

func (i INode) IsDir() bool

func (INode) ModTime

func (i INode) ModTime() time.Time

func (INode) Mode

func (i INode) Mode() fs.FileMode

func (INode) Name

func (i INode) Name() string

func (INode) Size

func (i INode) Size() int64

func (*INode) Stat

func (i *INode) Stat(path string) (os.FileInfo, error)

Stat looks up a child INode in the VFS or returns nothing. Note: We intentionally do not implement support for the `..` directory entry for security reasons.

func (INode) Sys

func (i INode) Sys() any

func (INode) Type

func (i INode) Type() fs.FileMode

type VFS

type VFS struct {
	FS   BaseFS
	Root *INode
}

VFS is an overlay virtual filesystem which tracks an underlying BaseFS.

It allows for things like permission and ownership changes that do not require physical root access, because it is tracked at the VFS level instead.

func New

func New(base BaseFS) (*VFS, error)

func (*VFS) Chmod

func (vfs *VFS) Chmod(path string, mode fs.FileMode) error

func (*VFS) Chown

func (vfs *VFS) Chown(path string, uid, gid uint32) error

func (*VFS) Create

func (vfs *VFS) Create(path string) (io.WriteCloser, error)

func (*VFS) Open

func (vfs *VFS) Open(path string) (fs.File, error)

func (*VFS) ReadDir

func (vfs *VFS) ReadDir(path string) ([]fs.DirEntry, error)

func (*VFS) ReadFile

func (vfs *VFS) ReadFile(path string) ([]byte, error)

func (*VFS) Stat

func (vfs *VFS) Stat(path string) (os.FileInfo, error)

Jump to

Keyboard shortcuts

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