fs

package
v0.0.0-...-77c5d82 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2022 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaxReadHead   = uint32(400 * 1024 * 1024)
	ReadHeadChunk = uint32(20 * 1024 * 1024)
)
View Source
const BuffSize = 5 * 1024 * 1024

Variables

View Source
var TIMEMAX = time.Unix(1<<63-62135596801, 999999999)

Functions

func Dup

func Dup(value []byte) []byte

func GetTgid

func GetTgid(pid uint32) (tgid *int32, err error)

GetTgid returns the tgid for the given pid.

func LogPanic

func LogPanic(err *error)

func MaxInt

func MaxInt(a, b int) int

func MaxInt64

func MaxInt64(a, b int64) int64

func MaxUInt32

func MaxUInt32(a, b uint32) uint32

func MaxUInt64

func MaxUInt64(a, b uint64) uint64

func MinInt

func MinInt(a, b int) int

func MinInt64

func MinInt64(a, b int64) int64

func MinUInt32

func MinUInt32(a, b uint32) uint32

func MinUInt64

func MinUInt64(a, b uint64) uint64

func NilStr

func NilStr(v *string) string

func PBool

func PBool(v bool) *bool

func PInt32

func PInt32(v int32) *int32

func PInt64

func PInt64(v int64) *int64

func PString

func PString(v string) *string

func PTime

func PTime(v time.Time) *time.Time

func PUInt32

func PUInt32(v uint32) *uint32

func PUInt64

func PUInt64(v uint64) *uint64

func TryUnmountFS

func TryUnmountFS(mountPoint string) (err error)

Types

type Buffer

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

func (*Buffer) Close

func (b *Buffer) Close() (err error)

func (Buffer) Init

func (b Buffer) Init(buf *MBuf, r ReaderProvider) *Buffer

func (*Buffer) ReInit

func (b *Buffer) ReInit(r ReaderProvider)

func (*Buffer) Read

func (b *Buffer) Read(p []byte) (n int, err error)

type BufferPool

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

func NewBufferPool

func NewBufferPool(maxSizeGlobal uint64) *BufferPool

for testing

func (*BufferPool) Free

func (pool *BufferPool) Free(buf []byte)

func (BufferPool) Init

func (pool BufferPool) Init() *BufferPool

func (*BufferPool) MaybeGC

func (pool *BufferPool) MaybeGC()

func (*BufferPool) RequestBuffer

func (pool *BufferPool) RequestBuffer() (buf []byte)

func (*BufferPool) RequestMultiple

func (pool *BufferPool) RequestMultiple(size uint64, block bool) (buffers [][]byte)

type DirHandle

type DirHandle struct {
	Marker *string
	// contains filtered or unexported fields
}

func NewDirHandle

func NewDirHandle(inode *Inode) (dh *DirHandle)

func (*DirHandle) CloseDir

func (dh *DirHandle) CloseDir() error

func (*DirHandle) ReadDir

func (dh *DirHandle) ReadDir(offset fuseops.DirOffset) (en *DirHandleEntry, err error)

LOCKS_REQUIRED(dh.mu) LOCKS_EXCLUDED(dh.inode.mu) LOCKS_EXCLUDED(dh.inode.fs)

type DirHandleEntry

type DirHandleEntry struct {
	Name   string
	Inode  fuseops.InodeID
	Type   fuseutil.DirentType
	Offset fuseops.DirOffset
}

type DirInodeData

type DirInodeData struct {
	DirTime time.Time

	Children []*Inode
	// contains filtered or unexported fields
}

type FileHandle

type FileHandle struct {

	// User space PID. All threads created by a process will have the same TGID,
	// but different PIDs[1].
	// This value can be nil if we fail to get TGID from PID[2].
	// [1] : https://godoc.org/github.com/shirou/gopsutil/process#Process.Tgid
	// [2] : https://github.com/shirou/gopsutil#process-class
	Tgid *int32
	// contains filtered or unexported fields
}

func NewFileHandle

func NewFileHandle(inode *Inode, opMetadata fuseops.OpMetadata) *FileHandle

