fuse

package
v0.0.0-...-7d00531 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2013 License: BSD-3-Clause Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
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)
)
View Source
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)
)
View Source
const (
	// The kernel caps writes at 128k.
	MAX_KERNEL_WRITE = 128 * 1024
)
View Source
const PAGESIZE = 4096

Variables

This section is empty.

Functions

func ModeToType

func ModeToType(mode uint32) uint32

func ToStatT

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

func VerboseTest

func VerboseTest() bool

VerboseTest returns true if the testing framework is run with -v.

func Version

func Version() string

Types

type Attr

type Attr raw.Attr

func ToAttr

func ToAttr(f os.FileInfo) *Attr

func (*Attr) AccessTime

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

func (*Attr) ChangeTime

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

func (*Attr) FromStat

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

func (*Attr) IsBlock

func (a *Attr) IsBlock() bool

IsBlock reports whether the FileInfo describes a block special file.

func (*Attr) IsChar

func (a *Attr) IsChar() bool

IsChar reports whether the FileInfo describes a character special file.

func (*Attr) IsDir

func (a *Attr) IsDir() bool

IsDir reports whether the FileInfo describes a directory.

func (*Attr) IsFifo

func (a *Attr) IsFifo() bool

func (*Attr) IsRegular

func (a *Attr) IsRegular() bool

IsRegular reports whether the FileInfo describes a regular file.

func (*Attr) IsSocket

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

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

func (*Attr) SetTimes

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

func (*Attr) String

func (a *Attr) String() string

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

type DirEntry struct {
	Mode uint32
	Name string
}

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) Add

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

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

func (FileMode) IsBlock

func (m FileMode) IsBlock() bool

IsBlock reports whether the FileInfo describes a block special file.

func (FileMode) IsChar

func (m FileMode) IsChar() bool

IsChar reports whether the FileInfo describes a character special file.

func (FileMode) IsDir

func (m FileMode) IsDir() bool

IsDir reports whether the FileInfo describes a directory.

func (FileMode) IsFifo

func (m FileMode) IsFifo() bool

func (FileMode) IsRegular

func (m FileMode) IsRegular() bool

IsRegular reports whether the FileInfo describes a regular file.

func (FileMode) IsSocket

func (m FileMode) IsSocket() bool

IsSocket reports whether the FileInfo describes a socket.

func (m FileMode) IsSymlink() bool

IsSymlink reports whether the FileInfo describes a symbolic link.

func (FileMode) String

func (me FileMode) String() string

type LatencyMap

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

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 Owner

type Owner raw.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(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) Bytes

func (r *ReadResultData) Bytes(buf []byte) ([]byte, Status)

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 (ms *Server) BufferPoolStats() string

func (*Server) KernelSettings

func (ms *Server) KernelSettings() raw.InitIn

func (*Server) MountPoint

func (ms *Server) MountPoint() string

func (*Server) RecordLatencies

func (ms *Server) RecordLatencies(l LatencyMap)

func (*Server) Serve

func (ms *Server) Serve()

Loop initiates the FUSE loop. Normally, callers should run Loop() 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

func (ms *Server) SetDebug(dbg bool)

func (*Server) Unmount

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

func (*Server) WaitMount

func (ms *Server) WaitMount()

Wait for the first request to be served. Use this to avoid racing between accessing the (empty) mountpoint, and the OS trying to setup the user-space mount.

type Status

type Status int32

func ToStatus

func ToStatus(err error) Status

Convert error back to Errno based errors.

func (Status) Ok

func (code Status) Ok() bool

func (Status) String

func (code Status) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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