vfs

package
v0.0.0-...-014ce7a Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2024 License: AGPL-3.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const VFS_ROOT_NODE = VfsNode(1)

Variables

This section is empty.

Functions

This section is empty.

Types

type Attributes

type Attributes struct {
	// contains filtered or unexported fields
}

Attributes of a file, normally requested through stat() or readdir(). A bitmask is used to track which attributes are set.

func (*Attributes) GetAccessTime

func (a *Attributes) GetAccessTime() (time.Time, bool)

func (*Attributes) GetBirthTime

func (a *Attributes) GetBirthTime() (time.Time, bool)

func (*Attributes) GetChangeID

func (a *Attributes) GetChangeID() uint64

GetChangeID returns the change ID, which clients can use to determine if file data, directory contents, or attributes of the node have changed.

func (*Attributes) GetDeviceNumber

func (a *Attributes) GetDeviceNumber() (uint64, bool)

GetDeviceNumber returns the raw device number (st_rdev).

func (*Attributes) GetDiskSizeBytes

func (a *Attributes) GetDiskSizeBytes() (uint64, bool)

func (*Attributes) GetFileHandle

func (a *Attributes) GetFileHandle() VfsNode

GetFileHandle returns an identifier of the file that contains sufficient information to be able to resolve it at a later point in time.

func (*Attributes) GetFileType

func (a *Attributes) GetFileType() FileType

GetFileType returns the file type (upper 4 bits of st_mode).

func (*Attributes) GetGID

func (a *Attributes) GetGID() (uint32, bool)

func (*Attributes) GetInodeNumber

func (a *Attributes) GetInodeNumber() uint64

GetInodeNumber returns the inode number (st_ino).

func (*Attributes) GetLastDataModificationTime

func (a *Attributes) GetLastDataModificationTime() (time.Time, bool)

GetLastDataModificationTime returns the last data modification time (st_mtim).

func (*Attributes) GetLastStatusChangeTime

func (a *Attributes) GetLastStatusChangeTime() (time.Time, bool)

func (*Attributes) GetLinkCount

func (a *Attributes) GetLinkCount() uint32

GetLinkCount returns the link count (st_nlink).

func (*Attributes) GetPermissions

func (a *Attributes) GetPermissions() (Permissions, bool)

GetPermissions returns the mode (lowest 12 bits of st_mode).

func (*Attributes) GetSizeBytes

func (a *Attributes) GetSizeBytes() (uint64, bool)

GetSizeBytes returns the file size (st_size).

func (*Attributes) GetUID

func (a *Attributes) GetUID() (uint32, bool)

func (*Attributes) GetUnixMode

func (a *Attributes) GetUnixMode() (uint32, bool)

GetPermissions returns the mode (lowest 12 bits of st_mode).

func (*Attributes) SetAccessTime

func (a *Attributes) SetAccessTime(aTime time.Time) *Attributes

func (*Attributes) SetBirthTime

func (a *Attributes) SetBirthTime(bTime time.Time) *Attributes

func (*Attributes) SetChangeID

func (a *Attributes) SetChangeID(changeID uint64) *Attributes

SetChangeID sets the change ID, which clients can use to determine if file data, directory contents, or attributes of the node have changed.

func (*Attributes) SetDeviceNumber

func (a *Attributes) SetDeviceNumber(deviceNumber uint64) *Attributes

SetDeviceNumber sets the raw device number (st_rdev).

func (*Attributes) SetDiskSizeBytes

func (a *Attributes) SetDiskSizeBytes(sizeBytes uint64) *Attributes

SetSizeBytes sets the file size (st_size).

func (*Attributes) SetFileHandle

func (a *Attributes) SetFileHandle(fileHandle VfsNode) *Attributes

SetFileHandle sets an identifier of the file that contains sufficient information to be able to resolve it at a later point in time.

func (*Attributes) SetFileType

func (a *Attributes) SetFileType(fileType FileType) *Attributes

SetFileType sets the file type (upper 4 bits of st_mode).

func (*Attributes) SetGID

func (a *Attributes) SetGID(gid uint32) *Attributes

SetSizeBytes sets the file size (st_size).

func (*Attributes) SetInodeNumber

func (a *Attributes) SetInodeNumber(inodeNumber uint64) *Attributes

SetInodeNumber sets the inode number (st_ino).

func (*Attributes) SetLastDataModificationTime

func (a *Attributes) SetLastDataModificationTime(mTime time.Time) *Attributes

SetLastDataModificationTime sets the last data modification time (st_mtim).

func (*Attributes) SetLastStatusChangeTime

func (a *Attributes) SetLastStatusChangeTime(cTime time.Time) *Attributes