NewFileHandle returns a new file handle for the given `inode` triggered by fuse operation with the given `opMetadata`

func (*FileHandle) FlushFile

func (fh *FileHandle) FlushFile() (err error)

func (*FileHandle) ReadFile

func (fh *FileHandle) ReadFile(offset int64, buf []byte) (bytesRead int, err error)

func (*FileHandle) Release

func (fh *FileHandle) Release()

func (*FileHandle) WriteFile

func (fh *FileHandle) WriteFile(offset int64, data []byte) (err error)

type FileSystem

type FileSystem struct {
	fuseutil.NotImplementedFileSystem
	// contains filtered or unexported fields
}

func MountFS

func NewFileSystem

func NewFileSystem(ctx context.Context, cloud storage.ObjectBackend, flags *Flags) *FileSystem

func (*FileSystem) CreateFile

func (fs *FileSystem) CreateFile(ctx context.Context, op *fuseops.CreateFileOp) (err error)

func (*FileSystem) FlushFile

func (fs *FileSystem) FlushFile(ctx context.Context, op *fuseops.FlushFileOp) (err error)

func (*FileSystem) ForgetInode

func (fs *FileSystem) ForgetInode(ctx context.Context, op *fuseops.ForgetInodeOp) (err error)

func (*FileSystem) GetInodeAttributes

func (fs *FileSystem) GetInodeAttributes(ctx context.Context, op *fuseops.GetInodeAttributesOp) (err error)

func (*FileSystem) GetXattr

func (fs *FileSystem) GetXattr(ctx context.Context, op *fuseops.GetXattrOp) (err error)

func (*FileSystem) ListXattr

func (fs *FileSystem) ListXattr(ctx context.Context, op *fuseops.ListXattrOp) (err error)

func (*FileSystem) LookUpInode

func (fs *FileSystem) LookUpInode(ctx context.Context, op *fuseops.LookUpInodeOp) (err error)

func (*FileSystem) MkDir

func (fs *FileSystem) MkDir(ctx context.Context, op *fuseops.MkDirOp) (err error)

func (*FileSystem) Mount

func (fs *FileSystem) Mount(mount *Mount)

func (*FileSystem) MountAll

func (fs *FileSystem) MountAll(mounts []*Mount)

func (*FileSystem) OpenDir

func (fs *FileSystem) OpenDir(ctx context.Context, op *fuseops.OpenDirOp) (err error)

func (*FileSystem) OpenFile

func (fs *FileSystem) OpenFile(ctx context.Context, op *fuseops.OpenFileOp) (err error)

func (*FileSystem) ReadDir

func (fs *FileSystem) ReadDir(ctx context.Context, op *fuseops.ReadDirOp) (err error)

func (*FileSystem) ReadFile

func (fs *FileSystem) ReadFile(ctx context.Context, op *fuseops.ReadFileOp) (err error)

func (*FileSystem) ReleaseDirHandle

func (fs *FileSystem) ReleaseDirHandle(ctx context.Context, op *fuseops.ReleaseDirHandleOp) (err error)

func (*FileSystem) ReleaseFileHandle

func (fs *FileSystem) ReleaseFileHandle(ctx context.Context, op *fuseops.ReleaseFileHandleOp) (err error)

func (*FileSystem) RemoveXattr

func (fs *FileSystem) RemoveXattr(ctx context.Context, op *fuseops.RemoveXattrOp) (err error)

func (*FileSystem) Rename

func (fs *FileSystem) Rename(ctx context.Context, op *fuseops.RenameOp) (err error)

rename("from", "to") causes the kernel to send lookup of "from" and "to" prior to sending rename to us

func (*FileSystem) RmDir

func (fs *FileSystem) RmDir(ctx context.Context, op *fuseops.RmDirOp) (err error)

func (*FileSystem) SetInodeAttributes

func (fs *FileSystem) SetInodeAttributes(ctx context.Context, op *fuseops.SetInodeAttributesOp) (err error)

func (*FileSystem) SetXattr

func (fs *FileSystem) SetXattr(ctx context.Context,
	op *fuseops.SetXattrOp) (err error)

func (*FileSystem) SigUsr1

