go-fuse: github.com/hanwen/go-fuse/fuse Index | Files | Directories

package fuse

import "github.com/hanwen/go-fuse/fuse"

Package fuse provides APIs to implement filesystems in userspace in terms of raw FUSE protocol.

A filesystem is implemented by implementing its server that provides a RawFileSystem interface. Typically the server embeds NewDefaultRawFileSystem() and implements only subset of filesystem methods:

type MyFS struct {

func NewMyFS() *MyFS {
	return &MyFS{
		RawFileSystem: fuse.NewDefaultRawFileSystem(),

// Mkdir implements "mkdir" request handler.
// For other requests - not explicitly implemented by MyFS - ENOSYS
// will be typically returned to client.
func (fs *MyFS) Mkdir(...) {

Then the filesystem can be mounted and served to a client (typically OS kernel) by creating Server:

fs := NewMyFS() // implements RawFileSystem
fssrv, err := fuse.NewServer(fs, mountpoint, &fuse.MountOptions{...})
if err != nil {

and letting the server do its work:

// either synchronously - .Serve() blocks until the filesystem is unmounted.

// or in the background - .Serve() is spawned in another goroutine, but
// before interacting with fssrv from current context we have to wait
// until the filesystem mounting is complete.
go fssrv.Serve()
err = fssrv.WaitMount()
if err != nil {

The server will serve clients by dispatching their requests to the filesystem implementation and conveying responses back. For example "mkdir" FUSE request dispatches to call

fs.Mkdir(*MkdirIn, ..., *EntryOut)

"stat" to call

fs.GetAttr(*GetAttrIn, *AttrOut)

etc. Please refer to RawFileSystem documentation for details.

Typically, each call of the API happens in its own goroutine, so take care to make the file system thread-safe.

Higher level interfaces

As said above this packages provides way to implement filesystems in terms of raw FUSE protocol. Additionally packages nodefs and pathfs provide ways to implement filesystem at higher levels:

Package github.com/hanwen/go-fuse/fuse/nodefs provides way to implement filesystems in terms of inodes. This resembles kernel's idea of what a filesystem looks like.

Package github.com/hanwen/go-fuse/fuse/pathfs provides way to implement filesystems in terms of path names. Working with path names is somewhat easier compared to inodes, however renames can be racy. Do not use pathfs if you care about correctness.


Package 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 poll.go poll_linux.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


const (
    FUSE_ROOT_ID = 1

    FUSE_UNKNOWN_INO = 0xffffffff


    FUSE_LK_FLOCK = (1 << 0)




    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)

    // EACCESS Permission denied
    EACCES = Status(syscall.EACCES)

    // EBUSY Device or resource busy
    EBUSY = Status(syscall.EBUSY)

    // EAGAIN Resource temporarily unavailable
    EAGAIN = Status(syscall.EAGAIN)

    // EINVAL Invalid argument
    EINVAL = Status(syscall.EINVAL)

    // EIO I/O error
    EIO = Status(syscall.EIO)

    // ENOENT No such file or directory
    ENOENT = Status(syscall.ENOENT)

    // ENOSYS Function not implemented
    ENOSYS = Status(syscall.ENOSYS)

    // ENODATA No data available
    ENODATA = Status(syscall.ENODATA)

    // ENOTDIR Not a directory
    ENOTDIR = Status(syscall.ENOTDIR)

    // EISDIR Is a directory
    EISDIR = Status(syscall.EISDIR)

    // EPERM Operation not permitted
    EPERM = Status(syscall.EPERM)

    // ERANGE Math result not representable
    ERANGE = Status(syscall.ERANGE)

    // EXDEV Cross-device link
    EXDEV = Status(syscall.EXDEV)

    // EBADF Bad file number
    EBADF = Status(syscall.EBADF)

    // ENODEV No such device
    ENODEV = Status(syscall.ENODEV)

    // EROFS Read-only file system
    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)
    FATTR_CTIME     = (1 << 10)
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)
    CAP_ASYNC_DIO        = (1 << 15)
    CAP_WRITEBACK_CACHE  = (1 << 16)
    CAP_NO_OPEN_SUPPORT  = (1 << 17)
    CAP_PARALLEL_DIROPS  = (1 << 18)
    CAP_POSIX_ACL        = (1 << 19)
    CAP_HANDLE_KILLPRIV  = (1 << 20)

To be set in InitIn/InitOut.Flags.

const (
    FUSE_IOCTL_COMPAT       = (1 << 0)
    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 kernel that a poll waiting for IO on a file handle should wake up
    NOTIFY_INVAL_INODE    = -2 // notify kernel that an inode should be invalidated
    NOTIFY_INVAL_ENTRY    = -3 // notify kernel that a directory entry should be invalidated
    NOTIFY_STORE_CACHE    = -4 // store data into kernel cache of an inode
    NOTIFY_RETRIEVE_CACHE = -5 // retrieve data from kernel cache of an inode
    NOTIFY_DELETE         = -6 // notify kernel that a directory entry has been deleted

const (
    WRITE_CACHE     = (1 << 0)
    WRITE_LOCKOWNER = (1 << 1)
const (
    ENOATTR = Status(syscall.ENODATA) // On Linux, ENOATTR is an alias for ENODATA.

    // EREMOTEIO Remote I/O error
    EREMOTEIO = Status(syscall.EREMOTEIO)
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 (
    READ_LOCKOWNER = (1 << 1)
const RELEASE_FLUSH = (1 << 0)


var FuseOpenFlagNames map[int64]string
var OpenFlagNames map[int64]string

func FlagString Uses

func FlagString(names map[int64]string, fl int64, def string) string

func Print Uses

func Print(obj interface{}) string

Print pretty prints FUSE data types for kernel communication

func ToStatT Uses

func ToStatT(f os.FileInfo) *syscall.Stat_t

func UtimeToTimespec Uses

func UtimeToTimespec(t *time.Time) (ts syscall.Timespec)

UtimeToTimespec converts a "Time" pointer as passed to Utimens to a "Timespec" that can be passed to the utimensat syscall. A nil pointer is converted to the special UTIME_OMIT value.

type AccessIn Uses

type AccessIn struct {
    Mask    uint32
    Padding uint32

type Attr Uses

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
    Rdev    uint32
    Blksize uint32
    Padding uint32

func ToAttr Uses

func ToAttr(f os.FileInfo) *Attr

func (*Attr) AccessTime Uses

func (a *Attr) AccessTime() time.Time

func (*Attr) ChangeTime Uses

func (a *Attr) ChangeTime() time.Time

func (*Attr) FromStat Uses

func (a *Attr) FromStat(s *syscall.Stat_t)

func (*Attr) IsBlock Uses

func (a *Attr) IsBlock() bool

IsBlock reports whether the FileInfo describes a block special file.

func (*Attr) IsChar Uses

func (a *Attr) IsChar() bool

IsChar reports whether the FileInfo describes a character special file.

func (*Attr) IsDir Uses

func (a *Attr) IsDir() bool

IsDir reports whether the FileInfo describes a directory.

func (*Attr) IsFifo Uses

func (a *Attr) IsFifo() bool

func (*Attr) IsRegular Uses

func (a *Attr) IsRegular() bool

IsRegular reports whether the FileInfo describes a regular file.

func (*Attr) IsSocket Uses

func (a *Attr) IsSocket() bool

IsSocket reports whether the FileInfo describes a socket.

func (a *Attr) IsSymlink() bool

IsSymlink reports whether the FileInfo describes a symbolic link.

func (*Attr) ModTime Uses

func (a *Attr) ModTime() time.Time

func (*Attr) SetTimes Uses

func (a *Attr) SetTimes(access *time.Time, mod *time.Time, chstatus *time.Time)

func (*Attr) String Uses

func (a *Attr) String() string

type AttrOut Uses

type AttrOut struct {
    AttrValid     uint64
    AttrValidNsec uint32
    Dummy         uint32

type BufferPool Uses

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)

BufferPool implements explicit memory management. It is used for minimizing the GC overhead of communicating with the kernel.

func NewBufferPool Uses

func NewBufferPool() BufferPool

NewBufferPool returns a BufferPool implementation that that returns slices with capacity of a multiple of page size, 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 Uses

func NewGcBufferPool() BufferPool

NewGcBufferPool is a fallback to the standard allocation routines.

type Context Uses

type Context struct {
    Pid uint32

type CreateIn Uses

type CreateIn struct {
    Flags uint32

    // Mode for the new file; already takes Umask into account.
    Mode uint32

    // Umask used for this create call.
    Umask   uint32
    Padding uint32

type CreateOut Uses

type CreateOut struct {

type DirEntry Uses

type DirEntry struct {
    // Mode is the file's mode. Only the high bits (eg. S_IFDIR)
    // are considered.
    Mode uint32

    // Name is the basename of the file in the directory.
    Name string

    // Ino is the inode number.
    Ino uint64

DirEntry is a type for PathFileSystem and NodeFileSystem to return directory contents in.

func (DirEntry) String Uses

func (d DirEntry) String() string

type DirEntryList Uses

type DirEntryList struct {
    // contains filtered or unexported fields

DirEntryList holds the return value for READDIR and READDIRPLUS opcodes.

func NewDirEntryList Uses

func NewDirEntryList(data []byte, off uint64) *DirEntryList

NewDirEntryList creates a DirEntryList with the given data buffer and offset.

func (*DirEntryList) Add Uses

func (l *DirEntryList) Add(prefix int, name string, inode uint64, mode uint32) (bool, uint64)

Add adds a direntry to the DirEntryList, returning whether it succeeded.

func (*DirEntryList) AddDirEntry Uses

func (l *DirEntryList) AddDirEntry(e DirEntry) (bool, uint64)

AddDirEntry tries to add an entry, and reports whether it succeeded.

func (*DirEntryList) AddDirLookupEntry Uses

func (l *DirEntryList) AddDirLookupEntry(e DirEntry) (*EntryOut, uint64)

AddDirLookupEntry is used for ReadDirPlus. It serializes a DirEntry and returns the space for entry. If no space is left, returns a nil pointer.

type EntryOut Uses

type EntryOut struct {
    NodeId         uint64
    Generation     uint64
    EntryValid     uint64
    AttrValid      uint64
    EntryValidNsec uint32
    AttrValidNsec  uint32

type FallocateIn Uses

type FallocateIn struct {
    Fh      uint64
    Offset  uint64
    Length  uint64
    Mode    uint32
    Padding uint32

type FileLock Uses

type FileLock struct {
    Start uint64
    End   uint64
    Typ   uint32
    Pid   uint32

func (*FileLock) FromFlockT Uses

func (lk *FileLock) FromFlockT(flockT *syscall.Flock_t)

func (*FileLock) ToFlockT Uses

func (lk *FileLock) ToFlockT(flockT *syscall.Flock_t)

type FlushIn Uses

type FlushIn struct {
    Fh        uint64
    Unused    uint32
    Padding   uint32
    LockOwner uint64

type ForgetIn Uses

type ForgetIn struct {

    Nlookup uint64

type FsyncIn Uses

type FsyncIn struct {
    Fh         uint64
    FsyncFlags uint32
    Padding    uint32

type GetAttrIn Uses

type GetAttrIn struct {

    Flags_ uint32
    Dummy  uint32
    Fh_    uint64

func (*GetAttrIn) Fh Uses

func (g *GetAttrIn) Fh() uint64

Fh accesses the file handle. This is a method, because OSXFuse does not have GetAttrIn flags.

func (*GetAttrIn) Flags Uses

func (g *GetAttrIn) Flags() uint32

Flags accesses the flags. This is a method, because OSXFuse does not have GetAttrIn flags.

type GetXAttrIn Uses

type GetXAttrIn struct {
    Size    uint32
    Padding uint32

type GetXAttrOut Uses

type GetXAttrOut struct {
    Size    uint32
    Padding uint32

type InHeader Uses

type InHeader struct {
    Length uint32
    Opcode int32
    Unique uint64
    NodeId uint64
    Padding uint32

type InitIn Uses

type InitIn struct {

    Major        uint32
    Minor        uint32
    MaxReadAhead uint32
    Flags        uint32

func (*InitIn) SupportsNotify Uses

func (in *InitIn) SupportsNotify(notifyType int) bool

SupportsNotify returns whether a certain notification type is supported. Pass any of the NOTIFY_* types as argument.

func (*InitIn) SupportsVersion Uses

func (in *InitIn) SupportsVersion(maj, min uint32) bool

SupportsVersion returns true if the kernel supports the given protocol version or newer.

type InitOut Uses

type InitOut struct {
    Major               uint32
    Minor               uint32
    MaxReadAhead        uint32
    Flags               uint32
    MaxBackground       uint16
    CongestionThreshold uint16
    MaxWrite            uint32
    TimeGran            uint32
    Unused              [9]uint32

type InterruptIn Uses

type InterruptIn struct {
    Unique uint64

type LatencyMap Uses

type LatencyMap interface {
    Add(name string, dt time.Duration)

This type may be provided for recording latencies of each FUSE operation.

type LinkIn Uses

type LinkIn struct {
    Oldnodeid uint64

type LkIn Uses

type LkIn struct {
    Fh      uint64
    Owner   uint64
    Lk      FileLock
    LkFlags uint32
    Padding uint32

type LkOut Uses

type LkOut struct {
    Lk FileLock

type MkdirIn Uses

type MkdirIn struct {

    // The mode for the new directory. The calling process' umask
    // is already factored into the mode.
    Mode  uint32
    Umask uint32

type MknodIn Uses

type MknodIn struct {

    // Mode to use, including the Umask value
    Mode    uint32
    Rdev    uint32
    Umask   uint32
    Padding uint32

type MountOptions Uses

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

    // Max read ahead to use.  If 0, use default. This number is
    // capped at the kernel maximum.
    MaxReadAhead 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

    // Values shown in "df -T" and friends
    // First column, "Filesystem"
    FsName string

    // Second column, "Type", will be shown as "fuse." + Name
    Name string

    // If set, wrap the file system in a single-threaded locking wrapper.
    SingleThreaded bool

    // If set, return ENOSYS for Getxattr calls, so the kernel does not issue any
    // Xattr operations at all.
    DisableXAttrs bool

    // If set, print debugging information.
    Debug bool

    // If set, ask kernel to forward file locks to FUSE. If using,
    // you must implement the GetLk/SetLk/SetLkw methods.
    EnableLocks bool

type NotifyInvalDeleteOut Uses

type NotifyInvalDeleteOut struct {
    Parent  uint64
    Child   uint64
    NameLen uint32
    Padding uint32

type NotifyInvalEntryOut Uses

type NotifyInvalEntryOut struct {
    Parent  uint64
    NameLen uint32
    Padding uint32

type NotifyInvalInodeOut Uses

type NotifyInvalInodeOut struct {
    Ino    uint64
    Off    int64
    Length int64

type NotifyRetrieveIn Uses

type NotifyRetrieveIn struct {
    Dummy1 uint64
    Offset uint64
    Size   uint32
    Dummy2 uint32
    Dummy3 uint64
    Dummy4 uint64

type NotifyRetrieveOut Uses

type NotifyRetrieveOut struct {
    NotifyUnique uint64
    Nodeid       uint64
    Offset       uint64
    Size         uint32
    Padding      uint32

type NotifyStoreOut Uses

type NotifyStoreOut struct {
    Nodeid  uint64
    Offset  uint64
    Size    uint32
    Padding uint32

type OpenIn Uses

type OpenIn struct {
    Flags uint32
    Mode  uint32

type OpenOut Uses

type OpenOut struct {
    Fh        uint64
    OpenFlags uint32
    Padding   uint32

type OutHeader Uses

type OutHeader struct {
    Length uint32
    Status int32
    Unique uint64

type Owner Uses

type Owner struct {
    Uid uint32
    Gid uint32

func CurrentOwner Uses

func CurrentOwner() *Owner

type RawFileSystem Uses

type RawFileSystem interface {
    String() string

    // If called, provide debug output through the log package.
    SetDebug(debug bool)

    // Lookup is called by the kernel when the VFS wants to know
    // about a file inside a directory. Many lookup calls can
    // occur in parallel, but only one call happens for each (dir,
    // name) pair.
    Lookup(header *InHeader, name string, out *EntryOut) (status Status)

    // Forget is called when the kernel discards entries from its
    // dentry cache. This happens on unmount, and when the kernel
    // is short on memory. Since it is not guaranteed to occur at
    // any moment, and since there is no return value, Forget
    // should not do I/O, as there is no channel to report back
    // I/O errors.
    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)

    // File locking
    GetLk(input *LkIn, out *LkOut) (code Status)
    SetLk(input *LkIn) (code Status)
    SetLkw(input *LkIn) (code 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).

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 nodefs.Node or pathfs.FileSystem interfaces; the details of getting interactions with open files, renames, and threading right etc. are somewhat tricky and not very interesting.

Each FUSE request results in a corresponding method called by Server. Several calls may be made simultaneously, because the server typically calls each method in separate goroutine.

A null implementation is provided by NewDefaultRawFileSystem.

func NewDefaultRawFileSystem Uses

func NewDefaultRawFileSystem() RawFileSystem

NewDefaultRawFileSystem returns ENOSYS (not implemented) for all operations.

func NewLockingRawFileSystem Uses

func NewLockingRawFileSystem(fs RawFileSystem) RawFileSystem

Returns a Wrap

func NewRawFileSystem Uses

func NewRawFileSystem(fs interface{}) RawFileSystem

NewRawFileSystem adds the methods missing for implementing a RawFileSystem to any object.

type ReadIn Uses

type ReadIn struct {
    Fh        uint64
    Offset    uint64
    Size      uint32
    ReadFlags uint32
    LockOwner uint64
    Flags     uint32
    Padding   uint32

type ReadResult Uses

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.

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 Uses

func ReadResultData(b []byte) ReadResult

func ReadResultFd Uses

func ReadResultFd(fd uintptr, off int64, sz int) ReadResult

type ReleaseIn Uses

type ReleaseIn struct {
    Fh           uint64
    Flags        uint32
    ReleaseFlags uint32
    LockOwner    uint64

type Rename2In Uses

type Rename2In struct {
    Newdir  uint64
    Flags   uint32
    Padding uint32

type RenameIn Uses

type RenameIn struct {
    Newdir uint64

type Server Uses

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 Uses

func NewServer(fs RawFileSystem, mountPoint string, opts *MountOptions) (*Server, error)

NewServer creates a server and attaches it to the given directory.

func (*Server) DebugData Uses

func (ms *Server) DebugData() string

DebugData returns internal status information for debugging purposes.

func (*Server) DeleteNotify Uses

func (ms *Server) DeleteNotify(parent uint64, child uint64, name string) Status

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. You should not hold any FUSE filesystem locks, as that can lead to deadlock.

func (*Server) EntryNotify Uses

func (ms *Server) EntryNotify(parent uint64, name string) Status

EntryNotify should be used if the existence status of an entry within a directory changes. You should not hold any FUSE filesystem locks, as that can lead to deadlock.

func (*Server) InodeNotify Uses

func (ms *Server) InodeNotify(node uint64, off int64, length int64) Status

InodeNotify invalidates the information associated with the inode (ie. data cache, attributes, etc.)

func (*Server) InodeNotifyStoreCache Uses

func (ms *Server) InodeNotifyStoreCache(node uint64, offset int64, data []byte) Status

InodeNotifyStoreCache tells kernel to store data into inode's cache.

This call is similar to InodeNotify, but instead of only invalidating a data region, it gives updated data directly to the kernel.

func (*Server) InodeRetrieveCache Uses

func (ms *Server) InodeRetrieveCache(node uint64, offset int64, dest []byte) (n int, st Status)

InodeRetrieveCache retrieves data from kernel's inode cache.

InodeRetrieveCache asks kernel to return data from its cache for inode at [offset:offset+len(dest)) and waits for corresponding reply. If kernel cache has fewer consecutive data starting at offset, that fewer amount is returned. In particular if inode data at offset is not cached (0, OK) is returned.

The kernel returns ENOENT if it does not currently have entry for this inode in its dentry cache.

func (*Server) KernelSettings Uses

func (ms *Server) KernelSettings() *InitIn

KernelSettings returns the Init message from the kernel, so filesystems can adapt to availability of features of the kernel driver. The message should not be altered.

func (*Server) RecordLatencies Uses

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 Uses

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.

func (*Server) SetDebug Uses

func (ms *Server) SetDebug(dbg bool)

SetDebug is deprecated. Use MountOptions.Debug instead.

func (*Server) Unmount Uses

func (ms *Server) Unmount() (err error)

Unmount calls fusermount -u on the mount. This has the effect of shutting down the filesystem. After the Server is unmounted, it should be discarded.

func (*Server) WaitMount Uses

func (ms *Server) WaitMount() error

WaitMount waits for the first request to be served. Use this to avoid racing between accessing the (empty or not yet mounted) mountpoint, and the OS trying to setup the user-space mount.

type SetAttrIn Uses

type SetAttrIn struct {

type SetAttrInCommon Uses

type SetAttrInCommon struct {

    Valid     uint32
    Padding   uint32
    Fh        uint64
    Size      uint64
    LockOwner uint64
    Atime     uint64
    Mtime     uint64
    Ctime     uint64
    Atimensec uint32
    Mtimensec uint32
    Ctimensec uint32
    Mode      uint32
    Unused4   uint32
    Unused5 uint32

type SetXAttrIn Uses

type SetXAttrIn struct {
    Size  uint32
    Flags uint32

type StatfsOut Uses

type StatfsOut struct {
    Blocks  uint64
    Bfree   uint64
    Bavail  uint64
    Files   uint64
    Ffree   uint64
    Bsize   uint32
    NameLen uint32
    Frsize  uint32
    Padding uint32
    Spare   [6]uint32

func (*StatfsOut) FromStatfsT Uses

func (s *StatfsOut) FromStatfsT(statfs *syscall.Statfs_t)

type Status Uses

type Status int32

Status is the errno number that a FUSE call returns to the kernel.

func ToStatus Uses

func ToStatus(err error) Status

ToStatus extracts an errno number from Go error objects. If it fails, it logs an error and returns ENOSYS.

func (Status) Ok Uses

func (code Status) Ok() bool

func (Status) String Uses

func (code Status) String() string

type WriteIn Uses

type WriteIn struct {
    Fh         uint64
    Offset     uint64
    Size       uint32
    WriteFlags uint32
    LockOwner  uint64
    Flags      uint32
    Padding    uint32

type WriteOut Uses

type WriteOut struct {
    Size    uint32
    Padding uint32


nodefsThe nodefs package offers a high level API that resembles the kernel's idea of what an FS looks like.

Package fuse imports 18 packages (graph) and is imported by 255 packages. Updated 2018-12-18. Refresh now. Tools for package owners.