kernfs

package
v0.0.0-...-989fa2c Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2023 License: Apache-2.0, MIT Imports: 20 Imported by: 0

Documentation

Overview

Package kernfs provides the tools to implement inode-based filesystems. Kernfs has two main features:

  1. 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.

  2. 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

View Source
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.

View Source
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) DecRef

func (d *Dentry) DecRef(ctx context.Context)

DecRef implements vfs.DentryImpl.DecRef.

func (*Dentry) FSLocalPath

func (d *Dentry) FSLocalPath() string

FSLocalPath returns an absolute path to d, relative to the root of its filesystem.

func (*Dentry) IncRef

func (d *Dentry) IncRef()

IncRef implements vfs.DentryImpl.IncRef.

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) Inode

func (d *Dentry) Inode() Inode

Inode returns the dentry's inode.

func (*Dentry) InotifyWithParent

func (d *Dentry) InotifyWithParent(ctx context.Context, events, cookie uint32, et vfs.EventType)

InotifyWithParent implements vfs.DentryImpl.InotifyWithParent.

func (*Dentry) LeakMessage

func (d *Dentry) LeakMessage() string

LeakMessage implements refs.CheckedObject.LeakMessage.

func (*Dentry) LogRefs

func (d *Dentry) LogRefs() bool

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

func (d *Dentry) OnZeroWatches(context.Context)

OnZeroWatches implements vfs.Dentry.OnZeroWatches.

func (*Dentry) Parent

func (d *Dentry) Parent() *Dentry

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) RefType

func (d *Dentry) RefType() string

RefType implements refs.CheckedObject.Type.

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 (d *Dentry) StateFields() []string

func (*Dentry) StateLoad

func (d *Dentry) StateLoad(stateSourceObject state.Source)

+checklocksignore

func (*Dentry) StateSave

func (d *Dentry) StateSave(stateSinkObject state.Sink)

+checklocksignore

func (*Dentry) StateTypeName

func (d *Dentry) StateTypeName() string

func (*Dentry) TryIncRef

func (d *Dentry) TryIncRef() bool

TryIncRef implements vfs.DentryImpl.TryIncRef.

func (*Dentry) VFSDentry

func (d *Dentry) VFSDentry() *vfs.Dentry

VFSDentry returns the generic vfs dentry for this kernfs dentry.

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.

func (*Dentry) Watches

func (d *Dentry) Watches() *vfs.Watches

Watches implements vfs.DentryImpl.Watches.

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

Read implements vfs.FileDescriptionImpl.Read.

func (*DynamicBytesFD) Release

func (fd *DynamicBytesFD) Release(context.Context)

Release implements vfs.FileDescriptionImpl.Release.

func (*DynamicBytesFD) Seek

func (fd *DynamicBytesFD) Seek(ctx context.Context, offset int64, whence int32) (int64, error)

Seek implements vfs.FileDescriptionImpl.Seek.

func (*DynamicBytesFD) SetStat

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

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

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

Open implements Inode.Open.

func (*DynamicBytesFile) SetStat

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

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

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

func (fd *GenericDirectoryFD) ConfigureMMap(ctx context.Context, opts *memmap.MMapOpts) error

ConfigureMMap implements vfs.FileDescriptionImpl.ConfigureMMap.

func (*GenericDirectoryFD) Init

Init initializes a GenericDirectoryFD. Use it when overriding GenericDirectoryFD. Caller must call fd.VFSFileDescription.Init() with the correct implementation.

func (*GenericDirectoryFD) IterDirents

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

Read implmenets vfs.FileDescriptionImpl.Read.

func (*GenericDirectoryFD) Release

func (fd *GenericDirectoryFD) Release(context.Context)

Release implements vfs.FileDescriptionImpl.Release.

func (*GenericDirectoryFD) Seek

func (fd *GenericDirectoryFD) Seek(ctx context.Context, offset int64, whence int32) (int64, error)

Seek implements vfs.FileDescriptionImpl.Seek.

func (*GenericDirectoryFD) SetStat

func (fd *GenericDirectoryFD) SetStat(ctx context.Context, opts vfs.SetStatOptions) error

SetStat implements vfs.FileDescriptionImpl.SetStat.

func (*GenericDirectoryFD) Stat

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

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(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

func (*InodeAlwaysValid) Valid

Valid implements Inode.Valid.

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 (a *InodeAttrs) DecLinks()

DecLinks implements Inode.DecLinks.

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) GID

func (a *InodeAttrs) GID() auth.KGID

GID implements Inode.GID.

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) Ino

func (a *InodeAttrs) Ino() uint64

Ino returns the inode id.

func (a *InodeAttrs) Links() uint32

Links returns the link count.

func (*InodeAttrs) Mode

func (a *InodeAttrs) Mode() linux.FileMode

Mode implements Inode.Mode.

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

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.

func (*InodeAttrs) UID

func (a *InodeAttrs) UID() auth.KUID

UID implements Inode.UID.

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

NewDir implements Inode.NewDir.

func (InodeDirectoryNoNewChildren) NewFile

NewFile implements Inode.NewFile.

NewLink implements Inode.NewLink.

func (InodeDirectoryNoNewChildren) NewNode

NewNode implements Inode.NewNode.

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

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

DecRef implements Inode.DecRef.

func (InodeNoopRefCount) IncRef

func (InodeNoopRefCount) IncRef()

IncRef implements Inode.IncRef.

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) Lookup

func (InodeNotDirectory) Lookup(ctx context.Context, name string) (Inode, error)

Lookup implements Inode.Lookup.

func (InodeNotDirectory) NewDir

NewDir implements Inode.NewDir.

func (InodeNotDirectory) NewFile

NewFile implements Inode.NewFile.

NewLink implements Inode.NewLinkink.

func (InodeNotDirectory) NewNode

NewNode implements Inode.NewNode.

NewSymlink implements Inode.NewSymlink.

func (InodeNotDirectory) Rename

Rename implements Inode.Rename.

func (InodeNotDirectory) RmDir

RmDir implements Inode.RmDir.

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

Unlink implements Inode.Unlink.

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

Getlink implements Inode.Getlink.

Readlink implements Inode.Readlink.

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 struct {
	InodeNotDirectory
}

InodeSymlink partially implements Inode interface for symlinks.

+stateify savable

func (InodeSymlink) Open

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) Keep

func (*InodeTemporary) Keep() bool

Keep implements Inode.Keep.

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

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) Lookup

func (o *OrderedChildren) Lookup(ctx context.Context, name string) (Inode, error)

Lookup implements Inode.Lookup.

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) RmDir

func (o *OrderedChildren) RmDir(ctx context.Context, name string, child Inode) error

RmDir implements Inode.RmDir.

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
func (o *OrderedChildren) Unlink(ctx context.Context, name string, child Inode) error

Unlink implements Inode.Unlink.

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

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

Open implements Inode.Open.

func (*StaticDirectory) SetStat

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 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

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 (s *StaticSymlink) Readlink(_ context.Context, _ *vfs.Mount) (string, error)

Readlink implements Inode.Readlink.

func (*StaticSymlink) SetStat

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

Jump to

Keyboard shortcuts

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