Documentation
¶
Index ¶
- Constants
- func ModeToType(mode uint32) uint32
- func ToStatT(f os.FileInfo) *syscall.Stat_t
- func VerboseTest() bool
- func Version() string
- 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 BufferPool
- type Context
- type DirEntry
- type DirEntryList
- type FileMode
- type LatencyMap
- type MountOptions
- type Owner
- type RawFileSystem
- type RawFsInit
- type ReadResult
- type ReadResultData
- type ReadResultFd
- type Server
- func (ms *Server) BufferPoolStats() string
- func (ms *Server) KernelSettings() raw.InitIn
- func (ms *Server) MountPoint() string
- 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 Status
Constants ¶
const ( S_IFDIR = syscall.S_IFDIR S_IFREG = syscall.S_IFREG S_IFLNK = syscall.S_IFLNK S_IFIFO = syscall.S_IFIFO 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) EINTR = Status(syscall.EINTR) EAGAIN = Status(syscall.EAGAIN) )
const (
// The kernel caps writes at 128k.
MAX_KERNEL_WRITE = 128 * 1024
)
const PAGESIZE = 4096
Variables ¶
This section is empty.
Functions ¶
func ModeToType ¶
func VerboseTest ¶
func VerboseTest() bool
VerboseTest returns true if the testing framework is run with -v.
Types ¶
type Attr ¶
func (*Attr) AccessTime ¶
func (*Attr) ChangeTime ¶
type BufferPool ¶
type BufferPool interface { AllocBuffer(size uint32) []byte FreeBuffer(slice []byte) String() string }
func NewBufferPool ¶
func NewBufferPool() BufferPool
func NewGcBufferPool ¶
func NewGcBufferPool() BufferPool
NewGcBufferPool is just a fallback to the standard allocation routines.
type Context ¶
type Context struct { NodeId uint64 Interrupted chan struct{} // This channel is closed if the request is interrupted *raw.Context }
Context contains assorted per-request data
type DirEntry ¶
DirEntry is a type for PathFileSystem and NodeFileSystem to return directory contents in.
type DirEntryList ¶
type DirEntryList struct { // TODO - hide this again. Offset uint64 // contains filtered or unexported fields }
func NewDirEntryList ¶
func NewDirEntryList(data []byte, off uint64) *DirEntryList
func (*DirEntryList) AddDirEntry ¶
func (l *DirEntryList) AddDirEntry(e DirEntry) bool
AddDirEntry tries to add an entry.
func (*DirEntryList) Bytes ¶
func (l *DirEntryList) Bytes() []byte
type FileMode ¶
type FileMode uint32
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 }
type RawFileSystem ¶
type RawFileSystem interface { String() string // If called, provide debug output through the log package. SetDebug(debug bool) Lookup(out *raw.EntryOut, context *Context, name string) (status Status) Forget(nodeid, nlookup uint64) // Attributes. GetAttr(out *raw.AttrOut, context *Context, input *raw.GetAttrIn) (code Status) SetAttr(out *raw.AttrOut, context *Context, input *raw.SetAttrIn) (code Status) // Modifying structure. Mknod(out *raw.EntryOut, context *Context, input *raw.MknodIn, name string) (code Status) Mkdir(out *raw.EntryOut, context *Context, input *raw.MkdirIn, name string) (code Status) Unlink(context *Context, name string) (code Status) Rmdir(context *Context, name string) (code Status) Rename(context *Context, input *raw.RenameIn, oldName string, newName string) (code Status) Link(out *raw.EntryOut, context *Context, input *raw.LinkIn, filename string) (code Status) Symlink(out *raw.EntryOut, context *Context, pointedTo string, linkName string) (code Status) Readlink(context *Context) (out []byte, code Status) Access(context *Context, input *raw.AccessIn) (code Status) // Extended attributes. GetXAttrSize(context *Context, attr string) (sz int, code Status) GetXAttrData(context *Context, attr string) (data []byte, code Status) ListXAttr(context *Context) (attributes []byte, code Status) SetXAttr(context *Context, input *raw.SetXAttrIn, attr string, data []byte) Status RemoveXAttr(context *Context, attr string) (code Status) // File handling. Create(out *raw.CreateOut, context *Context, input *raw.CreateIn, name string) (code Status) Open(out *raw.OpenOut, context *Context, input *raw.OpenIn) (status Status) Read(*Context, *raw.ReadIn, []byte) (ReadResult, Status) Release(context *Context, input *raw.ReleaseIn) Write(*Context, *raw.WriteIn, []byte) (written uint32, code Status) Flush(context *Context, input *raw.FlushIn) Status Fsync(*Context, *raw.FsyncIn) (code Status) Fallocate(Context *Context, in *raw.FallocateIn) (code Status) // Directory handling OpenDir(out *raw.OpenOut, context *Context, input *raw.OpenIn) (status Status) ReadDir(out *DirEntryList, context *Context, input *raw.ReadIn) Status ReleaseDir(context *Context, input *raw.ReleaseIn) FsyncDir(context *Context, input *raw.FsyncIn) (code Status) // StatFs(out *raw.StatfsOut, context *Context) (code Status) // Provide callbacks for pushing notifications to the kernel. Init(params *RawFsInit) }
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
type RawFsInit ¶
type RawFsInit struct { InodeNotify func(*raw.NotifyInvalInodeOut) Status EntryNotify func(parent uint64, name string) Status DeleteNotify func(parent uint64, child uint64, name string) Status }
Talk back to FUSE.
InodeNotify invalidates the information associated with the inode (ie. data cache, attributes, etc.)
EntryNotify should be used if the existence status of an entry changes, (ie. to notify of creation or deletion of the file).
Somewhat confusingly, InodeNotify for a file that stopped to exist will give the correct result for Lstat (ENOENT), but the kernel will still issue file Open() on the inode.
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.
type ReadResultData ¶
type ReadResultData struct { // Raw bytes for the read. Data []byte }
ReadResultData is the read return for returning bytes directly.
func (*ReadResultData) Done ¶
func (r *ReadResultData) Done()
func (*ReadResultData) Size ¶
func (r *ReadResultData) Size() int
type ReadResultFd ¶
type ReadResultFd struct { // Splice from the following file. Fd uintptr // Offset within Fd, or -1 to use current offset. Off int64 // Size of data to be loaded. Actual data available may be // less at the EOF. Sz int }
ReadResultFd is the read return for zero-copy file data.
func (*ReadResultFd) Bytes ¶
func (r *ReadResultFd) Bytes(buf []byte) ([]byte, Status)
Reads raw bytes from file descriptor if necessary, using the passed buffer as storage.
func (*ReadResultFd) Done ¶
func (r *ReadResultFd) Done()
func (*ReadResultFd) Size ¶
func (r *ReadResultFd) Size() int
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) BufferPoolStats ¶
func (*Server) KernelSettings ¶
func (*Server) MountPoint ¶
func (*Server) RecordLatencies ¶
func (ms *Server) RecordLatencies(l LatencyMap)