Documentation ¶
Overview ¶
Package fsutil provides utilities for implementing fs.InodeOperations and fs.FileOperations:
- For embeddable utilities, see inode.go and file.go.
- For fs.Inodes that require a page cache to be memory mapped, see inode_cache.go.
- For anon fs.Inodes, see anon.go.
Index ¶
- func GenericConfigureMMap(file *fs.File, m memmap.Mappable, opts *memmap.MMapOpts) error
- func SeekWithDirCursor(ctx context.Context, file *fs.File, whence fs.SeekWhence, offset int64, ...) (int64, error)
- func SyncDirty(ctx context.Context, mr memmap.MappableRange, cache *FileRangeSet, ...) error
- func SyncDirtyAll(ctx context.Context, cache *FileRangeSet, dirty *DirtySet, max uint64, ...) error
- type CachedFileObject
- type CachingInodeOperations
- func (c *CachingInodeOperations) AddMapping(ctx context.Context, ms memmap.MappingSpace, ar hostarch.AddrRange, ...) error
- func (c *CachingInodeOperations) Allocate(ctx context.Context, offset, length int64) error
- func (c *CachingInodeOperations) CopyMapping(ctx context.Context, ms memmap.MappingSpace, srcAR, dstAR hostarch.AddrRange, ...) error
- func (c *CachingInodeOperations) DecLinks(ctx context.Context)
- func (c *CachingInodeOperations) DecRef(fr memmap.FileRange)
- func (c *CachingInodeOperations) Evict(ctx context.Context, er pgalloc.EvictableRange)
- func (c *CachingInodeOperations) FD() int
- func (c *CachingInodeOperations) IncLinks(ctx context.Context)
- func (c *CachingInodeOperations) IncRef(fr memmap.FileRange)
- func (c *CachingInodeOperations) InvalidateUnsavable(ctx context.Context) error
- func (c *CachingInodeOperations) MapInternal(fr memmap.FileRange, at hostarch.AccessType) (safemem.BlockSeq, error)
- func (c *CachingInodeOperations) NotifyChangeFD() error
- func (c *CachingInodeOperations) Read(ctx context.Context, file *fs.File, dst usermem.IOSequence, offset int64) (int64, error)
- func (c *CachingInodeOperations) Release()
- func (c *CachingInodeOperations) RemoveMapping(ctx context.Context, ms memmap.MappingSpace, ar hostarch.AddrRange, ...)
- func (c *CachingInodeOperations) SetOwner(ctx context.Context, inode *fs.Inode, owner fs.FileOwner) error
- func (c *CachingInodeOperations) SetPermissions(ctx context.Context, inode *fs.Inode, perms fs.FilePermissions) bool
- func (c *CachingInodeOperations) SetTimestamps(ctx context.Context, inode *fs.Inode, ts fs.TimeSpec) error
- func (c *CachingInodeOperations) TouchAccessTime(ctx context.Context, inode *fs.Inode)
- func (c *CachingInodeOperations) TouchModificationAndStatusChangeTime(ctx context.Context)
- func (c *CachingInodeOperations) TouchStatusChangeTime(ctx context.Context)
- func (c *CachingInodeOperations) Translate(ctx context.Context, required, optional memmap.MappableRange, ...) ([]memmap.Translation, error)
- func (c *CachingInodeOperations) Truncate(ctx context.Context, inode *fs.Inode, size int64) error
- func (c *CachingInodeOperations) UnstableAttr(ctx context.Context, inode *fs.Inode) (fs.UnstableAttr, error)
- func (c *CachingInodeOperations) UpdateUnstable(attr fs.UnstableAttr)
- func (c *CachingInodeOperations) Write(ctx context.Context, src usermem.IOSequence, offset int64) (int64, error)
- func (c *CachingInodeOperations) WriteDirtyPagesAndAttrs(ctx context.Context, inode *fs.Inode) error
- func (c *CachingInodeOperations) WriteOut(ctx context.Context, inode *fs.Inode) error
- type CachingInodeOperationsOptions
- type DirFileOperations
- type DirtyInfo
- type FileGenericSeek
- type FileNoFsync
- type FileNoIoctl
- type FileNoMMap
- type FileNoRead
- type FileNoSeek
- type FileNoSplice
- type FileNoWrite
- type FileNoopFlush
- type FileNoopFsync
- type FileNoopRead
- type FileNoopRelease
- type FileNoopWrite
- type FileNotDirReaddir
- type FilePipeSeek
- type FileRangeSetFunctions
- func (FileRangeSetFunctions) ClearValue(_ *uint64)
- func (FileRangeSetFunctions) MaxKey() uint64
- func (FileRangeSetFunctions) Merge(mr1 memmap.MappableRange, frstart1 uint64, _ memmap.MappableRange, ...) (uint64, bool)
- func (FileRangeSetFunctions) MinKey() uint64
- func (FileRangeSetFunctions) Split(mr memmap.MappableRange, frstart uint64, split uint64) (uint64, uint64)
- type FileStaticContentReader
- type FileUseInodeUnstableAttr
- type FileZeroSeek
- type FrameRefSetFunctions
- func (FrameRefSetFunctions) ClearValue(val *uint64)
- func (FrameRefSetFunctions) MaxKey() uint64
- func (FrameRefSetFunctions) Merge(_ memmap.FileRange, val1 uint64, _ memmap.FileRange, val2 uint64) (uint64, bool)
- func (FrameRefSetFunctions) MinKey() uint64
- func (FrameRefSetFunctions) Split(_ memmap.FileRange, val uint64, _ uint64) (uint64, uint64)
- type HostFileMapper
- func (f *HostFileMapper) DecRefOn(mr memmap.MappableRange)
- func (f *HostFileMapper) IncRefOn(mr memmap.MappableRange)
- func (f *HostFileMapper) Init()
- func (f *HostFileMapper) IsInited() bool
- func (f *HostFileMapper) MapInternal(fr memmap.FileRange, fd int, write bool) (safemem.BlockSeq, error)
- func (f *HostFileMapper) RegenerateMappings(fd int) error
- func (f *HostFileMapper) UnmapAll()
- type HostMappable
- func (h *HostMappable) AddMapping(ctx context.Context, ms memmap.MappingSpace, ar hostarch.AddrRange, ...) error
- func (h *HostMappable) Allocate(ctx context.Context, offset int64, length int64) error
- func (h *HostMappable) CopyMapping(ctx context.Context, ms memmap.MappingSpace, srcAR, dstAR hostarch.AddrRange, ...) error
- func (h *HostMappable) DecRef(fr memmap.FileRange)
- func (h *HostMappable) FD() int
- func (h *HostMappable) IncRef(fr memmap.FileRange)
- func (h *HostMappable) InvalidateUnsavable(_ context.Context) error
- func (h *HostMappable) MapInternal(fr memmap.FileRange, at hostarch.AccessType) (safemem.BlockSeq, error)
- func (h *HostMappable) NotifyChangeFD() error
- func (h *HostMappable) RemoveMapping(ctx context.Context, ms memmap.MappingSpace, ar hostarch.AddrRange, ...)
- func (h *HostMappable) Translate(ctx context.Context, required, optional memmap.MappableRange, ...) ([]memmap.Translation, error)
- func (h *HostMappable) Truncate(ctx context.Context, newSize int64, uattr fs.UnstableAttr) error
- func (h *HostMappable) Write(ctx context.Context, src usermem.IOSequence, offset int64, ...) (int64, error)
- type InodeDenyWriteChecker
- type InodeGenericChecker
- type InodeIsDirAllocate
- type InodeIsDirTruncate
- type InodeNoExtendedAttributes
- func (InodeNoExtendedAttributes) GetXattr(context.Context, *fs.Inode, string, uint64) (string, error)
- func (InodeNoExtendedAttributes) ListXattr(context.Context, *fs.Inode, uint64) (map[string]struct{}, error)
- func (InodeNoExtendedAttributes) RemoveXattr(context.Context, *fs.Inode, string) error
- func (InodeNoExtendedAttributes) SetXattr(context.Context, *fs.Inode, string, string, uint32) error
- type InodeNoStatFS
- type InodeNoopAllocate
- type InodeNoopRelease
- type InodeNoopTruncate
- type InodeNoopWriteOut
- type InodeNotAllocatable
- type InodeNotDirectory
- func (InodeNotDirectory) Bind(context.Context, *fs.Inode, string, transport.BoundEndpoint, ...) (*fs.Dirent, error)
- func (InodeNotDirectory) Create(context.Context, *fs.Inode, string, fs.FileFlags, fs.FilePermissions) (*fs.File, error)
- func (InodeNotDirectory) CreateDirectory(context.Context, *fs.Inode, string, fs.FilePermissions) error
- func (InodeNotDirectory) CreateFifo(context.Context, *fs.Inode, string, fs.FilePermissions) error
- func (InodeNotDirectory) CreateHardLink(context.Context, *fs.Inode, *fs.Inode, string) error
- func (InodeNotDirectory) CreateLink(context.Context, *fs.Inode, string, string) error
- func (InodeNotDirectory) Lookup(context.Context, *fs.Inode, string) (*fs.Dirent, error)
- func (InodeNotDirectory) Remove(context.Context, *fs.Inode, string) error
- func (InodeNotDirectory) RemoveDirectory(context.Context, *fs.Inode, string) error
- func (InodeNotDirectory) Rename(context.Context, *fs.Inode, *fs.Inode, string, *fs.Inode, string, bool) error
- type InodeNotMappable
- type InodeNotOpenable
- type InodeNotRenameable
- type InodeNotSocket
- type InodeNotSymlink
- type InodeNotTruncatable
- type InodeNotVirtual
- type InodeSimpleAttributes
- func (i *InodeSimpleAttributes) AddLink()
- func (i *InodeSimpleAttributes) DropLink()
- func (i *InodeSimpleAttributes) NotifyAccess(ctx context.Context)
- func (i *InodeSimpleAttributes) NotifyModification(ctx context.Context)
- func (i *InodeSimpleAttributes) NotifyModificationAndStatusChange(ctx context.Context)
- func (i *InodeSimpleAttributes) NotifyStatusChange(ctx context.Context)
- func (i *InodeSimpleAttributes) SetOwner(ctx context.Context, _ *fs.Inode, owner fs.FileOwner) error
- func (i *InodeSimpleAttributes) SetPermissions(ctx context.Context, _ *fs.Inode, p fs.FilePermissions) bool
- func (i *InodeSimpleAttributes) SetTimestamps(ctx context.Context, _ *fs.Inode, ts fs.TimeSpec) error
- func (i *InodeSimpleAttributes) StatFS(context.Context) (fs.Info, error)
- func (i *InodeSimpleAttributes) UnstableAttr(ctx context.Context, _ *fs.Inode) (fs.UnstableAttr, error)
- type InodeSimpleExtendedAttributes
- func (i *InodeSimpleExtendedAttributes) GetXattr(_ context.Context, _ *fs.Inode, name string, _ uint64) (string, error)
- func (i *InodeSimpleExtendedAttributes) ListXattr(context.Context, *fs.Inode, uint64) (map[string]struct{}, error)
- func (i *InodeSimpleExtendedAttributes) RemoveXattr(_ context.Context, _ *fs.Inode, name string) error
- func (i *InodeSimpleExtendedAttributes) SetXattr(_ context.Context, _ *fs.Inode, name, value string, flags uint32) error
- type InodeStaticFileGetter
- type InodeVirtual
- type NoReadWriteFile
- type NoReadWriteFileInode
- type SimpleFileInode
- type StaticDirFileOperations
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GenericConfigureMMap ¶
GenericConfigureMMap implements fs.FileOperations.ConfigureMMap for most filesystems that support memory mapping.
func SeekWithDirCursor ¶
func SeekWithDirCursor(ctx context.Context, file *fs.File, whence fs.SeekWhence, offset int64, dirCursor *string) (int64, error)
SeekWithDirCursor is used to implement fs.FileOperations.Seek. If dirCursor is not nil and the seek was on a directory, the cursor will be updated.
Currently only seeking to 0 on a directory is supported.
FIXME(b/33075855): Lift directory seeking limitations.
func SyncDirty ¶
func SyncDirty(ctx context.Context, mr memmap.MappableRange, cache *FileRangeSet, dirty *DirtySet, max uint64, mem memmap.File, writeAt func(ctx context.Context, srcs safemem.BlockSeq, offset uint64) (uint64, error)) error
SyncDirty passes pages in the range mr that are stored in cache and identified as dirty to writeAt, updating dirty to reflect successful writes. If writeAt returns a successful partial write, SyncDirty will call it repeatedly until all bytes have been written. max is the true size of the cached object; offsets beyond max will not be passed to writeAt, even if they are marked dirty.
func SyncDirtyAll ¶
func SyncDirtyAll(ctx context.Context, cache *FileRangeSet, dirty *DirtySet, max uint64, mem memmap.File, writeAt func(ctx context.Context, srcs safemem.BlockSeq, offset uint64) (uint64, error)) error
SyncDirtyAll passes all pages stored in cache identified as dirty to writeAt, updating dirty to reflect successful writes. If writeAt returns a successful partial write, SyncDirtyAll will call it repeatedly until all bytes have been written. max is the true size of the cached object; offsets beyond max will not be passed to writeAt, even if they are marked dirty.
Types ¶
type CachedFileObject ¶
type CachedFileObject interface { // ReadToBlocksAt reads up to dsts.NumBytes() bytes from the file to dsts, // starting at offset, and returns the number of bytes read. ReadToBlocksAt // may return a partial read without an error. ReadToBlocksAt(ctx context.Context, dsts safemem.BlockSeq, offset uint64) (uint64, error) // WriteFromBlocksAt writes up to srcs.NumBytes() bytes from srcs to the // file, starting at offset, and returns the number of bytes written. // WriteFromBlocksAt may return a partial write without an error. WriteFromBlocksAt(ctx context.Context, srcs safemem.BlockSeq, offset uint64) (uint64, error) // SetMaskedAttributes sets the attributes in attr that are true in // mask on the backing file. If the mask contains only ATime or MTime // and the CachedFileObject has an FD to the file, then this operation // is a noop unless forceSetTimestamps is true. This avoids an extra // RPC to the gofer in the open-read/write-close case, when the // timestamps on the file will be updated by the host kernel for us. // // SetMaskedAttributes may be called at any point, regardless of whether // the file was opened. SetMaskedAttributes(ctx context.Context, mask fs.AttrMask, attr fs.UnstableAttr, forceSetTimestamps bool) error // Allocate allows the caller to reserve disk space for the inode. // It's equivalent to fallocate(2) with 'mode=0'. Allocate(ctx context.Context, offset int64, length int64) error // Sync instructs the remote filesystem to sync the file to stable storage. Sync(ctx context.Context) error // FD returns a host file descriptor. If it is possible for // CachingInodeOperations.AddMapping to have ever been called with writable // = true, the FD must have been opened O_RDWR; otherwise, it may have been // opened O_RDONLY or O_RDWR. (mmap unconditionally requires that mapped // files are readable.) If no host file descriptor is available, FD returns // a negative number. // // For any given CachedFileObject, if FD() ever succeeds (returns a // non-negative number), it must always succeed. // // FD is called iff the file has been memory mapped. This implies that // the file was opened (see fs.InodeOperations.GetFile). FD() int }
CachedFileObject is a file that may require caching.
type CachingInodeOperations ¶
type CachingInodeOperations struct {
// contains filtered or unexported fields
}
CachingInodeOperations caches the metadata and content of a CachedFileObject. It implements a subset of InodeOperations. As a utility it can be used to implement the full set of InodeOperations. Generally it should not be embedded to avoid unexpected inherited behavior.
CachingInodeOperations implements Mappable for the CachedFileObject:
- If CachedFileObject.FD returns a value >= 0 then the file descriptor will be memory mapped on the host.
- Otherwise, the contents of CachedFileObject are buffered into memory managed by the CachingInodeOperations.
Implementations of FileOperations for a CachedFileObject must read and write through CachingInodeOperations using Read and Write respectively.
Implementations of InodeOperations.WriteOut must call Sync to write out in-memory modifications of data and metadata to the CachedFileObject.
+stateify savable
func NewCachingInodeOperations ¶
func NewCachingInodeOperations(ctx context.Context, backingFile CachedFileObject, uattr fs.UnstableAttr, opts CachingInodeOperationsOptions) *CachingInodeOperations
NewCachingInodeOperations returns a new CachingInodeOperations backed by a CachedFileObject and its initial unstable attributes.
func (*CachingInodeOperations) AddMapping ¶
func (c *CachingInodeOperations) AddMapping(ctx context.Context, ms memmap.MappingSpace, ar hostarch.AddrRange, offset uint64, writable bool) error
AddMapping implements memmap.Mappable.AddMapping.
func (*CachingInodeOperations) Allocate ¶
func (c *CachingInodeOperations) Allocate(ctx context.Context, offset, length int64) error
Allocate implements fs.InodeOperations.Allocate.
func (*CachingInodeOperations) CopyMapping ¶
func (c *CachingInodeOperations) CopyMapping(ctx context.Context, ms memmap.MappingSpace, srcAR, dstAR hostarch.AddrRange, offset uint64, writable bool) error
CopyMapping implements memmap.Mappable.CopyMapping.
func (*CachingInodeOperations) DecLinks ¶
func (c *CachingInodeOperations) DecLinks(ctx context.Context)
DecLinks decreases the link count and updates cached modification time.
func (*CachingInodeOperations) DecRef ¶
func (c *CachingInodeOperations) DecRef(fr memmap.FileRange)
DecRef implements memmap.File.DecRef. This is used when we directly map an underlying host fd and CachingInodeOperations is used as the memmap.File during translation.
func (*CachingInodeOperations) Evict ¶
func (c *CachingInodeOperations) Evict(ctx context.Context, er pgalloc.EvictableRange)
Evict implements pgalloc.EvictableMemoryUser.Evict.
func (*CachingInodeOperations) FD ¶
func (c *CachingInodeOperations) FD() int
FD implements memmap.File.FD. This is used when we directly map an underlying host fd and CachingInodeOperations is used as the memmap.File during translation.
func (*CachingInodeOperations) IncLinks ¶
func (c *CachingInodeOperations) IncLinks(ctx context.Context)
IncLinks increases the link count and updates cached modification time.
func (*CachingInodeOperations) IncRef ¶
func (c *CachingInodeOperations) IncRef(fr memmap.FileRange)
IncRef implements memmap.File.IncRef. This is used when we directly map an underlying host fd and CachingInodeOperations is used as the memmap.File during translation.
func (*CachingInodeOperations) InvalidateUnsavable ¶
func (c *CachingInodeOperations) InvalidateUnsavable(ctx context.Context) error
InvalidateUnsavable implements memmap.Mappable.InvalidateUnsavable.
func (*CachingInodeOperations) MapInternal ¶
func (c *CachingInodeOperations) MapInternal(fr memmap.FileRange, at hostarch.AccessType) (safemem.BlockSeq, error)
MapInternal implements memmap.File.MapInternal. This is used when we directly map an underlying host fd and CachingInodeOperations is used as the memmap.File during translation.
func (*CachingInodeOperations) NotifyChangeFD ¶
func (c *CachingInodeOperations) NotifyChangeFD() error
NotifyChangeFD must be called after the file description represented by CachedFileObject.FD() changes.
func (*CachingInodeOperations) Read ¶
func (c *CachingInodeOperations) Read(ctx context.Context, file *fs.File, dst usermem.IOSequence, offset int64) (int64, error)
Read reads from frames and otherwise directly from the backing file into dst starting at offset until dst is full, EOF is reached, or an error is encountered.
Read may partially fill dst and return a nil error.
func (*CachingInodeOperations) Release ¶
func (c *CachingInodeOperations) Release()
Release implements fs.InodeOperations.Release.
func (*CachingInodeOperations) RemoveMapping ¶
func (c *CachingInodeOperations) RemoveMapping(ctx context.Context, ms memmap.MappingSpace, ar hostarch.AddrRange, offset uint64, writable bool)
RemoveMapping implements memmap.Mappable.RemoveMapping.
func (*CachingInodeOperations) SetOwner ¶
func (c *CachingInodeOperations) SetOwner(ctx context.Context, inode *fs.Inode, owner fs.FileOwner) error
SetOwner implements fs.InodeOperations.SetOwner.
func (*CachingInodeOperations) SetPermissions ¶
func (c *CachingInodeOperations) SetPermissions(ctx context.Context, inode *fs.Inode, perms fs.FilePermissions) bool
SetPermissions implements fs.InodeOperations.SetPermissions.
func (*CachingInodeOperations) SetTimestamps ¶
func (c *CachingInodeOperations) SetTimestamps(ctx context.Context, inode *fs.Inode, ts fs.TimeSpec) error
SetTimestamps implements fs.InodeOperations.SetTimestamps.
func (*CachingInodeOperations) TouchAccessTime ¶
func (c *CachingInodeOperations) TouchAccessTime(ctx context.Context, inode *fs.Inode)
TouchAccessTime updates the cached access time in-place to the current time. It does not update status change time in-place. See mm/filemap.c:do_generic_file_read -> include/linux/h:file_accessed.
func (*CachingInodeOperations) TouchModificationAndStatusChangeTime ¶
func (c *CachingInodeOperations) TouchModificationAndStatusChangeTime(ctx context.Context)
TouchModificationAndStatusChangeTime updates the cached modification and status change times in-place to the current time.
func (*CachingInodeOperations) TouchStatusChangeTime ¶
func (c *CachingInodeOperations) TouchStatusChangeTime(ctx context.Context)
TouchStatusChangeTime updates the cached status change time in-place to the current time.
func (*CachingInodeOperations) Translate ¶
func (c *CachingInodeOperations) Translate(ctx context.Context, required, optional memmap.MappableRange, at hostarch.AccessType) ([]memmap.Translation, error)
Translate implements memmap.Mappable.Translate.
func (*CachingInodeOperations) UnstableAttr ¶
func (c *CachingInodeOperations) UnstableAttr(ctx context.Context, inode *fs.Inode) (fs.UnstableAttr, error)
UnstableAttr implements fs.InodeOperations.UnstableAttr.
func (*CachingInodeOperations) UpdateUnstable ¶
func (c *CachingInodeOperations) UpdateUnstable(attr fs.UnstableAttr)
UpdateUnstable updates the cached unstable attributes. Only non-dirty attributes are updated.
func (*CachingInodeOperations) Write ¶
func (c *CachingInodeOperations) Write(ctx context.Context, src usermem.IOSequence, offset int64) (int64, error)
Write writes to frames and otherwise directly to the backing file from src starting at offset and until src is empty or an error is encountered.
If Write partially fills src, a non-nil error is returned.
func (*CachingInodeOperations) WriteDirtyPagesAndAttrs ¶
func (c *CachingInodeOperations) WriteDirtyPagesAndAttrs(ctx context.Context, inode *fs.Inode) error
WriteDirtyPagesAndAttrs will write the dirty pages and attributes to the gofer without calling Fsync on the remote file.
type CachingInodeOperationsOptions ¶
type CachingInodeOperationsOptions struct { // If ForcePageCache is true, use the sentry page cache even if a host file // descriptor is available. ForcePageCache bool // If LimitHostFDTranslation is true, apply maxFillRange() constraints to // host file descriptor mappings returned by // CachingInodeOperations.Translate(). LimitHostFDTranslation bool }
CachingInodeOperationsOptions configures a CachingInodeOperations.
+stateify savable
type DirFileOperations ¶
type DirFileOperations struct { waiter.AlwaysReady FileGenericSeek FileNoIoctl FileNoMMap FileNoopFlush FileNoopFsync FileNoopRelease FileNoSplice }
DirFileOperations implements most of fs.FileOperations for directories, except for Readdir and UnstableAttr which the embedding type must implement.
type DirtyInfo ¶
type DirtyInfo struct { // Keep is true if the represented offset is concurrently writable, such // that writing the data for that offset back to the source does not // guarantee that the offset is clean (since it may be concurrently // rewritten after the writeback). Keep bool }
DirtyInfo is the value type of DirtySet, and represents information about a Mappable offset that is dirty (the cached data for that offset is newer than its source).
+stateify savable
type FileGenericSeek ¶
type FileGenericSeek struct{}
FileGenericSeek implements fs.FileOperations.Seek for files that use a generic seek implementation.
type FileNoFsync ¶
type FileNoFsync struct{}
FileNoFsync implements fs.FileOperations.Fsync for files that don't support syncing.
type FileNoIoctl ¶
type FileNoIoctl struct{}
FileNoIoctl implements fs.FileOperations.Ioctl for files that don't implement the ioctl syscall.
type FileNoMMap ¶
type FileNoMMap struct{}
FileNoMMap implements fs.FileOperations.Mappable for files that cannot be memory mapped.
func (FileNoMMap) ConfigureMMap ¶
ConfigureMMap implements fs.FileOperations.ConfigureMMap.
type FileNoRead ¶
type FileNoRead struct{}
FileNoRead implements fs.FileOperations.Read to return EINVAL.
type FileNoSeek ¶
type FileNoSeek struct{}
FileNoSeek implements fs.FileOperations.Seek to return EINVAL.
type FileNoSplice ¶
type FileNoSplice struct{}
FileNoSplice implements fs.FileOperations.ReadFrom and fs.FileOperations.WriteTo for files that don't support splice.
type FileNoWrite ¶
type FileNoWrite struct{}
FileNoWrite implements fs.FileOperations.Write to return EINVAL.
type FileNoopFlush ¶
type FileNoopFlush struct{}
FileNoopFlush implements fs.FileOperations.Flush as a no-op.
type FileNoopFsync ¶
type FileNoopFsync struct{}
FileNoopFsync implements fs.FileOperations.Fsync for files that don't need to synced.
type FileNoopRead ¶
type FileNoopRead struct{}
FileNoopRead implement fs.FileOperations.Read as a noop.
type FileNoopRelease ¶
type FileNoopRelease struct{}
FileNoopRelease implements fs.FileOperations.Release for files that have no resources to release.
func (FileNoopRelease) Release ¶
func (FileNoopRelease) Release(context.Context)
Release is a no-op.
type FileNoopWrite ¶
type FileNoopWrite struct{}
FileNoopWrite implements fs.FileOperations.Write as a noop.
type FileNotDirReaddir ¶
type FileNotDirReaddir struct{}
FileNotDirReaddir implements fs.FileOperations.Readdir for non-directories.
type FilePipeSeek ¶
type FilePipeSeek struct{}
FilePipeSeek implements fs.FileOperations.Seek and can be used for files that behave like pipes (seeking is not supported).
type FileRangeSetFunctions ¶
type FileRangeSetFunctions struct{}
FileRangeSetFunctions implements segment.Functions for FileRangeSet.
func (FileRangeSetFunctions) ClearValue ¶
func (FileRangeSetFunctions) ClearValue(_ *uint64)
ClearValue implements segment.Functions.ClearValue.
func (FileRangeSetFunctions) MaxKey ¶
func (FileRangeSetFunctions) MaxKey() uint64
MaxKey implements segment.Functions.MaxKey.
func (FileRangeSetFunctions) Merge ¶
func (FileRangeSetFunctions) Merge(mr1 memmap.MappableRange, frstart1 uint64, _ memmap.MappableRange, frstart2 uint64) (uint64, bool)
Merge implements segment.Functions.Merge.
func (FileRangeSetFunctions) MinKey ¶
func (FileRangeSetFunctions) MinKey() uint64
MinKey implements segment.Functions.MinKey.
func (FileRangeSetFunctions) Split ¶
func (FileRangeSetFunctions) Split(mr memmap.MappableRange, frstart uint64, split uint64) (uint64, uint64)
Split implements segment.Functions.Split.
type FileStaticContentReader ¶
type FileStaticContentReader struct {
// contains filtered or unexported fields
}
FileStaticContentReader is a helper to implement fs.FileOperations.Read with static content.
+stateify savable
func NewFileStaticContentReader ¶
func NewFileStaticContentReader(b []byte) FileStaticContentReader
NewFileStaticContentReader initializes a FileStaticContentReader with the given content.
type FileUseInodeUnstableAttr ¶
type FileUseInodeUnstableAttr struct{}
FileUseInodeUnstableAttr implements fs.FileOperations.UnstableAttr by calling InodeOperations.UnstableAttr.
func (FileUseInodeUnstableAttr) UnstableAttr ¶
func (FileUseInodeUnstableAttr) UnstableAttr(ctx context.Context, file *fs.File) (fs.UnstableAttr, error)
UnstableAttr implements fs.FileOperations.UnstableAttr.
type FileZeroSeek ¶
type FileZeroSeek struct{}
FileZeroSeek implements fs.FileOperations.Seek for files that maintain a constant zero-value offset and require a no-op Seek.
type FrameRefSetFunctions ¶
type FrameRefSetFunctions struct{}
FrameRefSetFunctions implements segment.Functions for FrameRefSet.
func (FrameRefSetFunctions) ClearValue ¶
func (FrameRefSetFunctions) ClearValue(val *uint64)
ClearValue implements segment.Functions.ClearValue.
func (FrameRefSetFunctions) MaxKey ¶
func (FrameRefSetFunctions) MaxKey() uint64
MaxKey implements segment.Functions.MaxKey.
func (FrameRefSetFunctions) Merge ¶
func (FrameRefSetFunctions) Merge(_ memmap.FileRange, val1 uint64, _ memmap.FileRange, val2 uint64) (uint64, bool)
Merge implements segment.Functions.Merge.
func (FrameRefSetFunctions) MinKey ¶
func (FrameRefSetFunctions) MinKey() uint64
MinKey implements segment.Functions.MinKey.
type HostFileMapper ¶
type HostFileMapper struct {
// contains filtered or unexported fields
}
HostFileMapper caches mappings of an arbitrary host file descriptor. It is used by implementations of memmap.Mappable that represent a host file descriptor.
+stateify savable
func NewHostFileMapper ¶
func NewHostFileMapper() *HostFileMapper
NewHostFileMapper returns an initialized HostFileMapper allocated on the heap with no references or cached mappings.
func (*HostFileMapper) DecRefOn ¶
func (f *HostFileMapper) DecRefOn(mr memmap.MappableRange)
DecRefOn decrements the reference count on all offsets in mr.
Preconditions: * mr.Length() != 0. * mr.Start and mr.End must be page-aligned.
func (*HostFileMapper) IncRefOn ¶
func (f *HostFileMapper) IncRefOn(mr memmap.MappableRange)
IncRefOn increments the reference count on all offsets in mr.
Preconditions: * mr.Length() != 0. * mr.Start and mr.End must be page-aligned.
func (*HostFileMapper) Init ¶
func (f *HostFileMapper) Init()
Init must be called on zero-value HostFileMappers before first use.
func (*HostFileMapper) IsInited ¶
func (f *HostFileMapper) IsInited() bool
IsInited returns true if f.Init() has been called. This is used when restoring a checkpoint that contains a HostFileMapper that may or may not have been initialized.
func (*HostFileMapper) MapInternal ¶
func (f *HostFileMapper) MapInternal(fr memmap.FileRange, fd int, write bool) (safemem.BlockSeq, error)
MapInternal returns a mapping of offsets in fr from fd. The returned safemem.BlockSeq is valid as long as at least one reference is held on all offsets in fr or until the next call to UnmapAll.
Preconditions: The caller must hold a reference on all offsets in fr.
func (*HostFileMapper) RegenerateMappings ¶
func (f *HostFileMapper) RegenerateMappings(fd int) error
RegenerateMappings must be called when the file description mapped by f changes, to replace existing mappings of the previous file description.
func (*HostFileMapper) UnmapAll ¶
func (f *HostFileMapper) UnmapAll()
UnmapAll unmaps all cached mappings. Callers are responsible for synchronization with mappings returned by previous calls to MapInternal.
type HostMappable ¶
type HostMappable struct {
// contains filtered or unexported fields
}
HostMappable implements memmap.Mappable and memmap.File over a CachedFileObject.
Lock order (compare the lock order model in mm/mm.go):
truncateMu ("fs locks") mu ("memmap.Mappable locks not taken by Translate") ("memmap.File locks") backingFile ("CachedFileObject locks")
+stateify savable
func NewHostMappable ¶
func NewHostMappable(backingFile CachedFileObject) *HostMappable
NewHostMappable creates a new mappable that maps directly to host FD.
func (*HostMappable) AddMapping ¶
func (h *HostMappable) AddMapping(ctx context.Context, ms memmap.MappingSpace, ar hostarch.AddrRange, offset uint64, writable bool) error
AddMapping implements memmap.Mappable.AddMapping.
func (*HostMappable) CopyMapping ¶
func (h *HostMappable) CopyMapping(ctx context.Context, ms memmap.MappingSpace, srcAR, dstAR hostarch.AddrRange, offset uint64, writable bool) error
CopyMapping implements memmap.Mappable.CopyMapping.
func (*HostMappable) DecRef ¶
func (h *HostMappable) DecRef(fr memmap.FileRange)
DecRef implements memmap.File.DecRef.
func (*HostMappable) IncRef ¶
func (h *HostMappable) IncRef(fr memmap.FileRange)
IncRef implements memmap.File.IncRef.
func (*HostMappable) InvalidateUnsavable ¶
func (h *HostMappable) InvalidateUnsavable(_ context.Context) error
InvalidateUnsavable implements memmap.Mappable.InvalidateUnsavable.
func (*HostMappable) MapInternal ¶
func (h *HostMappable) MapInternal(fr memmap.FileRange, at hostarch.AccessType) (safemem.BlockSeq, error)
MapInternal implements memmap.File.MapInternal.
func (*HostMappable) NotifyChangeFD ¶
func (h *HostMappable) NotifyChangeFD() error
NotifyChangeFD must be called after the file description represented by CachedFileObject.FD() changes.
func (*HostMappable) RemoveMapping ¶
func (h *HostMappable) RemoveMapping(ctx context.Context, ms memmap.MappingSpace, ar hostarch.AddrRange, offset uint64, writable bool)
RemoveMapping implements memmap.Mappable.RemoveMapping.
func (*HostMappable) Translate ¶
func (h *HostMappable) Translate(ctx context.Context, required, optional memmap.MappableRange, at hostarch.AccessType) ([]memmap.Translation, error)
Translate implements memmap.Mappable.Translate.
func (*HostMappable) Truncate ¶
func (h *HostMappable) Truncate(ctx context.Context, newSize int64, uattr fs.UnstableAttr) error
Truncate truncates the file, invalidating any mapping that may have been removed after the size change.
Truncation and writes are synchronized to prevent races where writes make the file grow between truncation and invalidation below:
T1: Calls SetMaskedAttributes and stalls T2: Appends to file causing it to grow T2: Writes to mapped pages and COW happens T1: Continues and wronly invalidates the page mapped in step above.
func (*HostMappable) Write ¶
func (h *HostMappable) Write(ctx context.Context, src usermem.IOSequence, offset int64, uattr fs.UnstableAttr) (int64, error)
Write writes to the file backing this mappable.
type InodeDenyWriteChecker ¶
type InodeDenyWriteChecker struct{}
InodeDenyWriteChecker implements fs.InodeOperations.Check which denies all write operations.
type InodeGenericChecker ¶
type InodeGenericChecker struct{}
InodeGenericChecker implements fs.InodeOperations.Check with a generic implementation.
type InodeIsDirAllocate ¶
type InodeIsDirAllocate struct{}
InodeIsDirAllocate implements fs.InodeOperations.Allocate for directories.
type InodeIsDirTruncate ¶
type InodeIsDirTruncate struct{}
InodeIsDirTruncate implements fs.InodeOperations.Truncate for directories.
type InodeNoExtendedAttributes ¶
type InodeNoExtendedAttributes struct{}
InodeNoExtendedAttributes can be used by Inodes that do not support extended attributes.
func (InodeNoExtendedAttributes) GetXattr ¶
func (InodeNoExtendedAttributes) GetXattr(context.Context, *fs.Inode, string, uint64) (string, error)
GetXattr implements fs.InodeOperations.GetXattr.
func (InodeNoExtendedAttributes) ListXattr ¶
func (InodeNoExtendedAttributes) ListXattr(context.Context, *fs.Inode, uint64) (map[string]struct{}, error)
ListXattr implements fs.InodeOperations.ListXattr.
func (InodeNoExtendedAttributes) RemoveXattr ¶
RemoveXattr implements fs.InodeOperations.RemoveXattr.
type InodeNoopAllocate ¶
type InodeNoopAllocate struct{}
InodeNoopAllocate implements fs.InodeOperations.Allocate as a noop.
type InodeNoopRelease ¶
type InodeNoopRelease struct{}
InodeNoopRelease implements fs.InodeOperations.Release as a noop.
func (InodeNoopRelease) Release ¶
func (InodeNoopRelease) Release(context.Context)
Release implements fs.InodeOperations.Release.
type InodeNoopTruncate ¶
type InodeNoopTruncate struct{}
InodeNoopTruncate implements fs.InodeOperations.Truncate as a noop.
type InodeNoopWriteOut ¶
type InodeNoopWriteOut struct{}
InodeNoopWriteOut is a no-op implementation of fs.InodeOperations.WriteOut.
type InodeNotAllocatable ¶
type InodeNotAllocatable struct{}
InodeNotAllocatable can be used by Inodes that do not support Allocate().
type InodeNotDirectory ¶
type InodeNotDirectory struct{}
InodeNotDirectory can be used by Inodes that are not directories.
func (InodeNotDirectory) Bind ¶
func (InodeNotDirectory) Bind(context.Context, *fs.Inode, string, transport.BoundEndpoint, fs.FilePermissions) (*fs.Dirent, error)
Bind implements fs.InodeOperations.Bind.
func (InodeNotDirectory) Create ¶
func (InodeNotDirectory) Create(context.Context, *fs.Inode, string, fs.FileFlags, fs.FilePermissions) (*fs.File, error)
Create implements fs.InodeOperations.Create.
func (InodeNotDirectory) CreateDirectory ¶
func (InodeNotDirectory) CreateDirectory(context.Context, *fs.Inode, string, fs.FilePermissions) error
CreateDirectory implements fs.InodeOperations.CreateDirectory.
func (InodeNotDirectory) CreateFifo ¶
func (InodeNotDirectory) CreateFifo(context.Context, *fs.Inode, string, fs.FilePermissions) error
CreateFifo implements fs.InodeOperations.CreateFifo.
func (InodeNotDirectory) CreateHardLink ¶
CreateHardLink implements fs.InodeOperations.CreateHardLink.
func (InodeNotDirectory) CreateLink ¶
CreateLink implements fs.InodeOperations.CreateLink.
func (InodeNotDirectory) RemoveDirectory ¶
RemoveDirectory implements fs.InodeOperations.RemoveDirectory.
type InodeNotMappable ¶
type InodeNotMappable struct{}
InodeNotMappable returns a nil memmap.Mappable.
type InodeNotOpenable ¶
type InodeNotOpenable struct{}
InodeNotOpenable can be used by Inodes that cannot be opened.
type InodeNotRenameable ¶
type InodeNotRenameable struct{}
InodeNotRenameable can be used by Inodes that cannot be truncated.
type InodeNotSocket ¶
type InodeNotSocket struct{}
InodeNotSocket can be used by Inodes that are not sockets.
func (InodeNotSocket) BoundEndpoint ¶
func (InodeNotSocket) BoundEndpoint(*fs.Inode, string) transport.BoundEndpoint
BoundEndpoint implements fs.InodeOperations.BoundEndpoint.
type InodeNotSymlink ¶
type InodeNotSymlink struct{}
InodeNotSymlink can be used by Inodes that are not symlinks.
type InodeNotTruncatable ¶
type InodeNotTruncatable struct{}
InodeNotTruncatable can be used by Inodes that cannot be truncated.
type InodeNotVirtual ¶
type InodeNotVirtual struct{}
InodeNotVirtual can be used by Inodes that are not virtual.
func (InodeNotVirtual) IsVirtual ¶
func (InodeNotVirtual) IsVirtual() bool
IsVirtual implements fs.InodeOperations.IsVirtual.
type InodeSimpleAttributes ¶
type InodeSimpleAttributes struct {
// contains filtered or unexported fields
}
InodeSimpleAttributes implements methods for updating in-memory unstable attributes.
+stateify savable
func NewInodeSimpleAttributes ¶
func NewInodeSimpleAttributes(ctx context.Context, owner fs.FileOwner, perms fs.FilePermissions, typ uint64) InodeSimpleAttributes
NewInodeSimpleAttributes returns a new InodeSimpleAttributes with the given owner and permissions, and all timestamps set to the current time.
func NewInodeSimpleAttributesWithUnstable ¶
func NewInodeSimpleAttributesWithUnstable(uattr fs.UnstableAttr, typ uint64) InodeSimpleAttributes
NewInodeSimpleAttributesWithUnstable returns a new InodeSimpleAttributes with the given unstable attributes.
func (*InodeSimpleAttributes) AddLink ¶
func (i *InodeSimpleAttributes) AddLink()
AddLink implements fs.InodeOperations.AddLink.
func (*InodeSimpleAttributes) DropLink ¶
func (i *InodeSimpleAttributes) DropLink()
DropLink implements fs.InodeOperations.DropLink.
func (*InodeSimpleAttributes) NotifyAccess ¶
func (i *InodeSimpleAttributes) NotifyAccess(ctx context.Context)
NotifyAccess updates the access time.
func (*InodeSimpleAttributes) NotifyModification ¶
func (i *InodeSimpleAttributes) NotifyModification(ctx context.Context)
NotifyModification updates the modification time.
func (*InodeSimpleAttributes) NotifyModificationAndStatusChange ¶
func (i *InodeSimpleAttributes) NotifyModificationAndStatusChange(ctx context.Context)
NotifyModificationAndStatusChange updates the modification and status change times.
func (*InodeSimpleAttributes) NotifyStatusChange ¶
func (i *InodeSimpleAttributes) NotifyStatusChange(ctx context.Context)
NotifyStatusChange updates the status change time.
func (*InodeSimpleAttributes) SetOwner ¶
func (i *InodeSimpleAttributes) SetOwner(ctx context.Context, _ *fs.Inode, owner fs.FileOwner) error
SetOwner implements fs.InodeOperations.SetOwner.
func (*InodeSimpleAttributes) SetPermissions ¶
func (i *InodeSimpleAttributes) SetPermissions(ctx context.Context, _ *fs.Inode, p fs.FilePermissions) bool
SetPermissions implements fs.InodeOperations.SetPermissions.
func (*InodeSimpleAttributes) SetTimestamps ¶
func (i *InodeSimpleAttributes) SetTimestamps(ctx context.Context, _ *fs.Inode, ts fs.TimeSpec) error
SetTimestamps implements fs.InodeOperations.SetTimestamps.
func (*InodeSimpleAttributes) UnstableAttr ¶
func (i *InodeSimpleAttributes) UnstableAttr(ctx context.Context, _ *fs.Inode) (fs.UnstableAttr, error)
UnstableAttr implements fs.InodeOperations.UnstableAttr.
type InodeSimpleExtendedAttributes ¶
type InodeSimpleExtendedAttributes struct {
// contains filtered or unexported fields
}
InodeSimpleExtendedAttributes implements fs.InodeOperations.{Get,Set,List}Xattr.
+stateify savable
func (*InodeSimpleExtendedAttributes) GetXattr ¶
func (i *InodeSimpleExtendedAttributes) GetXattr(_ context.Context, _ *fs.Inode, name string, _ uint64) (string, error)
GetXattr implements fs.InodeOperations.GetXattr.
func (*InodeSimpleExtendedAttributes) ListXattr ¶
func (i *InodeSimpleExtendedAttributes) ListXattr(context.Context, *fs.Inode, uint64) (map[string]struct{}, error)
ListXattr implements fs.InodeOperations.ListXattr.
func (*InodeSimpleExtendedAttributes) RemoveXattr ¶
func (i *InodeSimpleExtendedAttributes) RemoveXattr(_ context.Context, _ *fs.Inode, name string) error
RemoveXattr implements fs.InodeOperations.RemoveXattr.
type InodeStaticFileGetter ¶
type InodeStaticFileGetter struct {
Contents []byte
}
InodeStaticFileGetter implements GetFile for a file with static contents.
+stateify savable
type InodeVirtual ¶
type InodeVirtual struct{}
InodeVirtual can be used by Inodes that are virtual.
func (InodeVirtual) IsVirtual ¶
func (InodeVirtual) IsVirtual() bool
IsVirtual implements fs.InodeOperations.IsVirtual.
type NoReadWriteFile ¶
type NoReadWriteFile struct { waiter.AlwaysReady `state:"nosave"` FileGenericSeek `state:"nosave"` FileNoIoctl `state:"nosave"` FileNoMMap `state:"nosave"` FileNoopFsync `state:"nosave"` FileNoopFlush `state:"nosave"` FileNoopRelease `state:"nosave"` FileNoRead `state:"nosave"` FileNoWrite `state:"nosave"` FileNotDirReaddir `state:"nosave"` FileUseInodeUnstableAttr `state:"nosave"` FileNoSplice `state:"nosave"` }
NoReadWriteFile is a file that does not support reading or writing.
+stateify savable
type NoReadWriteFileInode ¶
type NoReadWriteFileInode struct { InodeGenericChecker `state:"nosave"` InodeNoExtendedAttributes `state:"nosave"` InodeNoopRelease `state:"nosave"` InodeNoopWriteOut `state:"nosave"` InodeNotAllocatable `state:"nosave"` InodeNotDirectory `state:"nosave"` InodeNotMappable `state:"nosave"` InodeNotSocket `state:"nosave"` InodeNotSymlink `state:"nosave"` InodeNotTruncatable `state:"nosave"` InodeNotVirtual `state:"nosave"` InodeSimpleAttributes }
NoReadWriteFileInode is an implementation of InodeOperations that supports opening files that are not readable or writeable.
+stateify savable
func NewNoReadWriteFileInode ¶
func NewNoReadWriteFileInode(ctx context.Context, owner fs.FileOwner, perms fs.FilePermissions, typ uint64) *NoReadWriteFileInode
NewNoReadWriteFileInode returns a new NoReadWriteFileInode.
type SimpleFileInode ¶
type SimpleFileInode struct { InodeGenericChecker `state:"nosave"` InodeNoExtendedAttributes `state:"nosave"` InodeNoopRelease `state:"nosave"` InodeNoopWriteOut `state:"nosave"` InodeNotAllocatable `state:"nosave"` InodeNotDirectory `state:"nosave"` InodeNotMappable `state:"nosave"` InodeNotOpenable `state:"nosave"` InodeNotSocket `state:"nosave"` InodeNotSymlink `state:"nosave"` InodeNotTruncatable `state:"nosave"` InodeNotVirtual `state:"nosave"` InodeSimpleAttributes }
SimpleFileInode is a simple implementation of InodeOperations.
+stateify savable
func NewSimpleFileInode ¶
func NewSimpleFileInode(ctx context.Context, owner fs.FileOwner, perms fs.FilePermissions, typ uint64) *SimpleFileInode
NewSimpleFileInode returns a new SimpleFileInode.
type StaticDirFileOperations ¶
type StaticDirFileOperations struct { DirFileOperations `state:"nosave"` FileUseInodeUnstableAttr `state:"nosave"` // contains filtered or unexported fields }
StaticDirFileOperations implements fs.FileOperations for directories with static children.
+stateify savable
func NewStaticDirFileOperations ¶
func NewStaticDirFileOperations(dentries *fs.SortedDentryMap) *StaticDirFileOperations
NewStaticDirFileOperations returns a new StaticDirFileOperations that will iterate the given denty map.