Documentation ¶
Index ¶
- Constants
- Variables
- func FlagString(names map[int64]string, fl int64, def string) string
- func Print(obj interface{}) string
- func ToStatT(f os.FileInfo) *syscall.Stat_t
- type AccessIn
- type Attr
- func (a *Attr) AccessTime() time.Time
- func (a *Attr) ChangeTime() time.Time
- func (a *Attr) FromStat(s *syscall.Stat_t)
- func (a *Attr) IsBlock() bool
- func (a *Attr) IsChar() bool
- func (a *Attr) IsDir() bool
- func (a *Attr) IsFifo() bool
- func (a *Attr) IsRegular() bool
- func (a *Attr) IsSocket() bool
- func (a *Attr) IsSymlink() bool
- func (a *Attr) ModTime() time.Time
- func (a *Attr) SetTimes(access *time.Time, mod *time.Time, chstatus *time.Time)
- func (a *Attr) String() string
- type AttrOut
- type BufferPool
- type Context
- type CreateIn
- type CreateOut
- type DirEntry
- type DirEntryList
- type EntryOut
- type FallocateIn
- type FlushIn
- type ForgetIn
- type FsyncIn
- type GetAttrIn
- type GetXAttrIn
- type GetXAttrOut
- type InHeader
- type InitIn
- type InitOut
- type InterruptIn
- type LatencyMap
- type LinkIn
- type MkdirIn
- type MknodIn
- type MountOptions
- type NotifyInvalDeleteOut
- type NotifyInvalEntryOut
- type NotifyInvalInodeOut
- type OpenIn
- type OpenOut
- type OutHeader
- type Owner
- type RawFileSystem
- type ReadIn
- type ReadResult
- type ReleaseIn
- type RenameIn
- type Server
- func (ms *Server) DebugData() string
- func (ms *Server) DeleteNotify(parent uint64, child uint64, name string) Status
- func (ms *Server) EntryNotify(parent uint64, name string) Status
- func (ms *Server) InodeNotify(node uint64, off int64, length int64) Status
- func (ms *Server) KernelSettings() InitIn
- func (ms *Server) RecordLatencies(l LatencyMap)
- func (ms *Server) Serve()
- func (ms *Server) SetDebug(dbg bool)
- func (ms *Server) Unmount() (err error)
- func (ms *Server) WaitMount()
- type SetAttrIn
- type SetAttrInCommon
- type SetXAttrIn
- type StatfsOut
- type Status
- type WriteIn
- type WriteOut
Constants ¶
const ( FUSE_ROOT_ID = 1 FUSE_UNKNOWN_INO = 0xffffffff CUSE_UNRESTRICTED_IOCTL = (1 << 0) FUSE_LK_FLOCK = (1 << 0) FUSE_IOCTL_MAX_IOV = 256 FUSE_POLL_SCHEDULE_NOTIFY = (1 << 0) CUSE_INIT_INFO_MAX = 4096 S_IFDIR = syscall.S_IFDIR S_IFREG = syscall.S_IFREG S_IFLNK = syscall.S_IFLNK S_IFIFO = syscall.S_IFIFO CUSE_INIT = 4096 O_ANYWRITE = uint32(os.O_WRONLY | os.O_RDWR | os.O_APPEND | os.O_CREATE | os.O_TRUNC) )
const ( OK = Status(0) EACCES = Status(syscall.EACCES) EBUSY = Status(syscall.EBUSY) EINVAL = Status(syscall.EINVAL) EIO = Status(syscall.EIO) ENOENT = Status(syscall.ENOENT) ENOSYS = Status(syscall.ENOSYS) ENODATA = Status(syscall.ENODATA) ENOTDIR = Status(syscall.ENOTDIR) EPERM = Status(syscall.EPERM) ERANGE = Status(syscall.ERANGE) EXDEV = Status(syscall.EXDEV) EBADF = Status(syscall.EBADF) ENODEV = Status(syscall.ENODEV) EROFS = Status(syscall.EROFS) )
const ( FATTR_MODE = (1 << 0) FATTR_UID = (1 << 1) FATTR_GID = (1 << 2) FATTR_SIZE = (1 << 3) FATTR_ATIME = (1 << 4) FATTR_MTIME = (1 << 5) FATTR_FH = (1 << 6) FATTR_ATIME_NOW = (1 << 7) FATTR_MTIME_NOW = (1 << 8) FATTR_LOCKOWNER = (1 << 9) )
const ( // OpenOut.Flags FOPEN_DIRECT_IO = (1 << 0) FOPEN_KEEP_CACHE = (1 << 1) FOPEN_NONSEEKABLE = (1 << 2) )
const ( CAP_ASYNC_READ = (1 << 0) CAP_POSIX_LOCKS = (1 << 1) CAP_FILE_OPS = (1 << 2) CAP_ATOMIC_O_TRUNC = (1 << 3) CAP_EXPORT_SUPPORT = (1 << 4) CAP_BIG_WRITES = (1 << 5) CAP_DONT_MASK = (1 << 6) CAP_SPLICE_WRITE = (1 << 7) CAP_SPLICE_MOVE = (1 << 8) CAP_SPLICE_READ = (1 << 9) CAP_FLOCK_LOCKS = (1 << 10) CAP_IOCTL_DIR = (1 << 11) CAP_AUTO_INVAL_DATA = (1 << 12) CAP_READDIRPLUS = (1 << 13) CAP_READDIRPLUS_AUTO = (1 << 14) )
To be set in InitIn/InitOut.Flags.
const ( FUSE_IOCTL_COMPAT = (1 << 0) FUSE_IOCTL_UNRESTRICTED = (1 << 1) FUSE_IOCTL_RETRY = (1 << 2) )
const ( X_OK = 1 W_OK = 2 R_OK = 4 F_OK = 0 )
For AccessIn.Mask.
const ( NOTIFY_POLL = -1 NOTIFY_INVAL_INODE = -2 NOTIFY_INVAL_ENTRY = -3 NOTIFY_STORE = -4 NOTIFY_RETRIEVE = -5 NOTIFY_INVAL_DELETE = -6 NOTIFY_CODE_MAX = -6 )
const ( WRITE_CACHE = (1 << 0) WRITE_LOCKOWNER = (1 << 1) )
const (
// Mask for GetAttrIn.Flags. If set, GetAttrIn has a file handle set.
FUSE_GETATTR_FH = (1 << 0)
)
const (
// The kernel caps writes at 128k.
MAX_KERNEL_WRITE = 128 * 1024
)
const PAGESIZE = 4096
const (
READ_LOCKOWNER = (1 << 1)
)
const RELEASE_FLUSH = (1 << 0)
Variables ¶
var FuseOpenFlagNames map[int64]string
var OpenFlagNames map[int64]string
Functions ¶
Types ¶
type Attr ¶
type Attr struct { Ino uint64 Size uint64 Blocks uint64 Atime uint64 Mtime uint64 Ctime uint64 Atimensec uint32 Mtimensec uint32 Ctimensec uint32 Mode uint32 Nlink uint32 Owner Rdev uint32 Blksize uint32 Padding uint32 }
func (*Attr) AccessTime ¶
func (*Attr) ChangeTime ¶
type BufferPool ¶
type BufferPool interface { // AllocBuffer creates a buffer of at least the given size. After use, // it should be deallocated with FreeBuffer(). AllocBuffer(size uint32) []byte // FreeBuffer takes back a buffer if it was allocated through // AllocBuffer. It is not an error to call FreeBuffer() on a slice // obtained elsewhere. FreeBuffer(slice []byte) // Return debug information. String() string }
BufferPool implements explicit memory management. It is used for minimizing the GC overhead of communicating with the kernel.
func NewBufferPool ¶
func NewBufferPool() BufferPool
NewBufferPool returns a BufferPool implementation that that returns slices with capacity of a multiple of PAGESIZE, which have possibly been used, and may contain random contents. When using NewBufferPool, file system handlers may not hang on to passed-in buffers beyond the handler's return.
func NewGcBufferPool ¶
func NewGcBufferPool() BufferPool
NewGcBufferPool is a fallback to the standard allocation routines.
type DirEntry ¶
DirEntry is a type for PathFileSystem and NodeFileSystem to return directory contents in.
type DirEntryList ¶
type DirEntryList struct {
// contains filtered or unexported fields
}
DirEntryList holds the return value for READDIR and READDIRPLUS opcodes.
func NewDirEntryList ¶
func NewDirEntryList(data []byte, off uint64) *DirEntryList
NewDirEntryList creates a DirEntryList with the given data buffer and offset.
func (*DirEntryList) AddDirEntry ¶
func (l *DirEntryList) AddDirEntry(e DirEntry) (bool, uint64)
AddDirEntry tries to add an entry, and reports whether it succeeded.
func (*DirEntryList) AddDirLookupEntry ¶
func (l *DirEntryList) AddDirLookupEntry(e DirEntry, entryOut *EntryOut) (bool, uint64)
AddDirLookupEntry is used for ReadDirPlus. It serializes a DirEntry and its corresponding lookup. Pass a zero entryOut if the lookup data should be ignored.
type FallocateIn ¶
type GetAttrIn ¶
type GetXAttrIn ¶
type GetXAttrOut ¶
type InterruptIn ¶
type LatencyMap ¶
This type may be provided for recording latencies of each FUSE operation.
type MountOptions ¶
type MountOptions struct { AllowOther bool // Options are passed as -o string to fusermount. Options []string // Default is _DEFAULT_BACKGROUND_TASKS, 12. This numbers // controls the allowed number of requests that relate to // async I/O. Concurrency for synchronous I/O is not limited. MaxBackground int // Write size to use. If 0, use default. This number is // capped at the kernel maximum. MaxWrite int // If IgnoreSecurityLabels is set, all security related xattr // requests will return NO_DATA without passing through the // user defined filesystem. You should only set this if you // file system implements extended attributes, and you are not // interested in security labels. IgnoreSecurityLabels bool // ignoring labels should be provided as a fusermount mount option. // If given, use this buffer pool instead of the global one. Buffers BufferPool // If RememberInodes is set, we will never forget inodes. // This may be useful for NFS. RememberInodes bool // The name will show up on the output of the mount. Keep this string // small. Name string // If set, wrap the file system in a single-threaded locking wrapper. SingleThreaded bool }
type NotifyInvalDeleteOut ¶
type NotifyInvalEntryOut ¶
type NotifyInvalInodeOut ¶
type Owner ¶
func CurrentOwner ¶
func CurrentOwner() *Owner
type RawFileSystem ¶
type RawFileSystem interface { String() string // If called, provide debug output through the log package. SetDebug(debug bool) Lookup(header *InHeader, name string, out *EntryOut) (status Status) Forget(nodeid, nlookup uint64) // Attributes. GetAttr(input *GetAttrIn, out *AttrOut) (code Status) SetAttr(input *SetAttrIn, out *AttrOut) (code Status) // Modifying structure. Mknod(input *MknodIn, name string, out *EntryOut) (code Status) Mkdir(input *MkdirIn, name string, out *EntryOut) (code Status) Unlink(header *InHeader, name string) (code Status) Rmdir(header *InHeader, name string) (code Status) Rename(input *RenameIn, oldName string, newName string) (code Status) Link(input *LinkIn, filename string, out *EntryOut) (code Status) Symlink(header *InHeader, pointedTo string, linkName string, out *EntryOut) (code Status) Readlink(header *InHeader) (out []byte, code Status) Access(input *AccessIn) (code Status) // Extended attributes. GetXAttrSize(header *InHeader, attr string) (sz int, code Status) GetXAttrData(header *InHeader, attr string) (data []byte, code Status) ListXAttr(header *InHeader) (attributes []byte, code Status) SetXAttr(input *SetXAttrIn, attr string, data []byte) Status RemoveXAttr(header *InHeader, attr string) (code Status) // File handling. Create(input *CreateIn, name string, out *CreateOut) (code Status) Open(input *OpenIn, out *OpenOut) (status Status) Read(input *ReadIn, buf []byte) (ReadResult, Status) Release(input *ReleaseIn) Write(input *WriteIn, data []byte) (written uint32, code Status) Flush(input *FlushIn) Status Fsync(input *FsyncIn) (code Status) Fallocate(input *FallocateIn) (code Status) // Directory handling OpenDir(input *OpenIn, out *OpenOut) (status Status) ReadDir(input *ReadIn, out *DirEntryList) Status ReadDirPlus(input *ReadIn, out *DirEntryList) Status ReleaseDir(input *ReleaseIn) FsyncDir(input *FsyncIn) (code Status) // StatFs(input *InHeader, out *StatfsOut) (code Status) // This is called on processing the first request. The // filesystem implementation can use the server argument to // talk back to the kernel (through notify methods). Init(*Server) }
RawFileSystem is an interface close to the FUSE wire protocol.
Unless you really know what you are doing, you should not implement this, but rather the FileSystem interface; the details of getting interactions with open files, renames, and threading right etc. are somewhat tricky and not very interesting.
A null implementation is provided by NewDefaultRawFileSystem.
func NewDefaultRawFileSystem ¶
func NewDefaultRawFileSystem() RawFileSystem
NewDefaultRawFileSystem returns ENOSYS (not implemented) for all operations.
func NewLockingRawFileSystem ¶
func NewLockingRawFileSystem(fs RawFileSystem) RawFileSystem
Returns a Wrap
func NewRawFileSystem ¶
func NewRawFileSystem(fs interface{}) RawFileSystem
NewRawFileSystem adds the methods missing for implementing a RawFileSystem to any object.
type ReadResult ¶
type ReadResult interface { // Returns the raw bytes for the read, possibly using the // passed buffer. The buffer should be larger than the return // value from Size. Bytes(buf []byte) ([]byte, Status) // Size returns how many bytes this return value takes at most. Size() int // Done() is called after sending the data to the kernel. Done() }
The result of Read is an array of bytes, but for performance reasons, we can also return data as a file-descriptor/offset/size tuple. If the backing store for a file is another filesystem, this reduces the amount of copying between the kernel and the FUSE server. The ReadResult interface captures both cases.
func ReadResultData ¶
func ReadResultData(b []byte) ReadResult
func ReadResultFd ¶
func ReadResultFd(fd uintptr, off int64, sz int) ReadResult
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server contains the logic for reading from the FUSE device and translating it to RawFileSystem interface calls.
func NewServer ¶
func NewServer(fs RawFileSystem, mountPoint string, opts *MountOptions) (*Server, error)
NewServer creates a server and attaches it to the given directory.
func (*Server) DeleteNotify ¶
DeleteNotify notifies the kernel that an entry is removed from a directory. In many cases, this is equivalent to EntryNotify, except when the directory is in use, eg. as working directory of some process.
func (*Server) EntryNotify ¶
EntryNotify should be used if the existence status of an entry within a directory changes.
func (*Server) InodeNotify ¶
InodeNotify invalidates the information associated with the inode (ie. data cache, attributes, etc.)
func (*Server) KernelSettings ¶
KernelSettings returns the Init message from the kernel, so filesystems can adapt to availability of features of the kernel driver.
func (*Server) RecordLatencies ¶
func (ms *Server) RecordLatencies(l LatencyMap)
RecordLatencies switches on collection of timing for each request coming from the kernel.P assing a nil argument switches off the
func (*Server) Serve ¶
func (ms *Server) Serve()
Serve initiates the FUSE loop. Normally, callers should run Serve() and wait for it to exit, but tests will want to run this in a goroutine.
Each filesystem operation executes in a separate goroutine.
type SetAttrIn ¶
type SetAttrIn struct {
SetAttrInCommon
}
type SetAttrInCommon ¶
type SetXAttrIn ¶
type Status ¶
type Status int32
Status is the errno number that a FUSE call returns to the kernel.
Source Files ¶
- api.go
- attr.go
- attr_linux.go
- bufferpool.go
- constants.go
- constants_linux.go
- defaultraw.go
- direntry.go
- lockingfs.go
- misc.go
- mount_linux.go
- opcode.go
- print.go
- print_linux.go
- read.go
- request.go
- request_linux.go
- server.go
- server_linux.go
- splice_linux.go
- syscall_linux.go
- typeprint.go
- types.go
- types_linux.go
- upgrade.go