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 reponsible 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) StateFields() []string
- func (i *CachedMappable) StateLoad(stateSourceObject state.Source)
- func (i *CachedMappable) StateSave(stateSinkObject state.Sink)
- func (i *CachedMappable) StateTypeName() string
- 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 (e *Dentry) Next() *Dentry
- func (d *Dentry) OnZeroWatches(context.Context)
- func (d *Dentry) Parent() *Dentry
- func (e *Dentry) Prev() *Dentry
- func (d *Dentry) RefType() string
- func (e *Dentry) SetNext(elem *Dentry)
- func (e *Dentry) SetPrev(elem *Dentry)
- func (d *Dentry) StateFields() []string
- func (d *Dentry) StateLoad(stateSourceObject state.Source)
- func (d *Dentry) StateSave(stateSinkObject state.Sink)
- func (d *Dentry) StateTypeName() 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) StateFields() []string
- func (fd *DynamicBytesFD) StateLoad(stateSourceObject state.Source)
- func (fd *DynamicBytesFD) StateSave(stateSinkObject state.Sink)
- func (fd *DynamicBytesFD) StateTypeName() string
- 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
- func (f *DynamicBytesFile) StateFields() []string
- func (f *DynamicBytesFile) StateLoad(stateSourceObject state.Source)
- func (f *DynamicBytesFile) StateSave(stateSinkObject state.Sink)
- func (f *DynamicBytesFile) StateTypeName() string
- 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) 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) StateFields() []string
- func (fs *Filesystem) StateLoad(stateSourceObject state.Source)
- func (fs *Filesystem) StateSave(stateSinkObject state.Sink)
- func (fs *Filesystem) StateTypeName() string
- 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) StateFields() []string
- func (fd *GenericDirectoryFD) StateLoad(stateSourceObject state.Source)
- func (fd *GenericDirectoryFD) StateSave(stateSinkObject state.Sink)
- func (fd *GenericDirectoryFD) StateTypeName() string
- 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) 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) StateFields() []string
- func (a *InodeAttrs) StateLoad(stateSourceObject state.Source)
- func (a *InodeAttrs) StateSave(stateSinkObject state.Sink)
- func (a *InodeAttrs) StateTypeName() string
- 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)
- func (i *InodeDirectoryNoNewChildren) StateFields() []string
- func (i *InodeDirectoryNoNewChildren) StateLoad(stateSourceObject state.Source)
- func (i *InodeDirectoryNoNewChildren) StateSave(stateSinkObject state.Sink)
- func (i *InodeDirectoryNoNewChildren) StateTypeName() string
- type InodeNoStatFS
- func (*InodeNoStatFS) StatFS(context.Context, *vfs.Filesystem) (linux.Statfs, error)
- func (i *InodeNoStatFS) StateFields() []string
- func (i *InodeNoStatFS) StateLoad(stateSourceObject state.Source)
- func (i *InodeNoStatFS) StateSave(stateSinkObject state.Sink)
- func (i *InodeNoStatFS) StateTypeName() string
- type InodeNoopRefCount
- func (InodeNoopRefCount) DecRef(context.Context)
- func (InodeNoopRefCount) IncRef()
- func (i *InodeNoopRefCount) StateFields() []string
- func (i *InodeNoopRefCount) StateLoad(stateSourceObject state.Source)
- func (i *InodeNoopRefCount) StateSave(stateSinkObject state.Sink)
- func (i *InodeNoopRefCount) StateTypeName() string
- func (InodeNoopRefCount) TryIncRef() bool
- 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 (i *InodeNotDirectory) StateFields() []string
- func (i *InodeNotDirectory) StateLoad(stateSourceObject state.Source)
- func (i *InodeNotDirectory) StateSave(stateSinkObject state.Sink)
- func (i *InodeNotDirectory) StateTypeName() string
- func (InodeNotDirectory) Unlink(context.Context, string, Inode) error
- type InodeNotSymlink
- func (InodeNotSymlink) Getlink(context.Context, *vfs.Mount) (vfs.VirtualDentry, string, error)
- func (InodeNotSymlink) Readlink(context.Context, *vfs.Mount) (string, error)
- func (i *InodeNotSymlink) StateFields() []string
- func (i *InodeNotSymlink) StateLoad(stateSourceObject state.Source)
- func (i *InodeNotSymlink) StateSave(stateSinkObject state.Sink)
- func (i *InodeNotSymlink) StateTypeName() string
- type InodeSymlink
- func (InodeSymlink) Open(ctx context.Context, rp *vfs.ResolvingPath, d *Dentry, opts vfs.OpenOptions) (*vfs.FileDescription, error)
- func (i *InodeSymlink) StateFields() []string
- func (i *InodeSymlink) StateLoad(stateSourceObject state.Source)
- func (i *InodeSymlink) StateSave(stateSinkObject state.Sink)
- func (i *InodeSymlink) StateTypeName() string
- 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) StateFields() []string
- func (o *OrderedChildren) StateLoad(stateSourceObject state.Source)
- func (o *OrderedChildren) StateSave(stateSinkObject state.Sink)
- func (o *OrderedChildren) StateTypeName() string
- 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
- func (s *StaticDirectory) StateFields() []string
- func (s *StaticDirectory) StateLoad(stateSourceObject state.Source)
- func (s *StaticDirectory) StateSave(stateSinkObject state.Sink)
- func (s *StaticDirectory) StateTypeName() string
- type StaticDirectoryRefs
- func (r *StaticDirectoryRefs) DecRef(destroy func())
- func (r *StaticDirectoryRefs) IncRef()
- func (r *StaticDirectoryRefs) InitRefs()
- func (r *StaticDirectoryRefs) LeakMessage() string
- func (r *StaticDirectoryRefs) LogRefs() bool
- func (r *StaticDirectoryRefs) ReadRefs() int64
- func (r *StaticDirectoryRefs) RefType() string
- func (r *StaticDirectoryRefs) StateFields() []string
- func (r *StaticDirectoryRefs) StateLoad(stateSourceObject state.Source)
- func (r *StaticDirectoryRefs) StateSave(stateSinkObject state.Sink)
- func (r *StaticDirectoryRefs) StateTypeName() string
- func (r *StaticDirectoryRefs) TryIncRef() bool
- 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
- func (s *StaticSymlink) StateFields() []string
- func (s *StaticSymlink) StateLoad(stateSourceObject state.Source)
- func (s *StaticSymlink) StateSave(stateSinkObject state.Sink)
- func (s *StaticSymlink) StateTypeName() string
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.
const StaticDirectoryenableLogging = false
enableLogging indicates whether reference-related events should be logged (with stack traces). This is false by default and should only be set to true for debugging purposes, as it can generate an extremely large amount of output and drastically degrade performance.
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) StateFields ¶
func (i *CachedMappable) StateFields() []string
func (*CachedMappable) StateLoad ¶
func (i *CachedMappable) StateLoad(stateSourceObject state.Source)
+checklocksignore
func (*CachedMappable) StateSave ¶
func (i *CachedMappable) StateSave(stateSinkObject state.Sink)
+checklocksignore
func (*CachedMappable) StateTypeName ¶
func (i *CachedMappable) StateTypeName() string
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) Next ¶
func (e *Dentry) Next() *Dentry
Next returns the entry that follows e in the list.
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) Prev ¶
func (e *Dentry) Prev() *Dentry
Prev returns the entry that precedes e in the list.
func (*Dentry) SetNext ¶
func (e *Dentry) SetNext(elem *Dentry)
SetNext assigns 'entry' as the entry that follows e in the list.
func (*Dentry) SetPrev ¶
func (e *Dentry) SetPrev(elem *Dentry)
SetPrev assigns 'entry' as the entry that precedes e in the list.
func (*Dentry) StateFields ¶
func (*Dentry) StateTypeName ¶
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) StateFields ¶
func (fd *DynamicBytesFD) StateFields() []string
func (*DynamicBytesFD) StateLoad ¶
func (fd *DynamicBytesFD) StateLoad(stateSourceObject state.Source)
+checklocksignore
func (*DynamicBytesFD) StateSave ¶
func (fd *DynamicBytesFD) StateSave(stateSinkObject state.Sink)
+checklocksignore
func (*DynamicBytesFD) StateTypeName ¶
func (fd *DynamicBytesFD) StateTypeName() string
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.
func (*DynamicBytesFile) StateFields ¶
func (f *DynamicBytesFile) StateFields() []string
func (*DynamicBytesFile) StateLoad ¶
func (f *DynamicBytesFile) StateLoad(stateSourceObject state.Source)
+checklocksignore
func (*DynamicBytesFile) StateSave ¶
func (f *DynamicBytesFile) StateSave(stateSinkObject state.Sink)
+checklocksignore
func (*DynamicBytesFile) StateTypeName ¶
func (f *DynamicBytesFile) StateTypeName() string
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) 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) StateFields ¶
func (fs *Filesystem) StateFields() []string
func (*Filesystem) StateLoad ¶
func (fs *Filesystem) StateLoad(stateSourceObject state.Source)
+checklocksignore
func (*Filesystem) StateSave ¶
func (fs *Filesystem) StateSave(stateSinkObject state.Sink)
+checklocksignore
func (*Filesystem) StateTypeName ¶
func (fs *Filesystem) StateTypeName() string
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 implmenets 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 implmenets 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) StateFields ¶
func (fd *GenericDirectoryFD) StateFields() []string
func (*GenericDirectoryFD) StateLoad ¶
func (fd *GenericDirectoryFD) StateLoad(stateSourceObject state.Source)
+checklocksignore
func (*GenericDirectoryFD) StateSave ¶
func (fd *GenericDirectoryFD) StateSave(stateSinkObject state.Sink)
+checklocksignore
func (*GenericDirectoryFD) StateTypeName ¶
func (fd *GenericDirectoryFD) StateTypeName() string
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
func (*GenericDirectoryFDOptions) StateFields ¶
func (g *GenericDirectoryFDOptions) StateFields() []string
func (*GenericDirectoryFDOptions) StateLoad ¶
func (g *GenericDirectoryFDOptions) StateLoad(stateSourceObject state.Source)
+checklocksignore
func (*GenericDirectoryFDOptions) StateSave ¶
func (g *GenericDirectoryFDOptions) StateSave(stateSinkObject state.Sink)
+checklocksignore
func (*GenericDirectoryFDOptions) StateTypeName ¶
func (g *GenericDirectoryFDOptions) StateTypeName() string
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) 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
func (*InodeAlwaysValid) StateFields ¶
func (i *InodeAlwaysValid) StateFields() []string
func (*InodeAlwaysValid) StateLoad ¶
func (i *InodeAlwaysValid) StateLoad(stateSourceObject state.Source)
+checklocksignore
func (*InodeAlwaysValid) StateSave ¶
func (i *InodeAlwaysValid) StateSave(stateSinkObject state.Sink)
+checklocksignore
func (*InodeAlwaysValid) StateTypeName ¶
func (i *InodeAlwaysValid) StateTypeName() string
type InodeAnonymous ¶
type InodeAnonymous struct{}
InodeAnonymous partially implements Inode.
+stateify savable
func (*InodeAnonymous) Anonymous ¶
func (*InodeAnonymous) Anonymous() bool
Anonymous implements Inode.Anonymous
func (*InodeAnonymous) StateFields ¶
func (i *InodeAnonymous) StateFields() []string
func (*InodeAnonymous) StateLoad ¶
func (i *InodeAnonymous) StateLoad(stateSourceObject state.Source)
+checklocksignore
func (*InodeAnonymous) StateSave ¶
func (i *InodeAnonymous) StateSave(stateSinkObject state.Sink)
+checklocksignore
func (*InodeAnonymous) StateTypeName ¶
func (i *InodeAnonymous) StateTypeName() string
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) 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) StateFields ¶
func (a *InodeAttrs) StateFields() []string
func (*InodeAttrs) StateLoad ¶
func (a *InodeAttrs) StateLoad(stateSourceObject state.Source)
+checklocksignore
func (*InodeAttrs) StateSave ¶
func (a *InodeAttrs) StateSave(stateSinkObject state.Sink)
+checklocksignore
func (*InodeAttrs) StateTypeName ¶
func (a *InodeAttrs) StateTypeName() string
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.
func (*InodeDirectoryNoNewChildren) StateFields ¶
func (i *InodeDirectoryNoNewChildren) StateFields() []string
func (*InodeDirectoryNoNewChildren) StateLoad ¶
func (i *InodeDirectoryNoNewChildren) StateLoad(stateSourceObject state.Source)
+checklocksignore
func (*InodeDirectoryNoNewChildren) StateSave ¶
func (i *InodeDirectoryNoNewChildren) StateSave(stateSinkObject state.Sink)
+checklocksignore
func (*InodeDirectoryNoNewChildren) StateTypeName ¶
func (i *InodeDirectoryNoNewChildren) StateTypeName() string
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.
func (*InodeNoStatFS) StateFields ¶
func (i *InodeNoStatFS) StateFields() []string
func (*InodeNoStatFS) StateLoad ¶
func (i *InodeNoStatFS) StateLoad(stateSourceObject state.Source)
+checklocksignore
func (*InodeNoStatFS) StateSave ¶
func (i *InodeNoStatFS) StateSave(stateSinkObject state.Sink)
+checklocksignore
func (*InodeNoStatFS) StateTypeName ¶
func (i *InodeNoStatFS) StateTypeName() string
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) StateFields ¶
func (i *InodeNoopRefCount) StateFields() []string
func (*InodeNoopRefCount) StateLoad ¶
func (i *InodeNoopRefCount) StateLoad(stateSourceObject state.Source)
+checklocksignore
func (*InodeNoopRefCount) StateSave ¶
func (i *InodeNoopRefCount) StateSave(stateSinkObject state.Sink)
+checklocksignore
func (*InodeNoopRefCount) StateTypeName ¶
func (i *InodeNoopRefCount) StateTypeName() string
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
func (*InodeNotAnonymous) StateFields ¶
func (i *InodeNotAnonymous) StateFields() []string
func (*InodeNotAnonymous) StateLoad ¶
func (i *InodeNotAnonymous) StateLoad(stateSourceObject state.Source)
+checklocksignore
func (*InodeNotAnonymous) StateSave ¶
func (i *InodeNotAnonymous) StateSave(stateSinkObject state.Sink)
+checklocksignore
func (*InodeNotAnonymous) StateTypeName ¶
func (i *InodeNotAnonymous) StateTypeName() string
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.
func (*InodeNotDirectory) StateFields ¶
func (i *InodeNotDirectory) StateFields() []string
func (*InodeNotDirectory) StateLoad ¶
func (i *InodeNotDirectory) StateLoad(stateSourceObject state.Source)
+checklocksignore
func (*InodeNotDirectory) StateSave ¶
func (i *InodeNotDirectory) StateSave(stateSinkObject state.Sink)
+checklocksignore
func (*InodeNotDirectory) StateTypeName ¶
func (i *InodeNotDirectory) StateTypeName() string
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
func (InodeNotSymlink) Getlink ¶
func (InodeNotSymlink) Getlink(context.Context, *vfs.Mount) (vfs.VirtualDentry, string, error)
Getlink implements Inode.Getlink.
func (*InodeNotSymlink) StateFields ¶
func (i *InodeNotSymlink) StateFields() []string
func (*InodeNotSymlink) StateLoad ¶
func (i *InodeNotSymlink) StateLoad(stateSourceObject state.Source)
+checklocksignore
func (*InodeNotSymlink) StateSave ¶
func (i *InodeNotSymlink) StateSave(stateSinkObject state.Sink)
+checklocksignore
func (*InodeNotSymlink) StateTypeName ¶
func (i *InodeNotSymlink) StateTypeName() string
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.
func (*InodeSymlink) StateFields ¶
func (i *InodeSymlink) StateFields() []string
func (*InodeSymlink) StateLoad ¶
func (i *InodeSymlink) StateLoad(stateSourceObject state.Source)
+checklocksignore
func (*InodeSymlink) StateSave ¶
func (i *InodeSymlink) StateSave(stateSinkObject state.Sink)
+checklocksignore
func (*InodeSymlink) StateTypeName ¶
func (i *InodeSymlink) StateTypeName() string
type InodeTemporary ¶
type InodeTemporary struct{}
InodeTemporary partially implements Inode.
+stateify savable
func (*InodeTemporary) StateFields ¶
func (i *InodeTemporary) StateFields() []string
func (*InodeTemporary) StateLoad ¶
func (i *InodeTemporary) StateLoad(stateSourceObject state.Source)
+checklocksignore
func (*InodeTemporary) StateSave ¶
func (i *InodeTemporary) StateSave(stateSinkObject state.Sink)
+checklocksignore
func (*InodeTemporary) StateTypeName ¶
func (i *InodeTemporary) StateTypeName() string
type InodeWatches ¶
type InodeWatches struct {
// contains filtered or unexported fields
}
InodeWatches partially implements Inode.
+stateify savable
func (*InodeWatches) StateFields ¶
func (i *InodeWatches) StateFields() []string
func (*InodeWatches) StateLoad ¶
func (i *InodeWatches) StateLoad(stateSourceObject state.Source)
+checklocksignore
func (*InodeWatches) StateSave ¶
func (i *InodeWatches) StateSave(stateSinkObject state.Sink)
+checklocksignore
func (*InodeWatches) StateTypeName ¶
func (i *InodeWatches) StateTypeName() string
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 childrens 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.
func (*OrderedChildren) StateFields ¶
func (o *OrderedChildren) StateFields() []string
func (*OrderedChildren) StateLoad ¶
func (o *OrderedChildren) StateLoad(stateSourceObject state.Source)
+checklocksignore
func (*OrderedChildren) StateSave ¶
func (o *OrderedChildren) StateSave(stateSinkObject state.Sink)
+checklocksignore
func (*OrderedChildren) StateTypeName ¶
func (o *OrderedChildren) StateTypeName() string
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
func (*OrderedChildrenOptions) StateFields ¶
func (o *OrderedChildrenOptions) StateFields() []string
func (*OrderedChildrenOptions) StateLoad ¶
func (o *OrderedChildrenOptions) StateLoad(stateSourceObject state.Source)
+checklocksignore
func (*OrderedChildrenOptions) StateSave ¶
func (o *OrderedChildrenOptions) StateSave(stateSinkObject state.Sink)
+checklocksignore
func (*OrderedChildrenOptions) StateTypeName ¶
func (o *OrderedChildrenOptions) StateTypeName() string
type SeekEndConfig ¶
type SeekEndConfig int
SeekEndConfig describes the SEEK_END behaviour for FDs.
+stateify savable
func (*SeekEndConfig) StateFields ¶
func (s *SeekEndConfig) StateFields() []string
func (*SeekEndConfig) StateTypeName ¶
func (s *SeekEndConfig) StateTypeName() string
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
var StaticDirectoryobj *StaticDirectory
obj is used to customize logging. Note that we use a pointer to T so that we do not copy the entire object when passed as a format parameter.
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.
func (*StaticDirectory) StateFields ¶
func (s *StaticDirectory) StateFields() []string
func (*StaticDirectory) StateLoad ¶
func (s *StaticDirectory) StateLoad(stateSourceObject state.Source)
+checklocksignore
func (*StaticDirectory) StateSave ¶
func (s *StaticDirectory) StateSave(stateSinkObject state.Sink)
+checklocksignore
func (*StaticDirectory) StateTypeName ¶
func (s *StaticDirectory) StateTypeName() string
type StaticDirectoryRefs ¶
type StaticDirectoryRefs struct {
// contains filtered or unexported fields
}
Refs implements refs.RefCounter. It keeps a reference count using atomic operations and calls the destructor when the count reaches zero.
NOTE: Do not introduce additional fields to the Refs struct. It is used by many filesystem objects, and we want to keep it as small as possible (i.e., the same size as using an int64 directly) to avoid taking up extra cache space. In general, this template should not be extended at the cost of performance. If it does not offer enough flexibility for a particular object (example: b/187877947), we should implement the RefCounter/CheckedObject interfaces manually.
+stateify savable
func (*StaticDirectoryRefs) DecRef ¶
func (r *StaticDirectoryRefs) DecRef(destroy func())
DecRef implements refs.RefCounter.DecRef.
Note that speculative references are counted here. Since they were added prior to real references reaching zero, they will successfully convert to real references. In other words, we see speculative references only in the following case:
A: TryIncRef [speculative increase => sees non-negative references] B: DecRef [real decrease] A: TryIncRef [transform speculative to real]
func (*StaticDirectoryRefs) IncRef ¶
func (r *StaticDirectoryRefs) IncRef()
IncRef implements refs.RefCounter.IncRef.
func (*StaticDirectoryRefs) InitRefs ¶
func (r *StaticDirectoryRefs) InitRefs()
InitRefs initializes r with one reference and, if enabled, activates leak checking.
func (*StaticDirectoryRefs) LeakMessage ¶
func (r *StaticDirectoryRefs) LeakMessage() string
LeakMessage implements refs.CheckedObject.LeakMessage.
func (*StaticDirectoryRefs) LogRefs ¶
func (r *StaticDirectoryRefs) LogRefs() bool
LogRefs implements refs.CheckedObject.LogRefs.
func (*StaticDirectoryRefs) ReadRefs ¶
func (r *StaticDirectoryRefs) ReadRefs() int64
ReadRefs returns the current number of references. The returned count is inherently racy and is unsafe to use without external synchronization.
func (*StaticDirectoryRefs) RefType ¶
func (r *StaticDirectoryRefs) RefType() string
RefType implements refs.CheckedObject.RefType.
func (*StaticDirectoryRefs) StateFields ¶
func (r *StaticDirectoryRefs) StateFields() []string
func (*StaticDirectoryRefs) StateLoad ¶
func (r *StaticDirectoryRefs) StateLoad(stateSourceObject state.Source)
+checklocksignore
func (*StaticDirectoryRefs) StateSave ¶
func (r *StaticDirectoryRefs) StateSave(stateSinkObject state.Sink)
+checklocksignore
func (*StaticDirectoryRefs) StateTypeName ¶
func (r *StaticDirectoryRefs) StateTypeName() string
func (*StaticDirectoryRefs) TryIncRef ¶
func (r *StaticDirectoryRefs) TryIncRef() bool
TryIncRef implements refs.TryRefCounter.TryIncRef.
To do this safely without a loop, a speculative reference is first acquired on the object. This allows multiple concurrent TryIncRef calls to distinguish other TryIncRef calls from genuine references held.
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.
func (*StaticSymlink) StateFields ¶
func (s *StaticSymlink) StateFields() []string
func (*StaticSymlink) StateLoad ¶
func (s *StaticSymlink) StateLoad(stateSourceObject state.Source)
+checklocksignore
func (*StaticSymlink) StateSave ¶
func (s *StaticSymlink) StateSave(stateSinkObject state.Sink)
+checklocksignore
func (*StaticSymlink) StateTypeName ¶
func (s *StaticSymlink) StateTypeName() string
Source Files ¶
- deferred_dec_refs_mutex.go
- dentry_list.go
- dynamic_bytes_file.go
- fd_impl_util.go
- filesystem.go
- filesystem_mutex.go
- fstree.go
- inode_impl_util.go
- kernfs.go
- kernfs_state_autogen.go
- mmap_util.go
- save_restore.go
- slot_list.go
- static_directory_refs.go
- symlink.go
- synthetic_directory.go
- synthetic_directory_refs.go