func (*Attributes) SetLinkCount

func (a *Attributes) SetLinkCount(linkCount uint32) *Attributes

SetLinkCount sets the link count (st_nlink).

func (*Attributes) SetPermissions

func (a *Attributes) SetPermissions(permissions Permissions) *Attributes

SetPermissions sets the mode (lowest 12 bits of st_mode).

func (*Attributes) SetSizeBytes

func (a *Attributes) SetSizeBytes(sizeBytes uint64) *Attributes

SetSizeBytes sets the file size (st_size).

func (*Attributes) SetUID

func (a *Attributes) SetUID(uid uint32) *Attributes

SetSizeBytes sets the file size (st_size).

func (*Attributes) SetUnixMode

func (a *Attributes) SetUnixMode(mode uint32) *Attributes

SetUnixMode sets the mode (lowest 12 bits of st_mode).

type AttributesMask

type AttributesMask uint32

AttributesMask is a bitmask of status attributes that need to be requested through Node.VirtualGetAttributes().

const (
	// AttributesMaskChangeID requests the change ID, which clients
	// can use to determine if file data, directory contents, or
	// attributes of the node have changed.
	AttributesMaskChangeID AttributesMask = 1 << iota
	// AttributesMaskDeviceNumber requests the raw device number
	// (st_rdev).
	AttributesMaskDeviceNumber
	// AttributesMaskFileHandle requests an identifier of the file
	// that contains sufficient information to be able to resolve it
	// at a later point in time.
	AttributesMaskFileHandle
	// AttributesMaskFileType requests the file type (upper 4 bits
	// of st_mode).
	AttributesMaskFileType
	// AttributesMaskInodeNumber requests the inode number (st_ino).
	AttributesMaskInodeNumber
	// AttributesMaskLastDataModificationTime requests the last data
	// modification time (st_mtim).
	AttributesMaskLastDataModificationTime
	// Time of last access
	AttributesMaskAccessTime
	// Time of last status change
	AttributesMaskLastStatusChangeTime
	// Time of file creation(birth)
	AttributesMaskBirthTime
	// AttributesMaskLinkCount requests the link count (st_nlink).
	AttributesMaskLinkCount
	// AttributesMaskPermissions requests the permissions (lowest 12
	// bits of set_mode).
	AttributesMaskPermissions
	// AttributesMaskSizeBytes requests the file size (st_size).
	AttributesMaskSizeBytes
	//
	AttributesMaskDiskSizeBytes
	//
	AttributesMaskUserID
	//
	AttributesMaskGroupID
	//
	AttributesMaskUnixMode
)

type DirInfo

type DirInfo struct {
	Name string
	Attributes
}

type EntryReply

type EntryReply struct {
	Node       VfsNode
	Generation uint64
	Attrs      Attributes
}

type FSAttributes

type FSAttributes struct {
	// contains filtered or unexported fields
}

func (*FSAttributes) GetAvailableBlocks

func (a *FSAttributes) GetAvailableBlocks() (uint64, bool)

func (*FSAttributes) GetBlockSize

func (a *FSAttributes) GetBlockSize() (uint64, bool)

func (*FSAttributes) GetBlocks

func (a *FSAttributes) GetBlocks() (uint64, bool)

func (*FSAttributes) GetFiles

func (a *FSAttributes) GetFiles() (uint64, bool)

func (*FSAttributes) GetFreeBlocks

func (a *FSAttributes) GetFreeBlocks() (uint64, bool)

func (*FSAttributes) GetFreeFiles

func (a *FSAttributes) GetFreeFiles() (uint64, bool)

func (*FSAttributes) GetIOkSize

func (a *FSAttributes) GetIOkSize() (uint64, bool)

func (*FSAttributes) SetAvailableBlocks

func (a *FSAttributes) SetAvailableBlocks(availBlocks uint64) *FSAttributes

func (*FSAttributes) SetBlockSize

func (a *FSAttributes) SetBlockSize(bsize uint64) *FSAttributes

func (*FSAttributes) SetBlocks

func (a *FSAttributes) SetBlocks(blocks uint64) *FSAttributes

func (*FSAttributes) SetFiles

func (a *FSAttributes) SetFiles(files uint64) *FSAttributes

func (*FSAttributes) SetFreeBlocks

func (a *FSAttributes) SetFreeBlocks(freeBlocks uint64) *FSAttributes

func (*FSAttributes) SetFreeFiles

func (a *FSAttributes) SetFreeFiles(freeFiles uint64) *FSAttributes

func (*FSAttributes) SetIOSize

func (a *FSAttributes) SetIOSize(iosize uint64) *FSAttributes