func (fs *FileSystem) SigUsr1()

func (*FileSystem) StatFS

func (fs *FileSystem) StatFS(ctx context.Context, op *fuseops.StatFSOp) error

func (*FileSystem) SyncFile

func (fs *FileSystem) SyncFile(ctx context.Context, op *fuseops.SyncFileOp) (err error)
func (fs *FileSystem) Unlink(ctx context.Context, op *fuseops.UnlinkOp) (err error)

func (*FileSystem) Unmount

func (fs *FileSystem) Unmount(mountPoint string)

func (*FileSystem) WriteFile

func (fs *FileSystem) WriteFile(ctx context.Context, op *fuseops.WriteFileOp) (err error)

type Flags

type Flags struct {
	// File system
	MountOptions      map[string]string
	MountPoint        string
	MountPointArg     string
	MountPointCreated string

	Cache    []string
	DirMode  os.FileMode
	FileMode os.FileMode
	Uid      uint32
	Gid      uint32

	// Common Backend Flags
	UseContentType bool
	Endpoint       string

	// Tuning
	ExplicitDir  bool
	StatCacheTTL time.Duration
	TypeCacheTTL time.Duration
	HTTPTimeout  time.Duration

	// Debugging
	DebugFuse  bool
	Foreground bool
}

func (*Flags) Cleanup

func (c *Flags) Cleanup()

func (*Flags) GetMimeType

func (c *Flags) GetMimeType(fileName string) (retMime *string)

type FusePanicLogger

type FusePanicLogger struct {
	Fs fuseutil.FileSystem
}

func (FusePanicLogger) CreateFile

func (fs FusePanicLogger) CreateFile(ctx context.Context, op *fuseops.CreateFileOp) (err error)
func (fs FusePanicLogger) CreateLink(ctx context.Context, op *fuseops.CreateLinkOp) (err error)
func (fs FusePanicLogger) CreateSymlink(ctx context.Context, op *fuseops.CreateSymlinkOp) (err error)

func (FusePanicLogger) Destroy

func (fs FusePanicLogger) Destroy()

func (FusePanicLogger) Fallocate

func (fs FusePanicLogger) Fallocate(ctx context.Context, op *fuseops.FallocateOp) (err error)

func (FusePanicLogger) FlushFile

func (fs FusePanicLogger) FlushFile(ctx context.Context, op *fuseops.FlushFileOp) (err error)

func (FusePanicLogger) ForgetInode

func (fs FusePanicLogger) ForgetInode(ctx context.Context, op *fuseops.ForgetInodeOp) (err error)

func (FusePanicLogger) GetInodeAttributes

func (fs FusePanicLogger) GetInodeAttributes(ctx context.Context, op *fuseops.GetInodeAttributesOp) (err error)

func (FusePanicLogger) GetXattr

func (fs FusePanicLogger) GetXattr(ctx context.Context, op *fuseops.GetXattrOp) (err error)

func (FusePanicLogger) ListXattr

func (fs FusePanicLogger) ListXattr(ctx context.Context, op *fuseops.ListXattrOp) (err error)

func (FusePanicLogger) LookUpInode

func (fs FusePanicLogger) LookUpInode(ctx context.Context, op *fuseops.LookUpInodeOp) (err error)

func (FusePanicLogger) MkDir

func (fs FusePanicLogger) MkDir(ctx context.Context, op *fuseops.MkDirOp) (err error)

func (FusePanicLogger) MkNode

func (fs FusePanicLogger) MkNode(ctx context.Context, op *fuseops.MkNodeOp) (err error)

func (FusePanicLogger) OpenDir

func (fs FusePanicLogger) OpenDir(ctx context.Context, op *fuseops.OpenDirOp) (err error)

func (FusePanicLogger) OpenFile

func (fs FusePanicLogger) OpenFile(ctx context.Context, op *fuseops.OpenFileOp) (err error)

func (FusePanicLogger) ReadDir

func (fs FusePanicLogger) ReadDir(ctx context.Context, op *fuseops.ReadDirOp) (err error)

func (FusePanicLogger) ReadFile

