Documentation ¶
Overview ¶
Package kernfs provides the tools to implement inode-based filesystems. Kernfs has two main features:
The Inode interface, which maps VFS's path-based filesystem operations to specific filesystem nodes. Kernfs uses the Inode interface to provide a blanket implementation for the vfs.FilesystemImpl. Kernfs also serves as the synchronization mechanism for all filesystem operations by holding a filesystem-wide lock across all operations.
Various utility types which provide generic implementations for various parts of the Inode and vfs.FileDescription interfaces. Client filesystems based on kernfs can embed the appropriate set of these to avoid having to reimplement common filesystem operations. See inode_impl_util.go and fd_impl_util.go.
Reference Model:
Kernfs dentries represents named pointers to inodes. Kernfs is solely responsible for maintaining and modifying its dentry tree; inode implementations can not access the tree. Dentries and inodes have independent lifetimes and reference counts. A child dentry unconditionally holds a reference on its parent directory's dentry. A dentry also holds a reference on the inode it points to (although that might not be the only reference on the inode). Due to this inodes can outlive the dentries that point to them. Multiple dentries can point to the same inode (for example, in the case of hardlinks). File descriptors hold a reference to the dentry they're opened on.
Dentries are guaranteed to exist while holding Filesystem.mu for reading. Dropping dentries require holding Filesystem.mu for writing. To queue dentries for destruction from a read critical section, see Filesystem.deferDecRef.
Lock ordering:
kernfs.Filesystem.mu kernel.TaskSet.mu kernel.Task.mu kernfs.Dentry.dirMu vfs.VirtualFilesystem.mountMu vfs.Dentry.mu (inode implementation locks, if any)
kernfs.Filesystem.deferredDecRefsMu
Index ¶
- Constants
- type CachedMappable
- func (i *CachedMappable) AddMapping(ctx context.Context, ms memmap.MappingSpace, ar hostarch.AddrRange, ...) error
- func (i *CachedMappable) CopyMapping(ctx context.Context, ms memmap.MappingSpace, srcAR, dstAR hostarch.AddrRange, ...) error
- func (i *CachedMappable) Init(hostFD int)
- func (i *CachedMappable) InitFileMapperOnce()
- func (i *CachedMappable) InvalidateRange(r memmap.MappableRange)
- func (i *CachedMappable) InvalidateUnsavable(ctx context.Context) error
- func (i *CachedMappable) RemoveMapping(ctx context.Context, ms memmap.MappingSpace, ar hostarch.AddrRange, ...)
- func (i *CachedMappable) Translate(ctx context.Context, required, optional memmap.MappableRange, ...) ([]memmap.Translation, error)
- type Dentry
- func (d *Dentry) DecRef(ctx context.Context)
- func (d *Dentry) FSLocalPath() string
- func (d *Dentry) IncRef()
- func (d *Dentry) Init(fs *Filesystem, inode Inode)
- func (d *Dentry) InitRoot(fs *Filesystem, inode Inode)
- func (d *Dentry) Inode() Inode
- func (d *Dentry) InotifyWithParent(ctx context.Context, events, cookie uint32, et vfs.EventType)
- func (d *Dentry) LeakMessage() string
- func (d *Dentry) LogRefs() bool
- func (d *Dentry) OnZeroWatches(context.Context)
- func (d *Dentry) Parent() *Dentry
- func (d *Dentry) RefType() string
- func (d *Dentry) TryIncRef() bool
- func (d *Dentry) VFSDentry() *vfs.Dentry
- func (d *Dentry) WalkDentryTree(ctx context.Context, vfsObj *vfs.VirtualFilesystem, p fspath.Path) (*Dentry, error)
- func (d *Dentry) Watches() *vfs.Watches
- type DynamicBytesFD
- func (fd *DynamicBytesFD) Init(m *vfs.Mount, d *Dentry, data vfs.DynamicBytesSource, locks *vfs.FileLocks, ...) error
- func (fd *DynamicBytesFD) PRead(ctx context.Context, dst usermem.IOSequence, offset int64, ...) (int64, error)
- func (fd *DynamicBytesFD) PWrite(ctx context.Context, src usermem.IOSequence, offset int64, ...) (int64, error)
- func (fd *DynamicBytesFD) Read(ctx context.Context, dst usermem.IOSequence, opts vfs.ReadOptions) (int64, error)
- func (fd *DynamicBytesFD) Release(context.Context)
- func (fd *DynamicBytesFD) Seek(ctx context.Context, offset int64, whence int32) (int64, error)
- func (fd *DynamicBytesFD) SetStat(context.Context, vfs.SetStatOptions) error
- func (fd *DynamicBytesFD) Stat(ctx context.Context, opts vfs.StatOptions) (linux.Statx, error)
- func (fd *DynamicBytesFD) Write(ctx context.Context, src usermem.IOSequence, opts vfs.WriteOptions) (int64, error)
- type DynamicBytesFile
- func (f *DynamicBytesFile) Data() vfs.DynamicBytesSource
- func (f *DynamicBytesFile) Init(ctx context.Context, creds *auth.Credentials, devMajor, devMinor uint32, ...)
- func (f *DynamicBytesFile) Locks() *vfs.FileLocks
- func (f *DynamicBytesFile) Open(ctx context.Context, rp *vfs.ResolvingPath, d *Dentry, opts vfs.OpenOptions) (*vfs.FileDescription, error)
- func (*DynamicBytesFile) SetStat(context.Context, *vfs.Filesystem, *auth.Credentials, vfs.SetStatOptions) error
- type Filesystem
- func (fs *Filesystem) AccessAt(ctx context.Context, rp *vfs.ResolvingPath, creds *auth.Credentials, ...) error
- func (fs *Filesystem) BoundEndpointAt(ctx context.Context, rp *vfs.ResolvingPath, opts vfs.BoundEndpointOptions) (transport.BoundEndpoint, error)
- func (fs *Filesystem) GetDentryAt(ctx context.Context, rp *vfs.ResolvingPath, opts vfs.GetDentryOptions) (*vfs.Dentry, error)
- func (fs *Filesystem) GetParentDentryAt(ctx context.Context, rp *vfs.ResolvingPath) (*vfs.Dentry, error)
- func (fs *Filesystem) GetXattrAt(ctx context.Context, rp *vfs.ResolvingPath, opts vfs.GetXattrOptions) (string, error)
- func (fs *Filesystem) IsDescendant(vfsroot, vd vfs.VirtualDentry) bool
- func (fs *Filesystem) LinkAt(ctx context.Context, rp *vfs.ResolvingPath, vd vfs.VirtualDentry) error
- func (fs *Filesystem) ListXattrAt(ctx context.Context, rp *vfs.ResolvingPath, size uint64) ([]string, error)
- func (fs *Filesystem) MkdirAt(ctx context.Context, rp *vfs.ResolvingPath, opts vfs.MkdirOptions) error
- func (fs *Filesystem) MknodAt(ctx context.Context, rp *vfs.ResolvingPath, opts vfs.MknodOptions) error
- func (fs *Filesystem) NextIno() uint64
- func (fs *Filesystem) OpenAt(ctx context.Context, rp *vfs.ResolvingPath, opts vfs.OpenOptions) (*vfs.FileDescription, error)
- func (fs *Filesystem) PrependPath(ctx context.Context, vfsroot, vd vfs.VirtualDentry, b *fspath.Builder) error
- func (fs *Filesystem) ReadlinkAt(ctx context.Context, rp *vfs.ResolvingPath) (string, error)
- func (fs *Filesystem) Release(ctx context.Context)
- func (fs *Filesystem) RemoveXattrAt(ctx context.Context, rp *vfs.ResolvingPath, name string) error
- func (fs *Filesystem) RenameAt(ctx context.Context, rp *vfs.ResolvingPath, oldParentVD vfs.VirtualDentry, ...) error
- func (fs *Filesystem) RmdirAt(ctx context.Context, rp *vfs.ResolvingPath) error
- func (fs *Filesystem) SafeDecRef(ctx context.Context, vd vfs.VirtualDentry)
- func (fs *Filesystem) SafeDecRefFD(ctx context.Context, fd *vfs.FileDescription)
- func (fs *Filesystem) SetStatAt(ctx context.Context, rp *vfs.ResolvingPath, opts vfs.SetStatOptions) error
- func (fs *Filesystem) SetXattrAt(ctx context.Context, rp *vfs.ResolvingPath, opts vfs.SetXattrOptions) error
- func (fs *Filesystem) StatAt(ctx context.Context, rp *vfs.ResolvingPath, opts vfs.StatOptions) (linux.Statx, error)
- func (fs *Filesystem) StatFSAt(ctx context.Context, rp *vfs.ResolvingPath) (linux.Statfs, error)
- func (fs *Filesystem) SymlinkAt(ctx context.Context, rp *vfs.ResolvingPath, target string) error
- func (fs *Filesystem) Sync(ctx context.Context) error
- func (fs *Filesystem) UnlinkAt(ctx context.Context, rp *vfs.ResolvingPath) error
- func (fs *Filesystem) VFSFilesystem() *vfs.Filesystem
- type GenericDirectoryFD
- func (fd *GenericDirectoryFD) Allocate(ctx context.Context, mode, offset, length uint64) error
- func (fd *GenericDirectoryFD) ConfigureMMap(ctx context.Context, opts *memmap.MMapOpts) error
- func (fd *GenericDirectoryFD) Init(children *OrderedChildren, locks *vfs.FileLocks, opts *vfs.OpenOptions, ...) error
- func (fd *GenericDirectoryFD) IterDirents(ctx context.Context, cb vfs.IterDirentsCallback) error
- func (fd *GenericDirectoryFD) PRead(ctx context.Context, dst usermem.IOSequence, offset int64, ...) (int64, error)
- func (fd *GenericDirectoryFD) PWrite(ctx context.Context, src usermem.IOSequence, offset int64, ...) (int64, error)
- func (fd *GenericDirectoryFD) Read(ctx context.Context, dst usermem.IOSequence, opts vfs.ReadOptions) (int64, error)
- func (fd *GenericDirectoryFD) Release(context.Context)
- func (fd *GenericDirectoryFD) Seek(ctx context.Context, offset int64, whence int32) (int64, error)
- func (fd *GenericDirectoryFD) SetStat(ctx context.Context, opts vfs.SetStatOptions) error
- func (fd *GenericDirectoryFD) Stat(ctx context.Context, opts vfs.StatOptions) (linux.Statx, error)
- func (fd *GenericDirectoryFD) VFSFileDescription() *vfs.FileDescription
- func (fd *GenericDirectoryFD) Write(ctx context.Context, src usermem.IOSequence, opts vfs.WriteOptions) (int64, error)
- type GenericDirectoryFDOptions
- type Inode
- type InodeAlwaysValid
- type InodeAnonymous
- type InodeAttrs
- func (a *InodeAttrs) CheckPermissions(_ context.Context, creds *auth.Credentials, ats vfs.AccessTypes) error
- func (a *InodeAttrs) DecLinks()
- func (a *InodeAttrs) DevMajor() uint32
- func (a *InodeAttrs) DevMinor() uint32
- func (a *InodeAttrs) GID() auth.KGID
- func (a *InodeAttrs) IncLinks(n uint32)
- func (a *InodeAttrs) Init(ctx context.Context, creds *auth.Credentials, devMajor, devMinor uint32, ...)
- func (a *InodeAttrs) InitWithIDs(ctx context.Context, uid auth.KUID, gid auth.KGID, devMajor, devMinor uint32, ...)
- func (a *InodeAttrs) Ino() uint64
- func (a *InodeAttrs) Links() uint32
- func (a *InodeAttrs) Mode() linux.FileMode
- func (a *InodeAttrs) SetStat(ctx context.Context, fs *vfs.Filesystem, creds *auth.Credentials, ...) error
- func (a *InodeAttrs) Stat(context.Context, *vfs.Filesystem, vfs.StatOptions) (linux.Statx, error)
- func (a *InodeAttrs) TouchAtime(ctx context.Context, mnt *vfs.Mount)
- func (a *InodeAttrs) TouchCMtime(ctx context.Context)
- func (a *InodeAttrs) UID() auth.KUID
- type InodeDirectoryNoNewChildren
- func (InodeDirectoryNoNewChildren) NewDir(context.Context, string, vfs.MkdirOptions) (Inode, error)
- func (InodeDirectoryNoNewChildren) NewFile(context.Context, string, vfs.OpenOptions) (Inode, error)
- func (InodeDirectoryNoNewChildren) NewLink(context.Context, string, Inode) (Inode, error)
- func (InodeDirectoryNoNewChildren) NewNode(context.Context, string, vfs.MknodOptions) (Inode, error)
- func (InodeDirectoryNoNewChildren) NewSymlink(context.Context, string, string) (Inode, error)
- type InodeNoStatFS
- type InodeNoopRefCount
- type InodeNotAnonymous
- type InodeNotDirectory
- func (InodeNotDirectory) HasChildren() bool
- func (InodeNotDirectory) IterDirents(ctx context.Context, mnt *vfs.Mount, callback vfs.IterDirentsCallback, ...) (newOffset int64, err error)
- func (InodeNotDirectory) Lookup(ctx context.Context, name string) (Inode, error)
- func (InodeNotDirectory) NewDir(context.Context, string, vfs.MkdirOptions) (Inode, error)
- func (InodeNotDirectory) NewFile(context.Context, string, vfs.OpenOptions) (Inode, error)
- func (InodeNotDirectory) NewLink(context.Context, string, Inode) (Inode, error)
- func (InodeNotDirectory) NewNode(context.Context, string, vfs.MknodOptions) (Inode, error)
- func (InodeNotDirectory) NewSymlink(context.Context, string, string) (Inode, error)
- func (InodeNotDirectory) Rename(context.Context, string, string, Inode, Inode) error
- func (InodeNotDirectory) RmDir(context.Context, string, Inode) error
- func (InodeNotDirectory) Unlink(context.Context, string, Inode) error
- type InodeNotSymlink
- type InodeSymlink
- type InodeTemporary
- type InodeWatches
- type OrderedChildren
- func (o *OrderedChildren) Destroy(ctx context.Context)
- func (o *OrderedChildren) ForEachChild(fn func(string, Inode))
- func (o *OrderedChildren) HasChildren() bool
- func (o *OrderedChildren) Init(opts OrderedChildrenOptions)
- func (o *OrderedChildren) Insert(name string, child Inode) error
- func (o *OrderedChildren) Inserter(name string, makeChild func() Inode) (Inode, error)
- func (o *OrderedChildren) IterDirents(ctx context.Context, mnt *vfs.Mount, cb vfs.IterDirentsCallback, ...) (newOffset int64, err error)
- func (o *OrderedChildren) Lookup(ctx context.Context, name string) (Inode, error)
- func (o *OrderedChildren) Populate(children map[string]Inode) uint32
- func (o *OrderedChildren) Rename(ctx context.Context, oldname, newname string, child, dstDir Inode) error
- func (o *OrderedChildren) RmDir(ctx context.Context, name string, child Inode) error
- func (o *OrderedChildren) Unlink(ctx context.Context, name string, child Inode) error
- type OrderedChildrenOptions
- type SeekEndConfig
- type StaticDirectory
- func (s *StaticDirectory) DecRef(ctx context.Context)
- func (s *StaticDirectory) Init(ctx context.Context, creds *auth.Credentials, devMajor, devMinor uint32, ...)
- func (s *StaticDirectory) Open(ctx context.Context, rp *vfs.ResolvingPath, d *Dentry, opts vfs.OpenOptions) (*vfs.FileDescription, error)
- func (*StaticDirectory) SetStat(context.Context, *vfs.Filesystem, *auth.Credentials, vfs.SetStatOptions) error
- type StaticSymlink
- func (s *StaticSymlink) Getlink(context.Context, *vfs.Mount) (vfs.VirtualDentry, string, error)
- func (s *StaticSymlink) Init(ctx context.Context, creds *auth.Credentials, devMajor uint32, devMinor uint32, ...)
- func (s *StaticSymlink) Readlink(_ context.Context, _ *vfs.Mount) (string, error)
- func (*StaticSymlink) SetStat(context.Context, *vfs.Filesystem, *auth.Credentials, vfs.SetStatOptions) error
Constants ¶
const ( // Consider the end of the file to be after the final static entry. This is // the default option. SeekEndStaticEntries = iota // Consider the end of the file to be at offset 0. SeekEndZero )
Constants related to SEEK_END behaviour for FDs.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CachedMappable ¶
type CachedMappable struct {
// contains filtered or unexported fields
}
CachedMappable implements memmap.Mappable. This utility can be embedded in a kernfs.Inode that represents a host file to make the inode mappable. CachedMappable caches the mappings of the host file. CachedMappable must be initialized (via Init) with a hostFD before use.
+stateify savable
func (*CachedMappable) AddMapping ¶
func (i *CachedMappable) AddMapping(ctx context.Context, ms memmap.MappingSpace, ar hostarch.AddrRange, offset uint64, writable bool) error
AddMapping implements memmap.Mappable.AddMapping.
func (*CachedMappable) CopyMapping ¶
func (i *CachedMappable) CopyMapping(ctx context.Context, ms memmap.MappingSpace, srcAR, dstAR hostarch.AddrRange, offset uint64, writable bool) error
CopyMapping implements memmap.Mappable.CopyMapping.
func (*CachedMappable) Init ¶
func (i *CachedMappable) Init(hostFD int)
Init initializes i.pf. This must be called before using CachedMappable.
func (*CachedMappable) InitFileMapperOnce ¶
func (i *CachedMappable) InitFileMapperOnce()
InitFileMapperOnce initializes the host file mapper. It ensures that the file mapper is initialized just once.
func (*CachedMappable) InvalidateRange ¶
func (i *CachedMappable) InvalidateRange(r memmap.MappableRange)
InvalidateRange invalidates the passed range on i.mappings.
func (*CachedMappable) InvalidateUnsavable ¶
func (i *CachedMappable) InvalidateUnsavable(ctx context.Context) error
InvalidateUnsavable implements memmap.Mappable.InvalidateUnsavable.
func (*CachedMappable) RemoveMapping ¶
func (i *CachedMappable) RemoveMapping(ctx context.Context, ms memmap.MappingSpace, ar hostarch.AddrRange, offset uint64, writable bool)
RemoveMapping implements memmap.Mappable.RemoveMapping.
func (*CachedMappable) Translate ¶
func (i *CachedMappable) Translate(ctx context.Context, required, optional memmap.MappableRange, at hostarch.AccessType) ([]memmap.Translation, error)
Translate implements memmap.Mappable.Translate.
type Dentry ¶
type Dentry struct {
// contains filtered or unexported fields
}
Dentry implements vfs.DentryImpl.
A kernfs dentry is similar to a dentry in a traditional filesystem: it's a named reference to an inode. A dentry generally lives as long as it's part of a mounted filesystem tree. Kernfs drops dentries once all references to them are dropped. Dentries hold a single reference to the inode they point to, and child dentries hold a reference on their parent.
Must be initialized by Init prior to first use.
+stateify savable
func (*Dentry) FSLocalPath ¶
FSLocalPath returns an absolute path to d, relative to the root of its filesystem.
func (*Dentry) Init ¶
func (d *Dentry) Init(fs *Filesystem, inode Inode)
Init initializes this dentry.
Precondition: Caller must hold a reference on inode.
Postcondition: Caller's reference on inode is transferred to the dentry.
func (*Dentry) InitRoot ¶
func (d *Dentry) InitRoot(fs *Filesystem, inode Inode)
InitRoot initializes this dentry as the root of the filesystem.
Precondition: Caller must hold a reference on inode.
Postcondition: Caller's reference on inode is transferred to the dentry.
func (*Dentry) InotifyWithParent ¶
InotifyWithParent implements vfs.DentryImpl.InotifyWithParent.
func (*Dentry) LeakMessage ¶
LeakMessage implements refs.CheckedObject.LeakMessage.
func (*Dentry) LogRefs ¶
LogRefs implements refs.CheckedObject.LogRefs.
This should only be set to true for debugging purposes, as it can generate an extremely large amount of output and drastically degrade performance.
func (*Dentry) OnZeroWatches ¶
OnZeroWatches implements vfs.Dentry.OnZeroWatches.
func (*Dentry) Parent ¶
Parent returns the parent of this Dentry. This is not safe in general, the filesystem may concurrently move d elsewhere. The caller is responsible for ensuring the returned result remains valid while it is used.
func (*Dentry) WalkDentryTree ¶
func (d *Dentry) WalkDentryTree(ctx context.Context, vfsObj *vfs.VirtualFilesystem, p fspath.Path) (*Dentry, error)
WalkDentryTree traverses p in the dentry tree for this filesystem. Note that this only traverses the dentry tree and is not a general path traversal. No symlinks and dynamic children are resolved, and no permission checks are performed. The caller is responsible for ensuring the returned Dentry exists for an appropriate lifetime.
p is interpreted starting at d, and may be absolute or relative (absolute vs relative paths both refer to the same target here, since p is absolute from d). p may contain "." and "..", but will not allow traversal above d (similar to ".." at the root dentry).
This is useful for filesystem internals, where the filesystem may not be mounted yet. For a mounted filesystem, use GetDentryAt.
type DynamicBytesFD ¶
type DynamicBytesFD struct { vfs.FileDescriptionDefaultImpl vfs.DynamicBytesFileDescriptionImpl vfs.LockFD // contains filtered or unexported fields }
DynamicBytesFD implements vfs.FileDescriptionImpl for an FD backed by a DynamicBytesFile.
Must be initialized with Init before first use.
+stateify savable
func (*DynamicBytesFD) Init ¶
func (fd *DynamicBytesFD) Init(m *vfs.Mount, d *Dentry, data vfs.DynamicBytesSource, locks *vfs.FileLocks, flags uint32) error
Init initializes a DynamicBytesFD.
func (*DynamicBytesFD) PRead ¶
func (fd *DynamicBytesFD) PRead(ctx context.Context, dst usermem.IOSequence, offset int64, opts vfs.ReadOptions) (int64, error)
PRead implements vfs.FileDescriptionImpl.PRead.
func (*DynamicBytesFD) PWrite ¶
func (fd *DynamicBytesFD) PWrite(ctx context.Context, src usermem.IOSequence, offset int64, opts vfs.WriteOptions) (int64, error)
PWrite implements vfs.FileDescriptionImpl.PWrite.
func (*DynamicBytesFD) Read ¶
func (fd *DynamicBytesFD) Read(ctx context.Context, dst usermem.IOSequence, opts vfs.ReadOptions) (int64, error)
Read implements vfs.FileDescriptionImpl.Read.
func (*DynamicBytesFD) Release ¶
func (fd *DynamicBytesFD) Release(context.Context)
Release implements vfs.FileDescriptionImpl.Release.
func (*DynamicBytesFD) SetStat ¶
func (fd *DynamicBytesFD) SetStat(context.Context, vfs.SetStatOptions) error
SetStat implements vfs.FileDescriptionImpl.SetStat.
func (*DynamicBytesFD) Stat ¶
func (fd *DynamicBytesFD) Stat(ctx context.Context, opts vfs.StatOptions) (linux.Statx, error)
Stat implements vfs.FileDescriptionImpl.Stat.
func (*DynamicBytesFD) Write ¶
func (fd *DynamicBytesFD) Write(ctx context.Context, src usermem.IOSequence, opts vfs.WriteOptions) (int64, error)
Write implements vfs.FileDescriptionImpl.Write.
type DynamicBytesFile ¶
type DynamicBytesFile struct { InodeAttrs InodeNoStatFS InodeNoopRefCount InodeNotAnonymous InodeNotDirectory InodeNotSymlink InodeWatches // contains filtered or unexported fields }
DynamicBytesFile implements kernfs.Inode and represents a read-only file whose contents are backed by a vfs.DynamicBytesSource. If data additionally implements vfs.WritableDynamicBytesSource, the file also supports dispatching writes to the implementer, but note that this will not update the source data.
Must be instantiated with NewDynamicBytesFile or initialized with Init before first use.
+stateify savable
func (*DynamicBytesFile) Data ¶
func (f *DynamicBytesFile) Data() vfs.DynamicBytesSource
Data returns the underlying data source.
func (*DynamicBytesFile) Init ¶
func (f *DynamicBytesFile) Init(ctx context.Context, creds *auth.Credentials, devMajor, devMinor uint32, ino uint64, data vfs.DynamicBytesSource, perm linux.FileMode)
Init initializes a dynamic bytes file.
func (*DynamicBytesFile) Locks ¶
func (f *DynamicBytesFile) Locks() *vfs.FileLocks
Locks returns the file locks for this file.
func (*DynamicBytesFile) Open ¶
func (f *DynamicBytesFile) Open(ctx context.Context, rp *vfs.ResolvingPath, d *Dentry, opts vfs.OpenOptions) (*vfs.FileDescription, error)
Open implements Inode.Open.
func (*DynamicBytesFile) SetStat ¶
func (*DynamicBytesFile) SetStat(context.Context, *vfs.Filesystem, *auth.Credentials, vfs.SetStatOptions) error
SetStat implements Inode.SetStat. By default DynamicBytesFile doesn't allow inode attributes to be changed. Override SetStat() making it call f.InodeAttrs to allow it.
type Filesystem ¶
type Filesystem struct { // MaxCachedDentries is the maximum size of cachedDentries. If not set, // defaults to 0 and kernfs does not cache any dentries. This is immutable. MaxCachedDentries uint64 // contains filtered or unexported fields }
Filesystem mostly implements vfs.FilesystemImpl for a generic in-memory filesystem. Concrete implementations are expected to embed this in their own Filesystem type.
+stateify savable
func (*Filesystem) AccessAt ¶
func (fs *Filesystem) AccessAt(ctx context.Context, rp *vfs.ResolvingPath, creds *auth.Credentials, ats vfs.AccessTypes) error
AccessAt implements vfs.Filesystem.Impl.AccessAt.
func (*Filesystem) BoundEndpointAt ¶
func (fs *Filesystem) BoundEndpointAt(ctx context.Context, rp *vfs.ResolvingPath, opts vfs.BoundEndpointOptions) (transport.BoundEndpoint, error)
BoundEndpointAt implements vfs.FilesystemImpl.BoundEndpointAt.
func (*Filesystem) GetDentryAt ¶
func (fs *Filesystem) GetDentryAt(ctx context.Context, rp *vfs.ResolvingPath, opts vfs.GetDentryOptions) (*vfs.Dentry, error)
GetDentryAt implements vfs.FilesystemImpl.GetDentryAt.
func (*Filesystem) GetParentDentryAt ¶
func (fs *Filesystem) GetParentDentryAt(ctx context.Context, rp *vfs.ResolvingPath) (*vfs.Dentry, error)
GetParentDentryAt implements vfs.FilesystemImpl.GetParentDentryAt.
func (*Filesystem) GetXattrAt ¶
func (fs *Filesystem) GetXattrAt(ctx context.Context, rp *vfs.ResolvingPath, opts vfs.GetXattrOptions) (string, error)
GetXattrAt implements vfs.FilesystemImpl.GetXattrAt.
func (*Filesystem) IsDescendant ¶
func (fs *Filesystem) IsDescendant(vfsroot, vd vfs.VirtualDentry) bool
IsDescendant implements vfs.FilesystemImpl.IsDescendant.
func (*Filesystem) LinkAt ¶
func (fs *Filesystem) LinkAt(ctx context.Context, rp *vfs.ResolvingPath, vd vfs.VirtualDentry) error
LinkAt implements vfs.FilesystemImpl.LinkAt.
func (*Filesystem) ListXattrAt ¶
func (fs *Filesystem) ListXattrAt(ctx context.Context, rp *vfs.ResolvingPath, size uint64) ([]string, error)
ListXattrAt implements vfs.FilesystemImpl.ListXattrAt.
func (*Filesystem) MkdirAt ¶
func (fs *Filesystem) MkdirAt(ctx context.Context, rp *vfs.ResolvingPath, opts vfs.MkdirOptions) error
MkdirAt implements vfs.FilesystemImpl.MkdirAt.
func (*Filesystem) MknodAt ¶
func (fs *Filesystem) MknodAt(ctx context.Context, rp *vfs.ResolvingPath, opts vfs.MknodOptions) error
MknodAt implements vfs.FilesystemImpl.MknodAt.
func (*Filesystem) NextIno ¶
func (fs *Filesystem) NextIno() uint64
NextIno allocates a new inode number on this filesystem.
func (*Filesystem) OpenAt ¶
func (fs *Filesystem) OpenAt(ctx context.Context, rp *vfs.ResolvingPath, opts vfs.OpenOptions) (*vfs.FileDescription, error)
OpenAt implements vfs.FilesystemImpl.OpenAt.
func (*Filesystem) PrependPath ¶
func (fs *Filesystem) PrependPath(ctx context.Context, vfsroot, vd vfs.VirtualDentry, b *fspath.Builder) error
PrependPath implements vfs.FilesystemImpl.PrependPath.
func (*Filesystem) ReadlinkAt ¶
func (fs *Filesystem) ReadlinkAt(ctx context.Context, rp *vfs.ResolvingPath) (string, error)
ReadlinkAt implements vfs.FilesystemImpl.ReadlinkAt.
func (*Filesystem) Release ¶
func (fs *Filesystem) Release(ctx context.Context)
Release implements vfs.FilesystemImpl.Release.
func (*Filesystem) RemoveXattrAt ¶
func (fs *Filesystem) RemoveXattrAt(ctx context.Context, rp *vfs.ResolvingPath, name string) error
RemoveXattrAt implements vfs.FilesystemImpl.RemoveXattrAt.
func (*Filesystem) RenameAt ¶
func (fs *Filesystem) RenameAt(ctx context.Context, rp *vfs.ResolvingPath, oldParentVD vfs.VirtualDentry, oldName string, opts vfs.RenameOptions) error
RenameAt implements vfs.FilesystemImpl.RenameAt.
func (*Filesystem) RmdirAt ¶
func (fs *Filesystem) RmdirAt(ctx context.Context, rp *vfs.ResolvingPath) error
RmdirAt implements vfs.FilesystemImpl.RmdirAt.
func (*Filesystem) SafeDecRef ¶
func (fs *Filesystem) SafeDecRef(ctx context.Context, vd vfs.VirtualDentry)
SafeDecRef safely DecRef the virtual dentry making sure DecRef is deferred in case Filesystem.mu is held. See comment on Filesystem.mu.
func (*Filesystem) SafeDecRefFD ¶
func (fs *Filesystem) SafeDecRefFD(ctx context.Context, fd *vfs.FileDescription)
SafeDecRefFD safely DecRef the FileDescription making sure DecRef is deferred in case Filesystem.mu is held. See comment on Filesystem.mu.
func (*Filesystem) SetStatAt ¶
func (fs *Filesystem) SetStatAt(ctx context.Context, rp *vfs.ResolvingPath, opts vfs.SetStatOptions) error
SetStatAt implements vfs.FilesystemImpl.SetStatAt.
func (*Filesystem) SetXattrAt ¶
func (fs *Filesystem) SetXattrAt(ctx context.Context, rp *vfs.ResolvingPath, opts vfs.SetXattrOptions) error
SetXattrAt implements vfs.FilesystemImpl.SetXattrAt.
func (*Filesystem) StatAt ¶
func (fs *Filesystem) StatAt(ctx context.Context, rp *vfs.ResolvingPath, opts vfs.StatOptions) (linux.Statx, error)
StatAt implements vfs.FilesystemImpl.StatAt.
func (*Filesystem) StatFSAt ¶
func (fs *Filesystem) StatFSAt(ctx context.Context, rp *vfs.ResolvingPath) (linux.Statfs, error)
StatFSAt implements vfs.FilesystemImpl.StatFSAt.
func (*Filesystem) SymlinkAt ¶
func (fs *Filesystem) SymlinkAt(ctx context.Context, rp *vfs.ResolvingPath, target string) error
SymlinkAt implements vfs.FilesystemImpl.SymlinkAt.
func (*Filesystem) Sync ¶
func (fs *Filesystem) Sync(ctx context.Context) error
Sync implements vfs.FilesystemImpl.Sync.
func (*Filesystem) UnlinkAt ¶
func (fs *Filesystem) UnlinkAt(ctx context.Context, rp *vfs.ResolvingPath) error
UnlinkAt implements vfs.FilesystemImpl.UnlinkAt.
func (*Filesystem) VFSFilesystem ¶
func (fs *Filesystem) VFSFilesystem() *vfs.Filesystem
VFSFilesystem returns the generic vfs filesystem object.
type GenericDirectoryFD ¶
type GenericDirectoryFD struct { vfs.FileDescriptionDefaultImpl vfs.DirectoryFileDescriptionDefaultImpl vfs.LockFD // contains filtered or unexported fields }
GenericDirectoryFD implements vfs.FileDescriptionImpl for a generic directory inode that uses OrderChildren to track child nodes.
Note that GenericDirectoryFD holds a lock over OrderedChildren while calling IterDirents callback. The IterDirents callback therefore cannot hash or unhash children, or recursively call IterDirents on the same underlying inode.
Must be initialize with Init before first use.
Lock ordering: mu => children.mu.
+stateify savable
func NewGenericDirectoryFD ¶
func NewGenericDirectoryFD(m *vfs.Mount, d *Dentry, children *OrderedChildren, locks *vfs.FileLocks, opts *vfs.OpenOptions, fdOpts GenericDirectoryFDOptions) (*GenericDirectoryFD, error)
NewGenericDirectoryFD creates a new GenericDirectoryFD and returns its dentry.
func (*GenericDirectoryFD) Allocate ¶
func (fd *GenericDirectoryFD) Allocate(ctx context.Context, mode, offset, length uint64) error
Allocate implements vfs.FileDescriptionImpl.Allocate.
func (*GenericDirectoryFD) ConfigureMMap ¶
ConfigureMMap implements vfs.FileDescriptionImpl.ConfigureMMap.
func (*GenericDirectoryFD) Init ¶
func (fd *GenericDirectoryFD) Init(children *OrderedChildren, locks *vfs.FileLocks, opts *vfs.OpenOptions, fdOpts GenericDirectoryFDOptions) error
Init initializes a GenericDirectoryFD. Use it when overriding GenericDirectoryFD. Caller must call fd.VFSFileDescription.Init() with the correct implementation.
func (*GenericDirectoryFD) IterDirents ¶
func (fd *GenericDirectoryFD) IterDirents(ctx context.Context, cb vfs.IterDirentsCallback) error
IterDirents implements vfs.FileDescriptionImpl.IterDirents. IterDirents holds o.mu when calling cb.
func (*GenericDirectoryFD) PRead ¶
func (fd *GenericDirectoryFD) PRead(ctx context.Context, dst usermem.IOSequence, offset int64, opts vfs.ReadOptions) (int64, error)
PRead implements vfs.FileDescriptionImpl.PRead.
func (*GenericDirectoryFD) PWrite ¶
func (fd *GenericDirectoryFD) PWrite(ctx context.Context, src usermem.IOSequence, offset int64, opts vfs.WriteOptions) (int64, error)
PWrite implements vfs.FileDescriptionImpl.PWrite.
func (*GenericDirectoryFD) Read ¶
func (fd *GenericDirectoryFD) Read(ctx context.Context, dst usermem.IOSequence, opts vfs.ReadOptions) (int64, error)
Read implements vfs.FileDescriptionImpl.Read.
func (*GenericDirectoryFD) Release ¶
func (fd *GenericDirectoryFD) Release(context.Context)
Release implements vfs.FileDescriptionImpl.Release.
func (*GenericDirectoryFD) SetStat ¶
func (fd *GenericDirectoryFD) SetStat(ctx context.Context, opts vfs.SetStatOptions) error
SetStat implements vfs.FileDescriptionImpl.SetStat.
func (*GenericDirectoryFD) Stat ¶
func (fd *GenericDirectoryFD) Stat(ctx context.Context, opts vfs.StatOptions) (linux.Statx, error)
Stat implements vfs.FileDescriptionImpl.Stat.
func (*GenericDirectoryFD) VFSFileDescription ¶
func (fd *GenericDirectoryFD) VFSFileDescription() *vfs.FileDescription
VFSFileDescription returns a pointer to the vfs.FileDescription representing this object.
func (*GenericDirectoryFD) Write ¶
func (fd *GenericDirectoryFD) Write(ctx context.Context, src usermem.IOSequence, opts vfs.WriteOptions) (int64, error)
Write implements vfs.FileDescriptionImpl.Write.
type GenericDirectoryFDOptions ¶
type GenericDirectoryFDOptions struct {
SeekEnd SeekEndConfig
}
GenericDirectoryFDOptions contains configuration for a GenericDirectoryFD.
+stateify savable
type Inode ¶
type Inode interface { // Open creates a file description for the filesystem object represented by // this inode. The returned file description should hold a reference on the // dentry for its lifetime. // // Precondition: rp.Done(). vfsd.Impl() must be the kernfs Dentry containing // the inode on which Open() is being called. Open(ctx context.Context, rp *vfs.ResolvingPath, d *Dentry, opts vfs.OpenOptions) (*vfs.FileDescription, error) // StatFS returns filesystem statistics for the client filesystem. This // corresponds to vfs.FilesystemImpl.StatFSAt. If the client filesystem // doesn't support statfs(2), this should return ENOSYS. StatFS(ctx context.Context, fs *vfs.Filesystem) (linux.Statfs, error) // Keep indicates whether the dentry created after Inode.Lookup should be // kept in the kernfs dentry tree. Keep() bool // Valid should return true if this inode is still valid, or needs to // be resolved again by a call to Lookup. Valid(ctx context.Context, parent *Dentry, name string) bool // Watches returns the set of inotify watches associated with this inode. Watches() *vfs.Watches // Anonymous indicates that the Inode is anonymous. It will never have // a name or parent. Anonymous() bool // contains filtered or unexported methods }
The Inode interface maps filesystem-level operations that operate on paths to equivalent operations on specific filesystem nodes.
The interface methods are groups into logical categories as sub interfaces below. Generally, an implementation for each sub interface can be provided by embedding an appropriate type from inode_impl_utils.go. The sub interfaces are purely organizational. Methods declared directly in the main interface have no generic implementations, and should be explicitly provided by the client filesystem.
Generally, implementations are not responsible for tasks that are common to all filesystems. These include:
- Checking that dentries passed to methods are of the appropriate file type.
- Checking permissions.
Inode functions may be called holding filesystem wide locks and are not allowed to call vfs functions that may reenter, unless otherwise noted.
Specific responsibilities of implementations are documented below.
func NewStaticDir ¶
func NewStaticDir(ctx context.Context, creds *auth.Credentials, devMajor, devMinor uint32, ino uint64, perm linux.FileMode, children map[string]Inode, fdOpts GenericDirectoryFDOptions) Inode
NewStaticDir creates a new static directory and returns its dentry.
func NewStaticSymlink ¶
func NewStaticSymlink(ctx context.Context, creds *auth.Credentials, devMajor, devMinor uint32, ino uint64, target string) Inode
NewStaticSymlink creates a new symlink file pointing to 'target'.
type InodeAlwaysValid ¶
type InodeAlwaysValid struct{}
InodeAlwaysValid partially implements Inode.
+stateify savable
type InodeAnonymous ¶
type InodeAnonymous struct{}
InodeAnonymous partially implements Inode.
+stateify savable
func (*InodeAnonymous) Anonymous ¶
func (*InodeAnonymous) Anonymous() bool
Anonymous implements Inode.Anonymous
type InodeAttrs ¶
type InodeAttrs struct {
// contains filtered or unexported fields
}
InodeAttrs partially implements the Inode interface, specifically the inodeMetadata sub interface. InodeAttrs provides functionality related to inode attributes.
Must be initialized by Init prior to first use.
+stateify savable
func (*InodeAttrs) CheckPermissions ¶
func (a *InodeAttrs) CheckPermissions(_ context.Context, creds *auth.Credentials, ats vfs.AccessTypes) error
CheckPermissions implements Inode.CheckPermissions.
func (*InodeAttrs) DevMajor ¶
func (a *InodeAttrs) DevMajor() uint32
DevMajor returns the device major number.
func (*InodeAttrs) DevMinor ¶
func (a *InodeAttrs) DevMinor() uint32
DevMinor returns the device minor number.
func (*InodeAttrs) IncLinks ¶
func (a *InodeAttrs) IncLinks(n uint32)
IncLinks implements Inode.IncLinks.
func (*InodeAttrs) Init ¶
func (a *InodeAttrs) Init(ctx context.Context, creds *auth.Credentials, devMajor, devMinor uint32, ino uint64, mode linux.FileMode)
Init initializes this InodeAttrs.
func (*InodeAttrs) InitWithIDs ¶
func (a *InodeAttrs) InitWithIDs(ctx context.Context, uid auth.KUID, gid auth.KGID, devMajor, devMinor uint32, ino uint64, mode linux.FileMode)
InitWithIDs initializes this InodeAttrs.
func (*InodeAttrs) SetStat ¶
func (a *InodeAttrs) SetStat(ctx context.Context, fs *vfs.Filesystem, creds *auth.Credentials, opts vfs.SetStatOptions) error
SetStat implements Inode.SetStat.
func (*InodeAttrs) Stat ¶
func (a *InodeAttrs) Stat(context.Context, *vfs.Filesystem, vfs.StatOptions) (linux.Statx, error)
Stat partially implements Inode.Stat. Note that this function doesn't provide all the stat fields, and the embedder should consider extending the result with filesystem-specific fields.
func (*InodeAttrs) TouchAtime ¶
func (a *InodeAttrs) TouchAtime(ctx context.Context, mnt *vfs.Mount)
TouchAtime updates a.atime to the current time.
func (*InodeAttrs) TouchCMtime ¶
func (a *InodeAttrs) TouchCMtime(ctx context.Context)
TouchCMtime updates a.{c/m}time to the current time. The caller should synchronize calls to this so that ctime and mtime are updated to the same value.
type InodeDirectoryNoNewChildren ¶
type InodeDirectoryNoNewChildren struct{}
InodeDirectoryNoNewChildren partially implements the Inode interface. InodeDirectoryNoNewChildren represents a directory inode which does not support creation of new children.
+stateify savable
func (InodeDirectoryNoNewChildren) NewDir ¶
func (InodeDirectoryNoNewChildren) NewDir(context.Context, string, vfs.MkdirOptions) (Inode, error)
NewDir implements Inode.NewDir.
func (InodeDirectoryNoNewChildren) NewFile ¶
func (InodeDirectoryNoNewChildren) NewFile(context.Context, string, vfs.OpenOptions) (Inode, error)
NewFile implements Inode.NewFile.
func (InodeDirectoryNoNewChildren) NewNode ¶
func (InodeDirectoryNoNewChildren) NewNode(context.Context, string, vfs.MknodOptions) (Inode, error)
NewNode implements Inode.NewNode.
func (InodeDirectoryNoNewChildren) NewSymlink ¶
NewSymlink implements Inode.NewSymlink.
type InodeNoStatFS ¶
type InodeNoStatFS struct{}
InodeNoStatFS partially implements the Inode interface, where the client filesystem doesn't support statfs(2).
+stateify savable
func (*InodeNoStatFS) StatFS ¶
func (*InodeNoStatFS) StatFS(context.Context, *vfs.Filesystem) (linux.Statfs, error)
StatFS implements Inode.StatFS.
type InodeNoopRefCount ¶
type InodeNoopRefCount struct {
InodeTemporary
}
InodeNoopRefCount partially implements the Inode interface, specifically the inodeRefs sub interface. InodeNoopRefCount implements a simple reference count for inodes, performing no extra actions when references are obtained or released. This is suitable for simple file inodes that don't reference any resources.
+stateify savable
func (InodeNoopRefCount) DecRef ¶
func (InodeNoopRefCount) DecRef(context.Context)
DecRef implements Inode.DecRef.
func (InodeNoopRefCount) TryIncRef ¶
func (InodeNoopRefCount) TryIncRef() bool
TryIncRef implements Inode.TryIncRef.
type InodeNotAnonymous ¶
type InodeNotAnonymous struct{}
InodeNotAnonymous partially implements Inode.
+stateify savable
func (*InodeNotAnonymous) Anonymous ¶
func (*InodeNotAnonymous) Anonymous() bool
Anonymous implements Inode.Anonymous
type InodeNotDirectory ¶
type InodeNotDirectory struct {
InodeAlwaysValid
}
InodeNotDirectory partially implements the Inode interface, specifically the inodeDirectory and inodeDynamicDirectory sub interfaces. Inodes that do not represent directories can embed this to provide no-op implementations for directory-related functions.
+stateify savable
func (InodeNotDirectory) HasChildren ¶
func (InodeNotDirectory) HasChildren() bool
HasChildren implements Inode.HasChildren.
func (InodeNotDirectory) IterDirents ¶
func (InodeNotDirectory) IterDirents(ctx context.Context, mnt *vfs.Mount, callback vfs.IterDirentsCallback, offset, relOffset int64) (newOffset int64, err error)
IterDirents implements Inode.IterDirents.
func (InodeNotDirectory) NewDir ¶
func (InodeNotDirectory) NewDir(context.Context, string, vfs.MkdirOptions) (Inode, error)
NewDir implements Inode.NewDir.
func (InodeNotDirectory) NewFile ¶
func (InodeNotDirectory) NewFile(context.Context, string, vfs.OpenOptions) (Inode, error)
NewFile implements Inode.NewFile.
func (InodeNotDirectory) NewNode ¶
func (InodeNotDirectory) NewNode(context.Context, string, vfs.MknodOptions) (Inode, error)
NewNode implements Inode.NewNode.
func (InodeNotDirectory) NewSymlink ¶
NewSymlink implements Inode.NewSymlink.
type InodeNotSymlink ¶
type InodeNotSymlink struct{}
InodeNotSymlink partially implements the Inode interface, specifically the inodeSymlink sub interface. All inodes that are not symlinks may embed this to return the appropriate errors from symlink-related functions.
+stateify savable
type InodeSymlink ¶
type InodeSymlink struct {
InodeNotDirectory
}
InodeSymlink partially implements Inode interface for symlinks.
+stateify savable
func (InodeSymlink) Open ¶
func (InodeSymlink) Open(ctx context.Context, rp *vfs.ResolvingPath, d *Dentry, opts vfs.OpenOptions) (*vfs.FileDescription, error)
Open implements Inode.Open.
type InodeTemporary ¶
type InodeTemporary struct{}
InodeTemporary partially implements Inode.
+stateify savable
type InodeWatches ¶
type InodeWatches struct {
// contains filtered or unexported fields
}
InodeWatches partially implements Inode.
+stateify savable
func (*InodeWatches) Watches ¶
func (i *InodeWatches) Watches() *vfs.Watches
Watches implements Inode.Watches.
type OrderedChildren ¶
type OrderedChildren struct {
// contains filtered or unexported fields
}
OrderedChildren partially implements the Inode interface. OrderedChildren can be embedded in directory inodes to keep track of children in the directory, and can then be used to implement a generic directory FD -- see GenericDirectoryFD.
OrderedChildren can represent a node in an Inode tree. The children inodes might be directories themselves using OrderedChildren; hence extending the tree. The parent inode (OrderedChildren user) holds a ref on all its static children. This lets the static inodes outlive their associated dentry. While the dentry might have to be regenerated via a Lookup() call, we can keep reusing the same static inode. These static children inodes are finally DecRef'd when this directory inode is being destroyed. This makes OrderedChildren suitable for static directory entries as well.
Must be initialize with Init before first use.
+stateify savable
func (*OrderedChildren) Destroy ¶
func (o *OrderedChildren) Destroy(ctx context.Context)
Destroy clears the children stored in o. It should be called by structs embedding OrderedChildren upon destruction, i.e. when their reference count reaches zero.
func (*OrderedChildren) ForEachChild ¶
func (o *OrderedChildren) ForEachChild(fn func(string, Inode))
ForEachChild calls fn on all children tracked by this ordered children.
func (*OrderedChildren) HasChildren ¶
func (o *OrderedChildren) HasChildren() bool
HasChildren implements Inode.HasChildren.
func (*OrderedChildren) Init ¶
func (o *OrderedChildren) Init(opts OrderedChildrenOptions)
Init initializes an OrderedChildren.
func (*OrderedChildren) Insert ¶
func (o *OrderedChildren) Insert(name string, child Inode) error
Insert inserts a dynamic child into o. This ignores the writability of o, as this is not part of the vfs.FilesystemImpl interface, and is a lower-level operation.
func (*OrderedChildren) Inserter ¶
func (o *OrderedChildren) Inserter(name string, makeChild func() Inode) (Inode, error)
Inserter is like Insert, but obtains the child to insert by calling makeChild. makeChild is only called if the insert will succeed. This allows the caller to atomically check and insert a child without having to clean up the child on failure.
func (*OrderedChildren) IterDirents ¶
func (o *OrderedChildren) IterDirents(ctx context.Context, mnt *vfs.Mount, cb vfs.IterDirentsCallback, offset, relOffset int64) (newOffset int64, err error)
IterDirents implements Inode.IterDirents.
func (*OrderedChildren) Populate ¶
func (o *OrderedChildren) Populate(children map[string]Inode) uint32
Populate inserts static children into this OrderedChildren. Populate returns the number of directories inserted, which the caller may use to update the link count for the parent directory.
Precondition:
- d must represent a directory inode.
- children must not contain any conflicting entries already in o.
- Caller must hold a reference on all inodes passed.
Postcondition: Caller's references on inodes are transferred to o.
func (*OrderedChildren) Rename ¶
func (o *OrderedChildren) Rename(ctx context.Context, oldname, newname string, child, dstDir Inode) error
Rename implements Inode.Rename.
Precondition: Rename may only be called across two directory inodes with identical implementations of Rename. Practically, this means filesystems that implement Rename by embedding OrderedChildren for any directory implementation must use OrderedChildren for all directory implementations that will support Rename.
Postcondition: reference on any replaced dentry transferred to caller.
type OrderedChildrenOptions ¶
type OrderedChildrenOptions struct { // Writable indicates whether vfs.FilesystemImpl methods implemented by // OrderedChildren may modify the tracked children. This applies to // operations related to rename, unlink and rmdir. If an OrderedChildren is // not writable, these operations all fail with EPERM. // // Note that writable users must implement the sticky bit (I_SVTX). Writable bool }
OrderedChildrenOptions contains initialization options for OrderedChildren.
+stateify savable
type SeekEndConfig ¶
type SeekEndConfig int
SeekEndConfig describes the SEEK_END behaviour for FDs.
+stateify savable
type StaticDirectory ¶
type StaticDirectory struct { InodeAlwaysValid InodeAttrs InodeDirectoryNoNewChildren InodeNoStatFS InodeNotAnonymous InodeNotSymlink InodeTemporary InodeWatches OrderedChildren StaticDirectoryRefs // contains filtered or unexported fields }
StaticDirectory is a standard implementation of a directory with static contents.
+stateify savable
func (*StaticDirectory) DecRef ¶
func (s *StaticDirectory) DecRef(ctx context.Context)
DecRef implements Inode.DecRef.
func (*StaticDirectory) Init ¶
func (s *StaticDirectory) Init(ctx context.Context, creds *auth.Credentials, devMajor, devMinor uint32, ino uint64, perm linux.FileMode, fdOpts GenericDirectoryFDOptions)
Init initializes StaticDirectory.
func (*StaticDirectory) Open ¶
func (s *StaticDirectory) Open(ctx context.Context, rp *vfs.ResolvingPath, d *Dentry, opts vfs.OpenOptions) (*vfs.FileDescription, error)
Open implements Inode.Open.
func (*StaticDirectory) SetStat ¶
func (*StaticDirectory) SetStat(context.Context, *vfs.Filesystem, *auth.Credentials, vfs.SetStatOptions) error
SetStat implements Inode.SetStat not allowing inode attributes to be changed.
type StaticSymlink ¶
type StaticSymlink struct { InodeAttrs InodeNoopRefCount InodeNotAnonymous InodeSymlink InodeNoStatFS InodeWatches // contains filtered or unexported fields }
StaticSymlink provides an Inode implementation for symlinks that point to a immutable target.
+stateify savable
func (*StaticSymlink) Getlink ¶
func (s *StaticSymlink) Getlink(context.Context, *vfs.Mount) (vfs.VirtualDentry, string, error)
Getlink implements Inode.Getlink.
func (*StaticSymlink) Init ¶
func (s *StaticSymlink) Init(ctx context.Context, creds *auth.Credentials, devMajor uint32, devMinor uint32, ino uint64, target string)
Init initializes the instance.
func (*StaticSymlink) SetStat ¶
func (*StaticSymlink) SetStat(context.Context, *vfs.Filesystem, *auth.Credentials, vfs.SetStatOptions) error
SetStat implements Inode.SetStat not allowing inode attributes to be changed.