type FSAttributesMask

type FSAttributesMask uint32

AttributesMask is a bitmask of status attributes that need to be requested through Node.VirtualGetAttributes().

const (
	AttributesMaskBlockSize FSAttributesMask = 1 << iota
	AttributesMaskIOSize
	AttributesMaskBlocks
	AttributesMaskFreeBlocks
	AttributesMaskAvailableBlocks
	AttributesMaskFileNodes
	AttributesMaskFreeFileNodes
)

type FileType

type FileType int
const (
	// FileTypeRegularFile means the file is a regular file.
	FileTypeRegularFile FileType = iota
	// FileTypeDirectory means the file is a directory.
	FileTypeDirectory
	// FileTypeSymlink means the file is a symbolic link.
	FileTypeSymlink
	// FileTypeBlockDevice means the file is a block device.
	FileTypeBlockDevice
	// FileTypeCharacterDevice means the file is a character device.
	FileTypeCharacterDevice
	// FileTypeFIFO means the file is a FIFO.
	FileTypeFIFO
	// FileTypeSocket means the file is a socket.
	FileTypeSocket
	// FileTypeOther means the file is neither a regular file, a
	// directory or symbolic link.
	FileTypeNamedAttributeDir
	FileTypeNamedAttribute
	// FileTypeOther means the file is neither a regular file, a
	// directory or symbolic link.
	FileTypeOther
)

type NotifyEvent

type NotifyEvent struct {
	EvType uint8
	Handle VfsHandle
	Name   string
}

type Permissions

type Permissions uint8

Permissions of a file. Unlike regular UNIX file system, no distinction is made between owner, group and all permissions. This is because the virtual file system is effectively single user.

const (
	// PermissionsRead indicates that file contents may be read, or
	// that files in a directory may be listed.
	PermissionsRead Permissions = 1 << iota
	// PermissionsWrite indicates that file contents may be written
	// to, or that files in a directory may be added, removed or
	// renamed.
	PermissionsWrite
	// PermissionsExecute indicates that a file is executable, or
	// that files in a directory may be looked up.
	PermissionsExecute
)

func NewPermissionsFromMode

func NewPermissionsFromMode(m uint32) (p Permissions)

NewPermissionsFromMode creates a set of permissions from a traditional UNIX style mode.

func (Permissions) ToMode

func (p Permissions) ToMode() (m uint32)

ToMode converts a set of permissions to a traditional UNIX style mode. The permissions for the owner, group and all will be identical.

type ShareMask

type ShareMask uint32

ShareMask is a bitmask of operations that are permitted

const (
	// ShareMaskRead permits calls to VirtualRead().
	ShareMaskRead ShareMask = 1 << iota
	// ShareMaskWrite permits calls to VirtualWrite().
	ShareMaskWrite
)

type Stat

type Stat struct {
	Ino     uint64
	Blocks  int64
	BlkSize int32
	Mtime   time.Time
	Atime   time.Time
	Ctime   time.Time
	Btime   time.Time
}

func CompatStat

func CompatStat(stat os.FileInfo) (Stat, bool)

type VFSFileSystem

type VFSFileSystem interface {
	GetAttr(VfsHandle) (*Attributes, error)
	SetAttr(VfsHandle, *Attributes) (*Attributes, error)

	StatFS(VfsHandle) (*FSAttributes, error)

	FSync(VfsHandle) error

	Flush(VfsHandle) error

	//Create(VfsNode, string, int, int) (*EntryReply, VfsHandle, error)
	Open(string, int, int) (VfsHandle, error)
	Close(VfsHandle) error

	Lookup(VfsHandle, string) (*Attributes, error)

	Mkdir(string, int) (*Attributes, error)

	Read(VfsHandle, []byte, uint64, int) (int, error)
	Write(VfsHandle, []byte, uint64, int) (int, error)

	OpenDir(string) (VfsHandle, error)
	ReadDir(VfsHandle, int, int) ([]DirInfo, error)

	Readlink(VfsHandle) (string, error)

	Unlink(VfsHandle) error

	Truncate(VfsHandle, uint64) error

	Rename(VfsHandle, string, int) error

	Symlink(VfsHandle, string, int) (*Attributes, error)
	Link(VfsNode, VfsNode, string) (*Attributes, error)

	Listxattr(VfsHandle) ([]string, error)
	Getxattr(VfsHandle, string, []byte) (int, error)
	Setxattr(VfsHandle, string, []byte) error
	Removexattr(VfsHandle, string) error
}

type VfsHandle

type VfsHandle uint64

type VfsNode

type VfsNode uint64

Jump to

Keyboard shortcuts

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