func (fs FusePanicLogger) ReadFile(ctx context.Context, op *fuseops.ReadFileOp) (err error)
func (fs FusePanicLogger) ReadSymlink(ctx context.Context, op *fuseops.ReadSymlinkOp) (err error)

func (FusePanicLogger) ReleaseDirHandle

func (fs FusePanicLogger) ReleaseDirHandle(ctx context.Context, op *fuseops.ReleaseDirHandleOp) (err error)

func (FusePanicLogger) ReleaseFileHandle

func (fs FusePanicLogger) ReleaseFileHandle(ctx context.Context, op *fuseops.ReleaseFileHandleOp) (err error)

func (FusePanicLogger) RemoveXattr

func (fs FusePanicLogger) RemoveXattr(ctx context.Context, op *fuseops.RemoveXattrOp) (err error)

func (FusePanicLogger) Rename

func (fs FusePanicLogger) Rename(ctx context.Context, op *fuseops.RenameOp) (err error)

func (FusePanicLogger) RmDir

func (fs FusePanicLogger) RmDir(ctx context.Context, op *fuseops.RmDirOp) (err error)

func (FusePanicLogger) SetInodeAttributes

func (fs FusePanicLogger) SetInodeAttributes(ctx context.Context, op *fuseops.SetInodeAttributesOp) (err error)

func (FusePanicLogger) SetXattr

func (fs FusePanicLogger) SetXattr(ctx context.Context, op *fuseops.SetXattrOp) (err error)

func (FusePanicLogger) StatFS

func (fs FusePanicLogger) StatFS(ctx context.Context, op *fuseops.StatFSOp) (err error)

func (FusePanicLogger) SyncFile

func (fs FusePanicLogger) SyncFile(ctx context.Context, op *fuseops.SyncFileOp) (err error)
func (fs FusePanicLogger) Unlink(ctx context.Context, op *fuseops.UnlinkOp) (err error)

func (FusePanicLogger) WriteFile

func (fs FusePanicLogger) WriteFile(ctx context.Context, op *fuseops.WriteFileOp) (err error)

type Inode

type Inode struct {
	Id   fuseops.InodeID
	Name *string

	Attributes InodeAttributes
	KnownSize  *uint64
	// It is generally safe to read `AttrTime` without locking because if some other
	// operation is modifying `AttrTime`, in most cases the reader is okay with working with
	// stale data. But Time is a struct and modifying it is not atomic. However
	// in practice (until the year 2157) we should be okay because
	// - Almost all uses of AttrTime will be about comparisions (AttrTime < x, AttrTime > x)
	// - Time object will have Time::monotonic bit set (until the year 2157) => the time
	//   comparision just compares Time::ext field
	// Ref: https://github.com/golang/go/blob/e42ae65a8507/src/time/time.go#L12:L56
	AttrTime time.Time

	// We are not very consistent about enforcing locks for `Parent` because, the
	// parent field very very rarely changes and it is generally fine to operate on
	// stale parent informaiton
	Parent *Inode

	Invalid     bool
	ImplicitDir bool
	// contains filtered or unexported fields
}

func NewInode

func NewInode(fs *FileSystem, parent *Inode, name *string) (inode *Inode)

func (*Inode) Create

func (parent *Inode) Create(name string, metadata fuseops.OpMetadata) (inode *Inode, fh *FileHandle)

func (*Inode) DeRef

func (inode *Inode) DeRef(n uint64) (stale bool)

func (*Inode) FullName

func (inode *Inode) FullName() *string

func (*Inode) GetAttributes

func (inode *Inode) GetAttributes() (*fuseops.InodeAttributes, error)

func (*Inode) GetXattr

func (inode *Inode) GetXattr(name string) ([]byte, error)

func (*Inode) InflateAttributes

func (inode *Inode) InflateAttributes() (attr fuseops.InodeAttributes)

func (*Inode) ListXattr

func (inode *Inode) ListXattr() ([]string, error)

func (*Inode) LookUp

func (parent *Inode) LookUp(name string) (inode *Inode, err error)

func (*Inode) LookUpInodeDir

func (parent *Inode) LookUpInodeDir(name string, c chan storage.ListBlobsOutput, errc chan error)

func (*Inode) LookUpInodeMaybeDir

func (parent *Inode) LookUpInodeMaybeDir(name string, fullName string) (inode *Inode, err error)

returned inode has nil Id

func (*Inode) LookUpInodeNotDir

func (parent *Inode) LookUpInodeNotDir(name string, c chan storage.HeadBlobOutput, errc chan error)

func (*Inode) MkDir

func (parent *Inode) MkDir(name string) (inode *Inode, err error)

func (*Inode) OpenDir

func (inode *Inode) OpenDir() (dh *DirHandle)

func (*Inode) OpenFile

func (inode *Inode) OpenFile(metadata fuseops.OpMetadata) (fh *FileHandle, err error)

func (*Inode) Ref

func (inode *Inode) Ref()

LOCKS_REQUIRED(fs.mu) XXX why did I put lock required? This used to return a resurrect bool which no long does anything, need to look into that to see if that was legacy

func (*Inode) RemoveXattr

func (inode *Inode) RemoveXattr(name string) error

func (*Inode) Rename

func (parent *Inode) Rename(from string, newParent *Inode, to string) (err error)

semantic of rename: rename("any", "not_exists") = ok rename("file1", "file2") = ok rename("empty_dir1", "empty_dir2") = ok rename("nonempty_dir1", "empty_dir2") = ok rename("nonempty_dir1", "nonempty_dir2") = ENOTEMPTY rename("file", "dir") = EISDIR rename("dir", "file") = ENOTDIR

func (*Inode) ResetForUnmount

func (inode *Inode) ResetForUnmount()

ResetForUnmount resets the Inode as part of unmounting a storage backend mounted at the given inode. ACQUIRES_LOCK(inode.mu)

func (*Inode) RmDir

func (parent *Inode) RmDir(name string) (err error)

func (*Inode) SetFromBlobItem

func (inode *Inode) SetFromBlobItem(item *storage.BlobItemOutput)

func (*Inode) SetXattr

func (inode *Inode) SetXattr(name string, value []byte, flags uint32) error

func (*Inode) ToDir

func (inode *Inode) ToDir()
func (parent *Inode) Unlink(name string) (err error)

type InodeAttributes

type InodeAttributes struct {
	Size  uint64
	Mtime time.Time
}

func (InodeAttributes) Equal

func (i InodeAttributes) Equal(other InodeAttributes) bool

type MBuf

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

func (*MBuf) Close

func (mb *MBuf) Close() error

func (*MBuf) Free

func (mb *MBuf) Free()

func (*MBuf) Full

func (mb *MBuf) Full() bool

func (MBuf) Init

func (mb MBuf) Init(h *BufferPool, size uint64, block bool) *MBuf

func (*MBuf) Len

func (mb *MBuf) Len() (length int)

func (*MBuf) Read

func (mb *MBuf) Read(p []byte) (n int, err error)

func (*MBuf) Reset

func (mb *MBuf) Reset()

func (*MBuf) Seek

func (mb *MBuf) Seek(offset int64, whence int) (int64, error)

seek only seeks the reader

func (*MBuf) Write

func (mb *MBuf) Write(p []byte) (n int, err error)

func (*MBuf) WriteFrom

func (mb *MBuf) WriteFrom(r io.Reader) (n int, err error)

type Mount

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

type ReadBuffer

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

func (ReadBuffer) Init

func (b ReadBuffer) Init(fh *FileHandle, offset uint64, size uint32) *ReadBuffer

func (*ReadBuffer) Read

func (b *ReadBuffer) Read(offset uint64, p []byte) (n int, err error)

type ReaderProvider

type ReaderProvider func() (io.ReadCloser, error)

type Ticket

type Ticket struct {
	Total uint32
	// contains filtered or unexported fields
}

func (Ticket) Init

func (t Ticket) Init() *Ticket

func (*Ticket) Return

func (t *Ticket) Return(howmany uint32)

func (*Ticket) Take

func (t *Ticket) Take(howmany uint32, block bool) (took bool)

Jump to

Keyboard shortcuts

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