Documentation
¶
Index ¶
- func CopyFile(srcFs, destFs FileSystem, srcFile, destFile string, context *fuse.Context) fuse.Status
- type FileSystem
- type PathNodeFs
- func (fs *PathNodeFs) AllFiles(name string, mask uint32) []nodefs.WithFlags
- func (fs *PathNodeFs) Connector() *nodefs.FileSystemConnector
- func (fs *PathNodeFs) EntryNotify(dir string, name string) fuse.Status
- func (fs *PathNodeFs) FileNotify(path string, off int64, length int64) fuse.Status
- func (fs *PathNodeFs) ForgetClientInodes()
- func (fs *PathNodeFs) LastNode(name string) (*nodefs.Inode, []string)
- func (fs *PathNodeFs) LookupNode(name string) *nodefs.Inode
- func (fs *PathNodeFs) Mount(path string, root nodefs.Node, opts *nodefs.Options) fuse.Status
- func (fs *PathNodeFs) Node(name string) *nodefs.Inode
- func (fs *PathNodeFs) Notify(path string) fuse.Status
- func (fs *PathNodeFs) Path(node *nodefs.Inode) string
- func (fs *PathNodeFs) RereadClientInodes()
- func (fs *PathNodeFs) Root() nodefs.Node
- func (fs *PathNodeFs) SetDebug(dbg bool)
- func (fs *PathNodeFs) String() string
- func (fs *PathNodeFs) Unmount(path string) fuse.Status
- func (fs *PathNodeFs) UnmountNode(node *nodefs.Inode) fuse.Status
- type PathNodeFsOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type FileSystem ¶
type FileSystem interface {
// Used for pretty printing.
String() string
// If called, provide debug output through the log package.
SetDebug(debug bool)
// Attributes. This function is the main entry point, through
// which FUSE discovers which files and directories exist.
//
// If the filesystem wants to implement hard-links, it should
// return consistent non-zero FileInfo.Ino data. Using
// hardlinks incurs a performance hit.
GetAttr(name string, context *fuse.Context) (*fuse.Attr, fuse.Status)
// These should update the file's ctime too.
Chmod(name string, mode uint32, context *fuse.Context) (code fuse.Status)
Chown(name string, uid uint32, gid uint32, context *fuse.Context) (code fuse.Status)
Utimens(name string, Atime *time.Time, Mtime *time.Time, context *fuse.Context) (code fuse.Status)
Truncate(name string, size uint64, context *fuse.Context) (code fuse.Status)
Access(name string, mode uint32, context *fuse.Context) (code fuse.Status)
// Tree structure
Link(oldName string, newName string, context *fuse.Context) (code fuse.Status)
Mkdir(name string, mode uint32, context *fuse.Context) fuse.Status
Mknod(name string, mode uint32, dev uint32, context *fuse.Context) fuse.Status
Rename(oldName string, newName string, context *fuse.Context) (code fuse.Status)
Rmdir(name string, context *fuse.Context) (code fuse.Status)
Unlink(name string, context *fuse.Context) (code fuse.Status)
// Extended attributes.
GetXAttr(name string, attribute string, context *fuse.Context) (data []byte, code fuse.Status)
ListXAttr(name string, context *fuse.Context) (attributes []string, code fuse.Status)
RemoveXAttr(name string, attr string, context *fuse.Context) fuse.Status
SetXAttr(name string, attr string, data []byte, flags int, context *fuse.Context) fuse.Status
// Called after mount.
OnMount(nodeFs *PathNodeFs)
OnUnmount()
// File handling. If opening for writing, the file's mtime
// should be updated too.
Open(name string, flags uint32, context *fuse.Context) (file nodefs.File, code fuse.Status)
Create(name string, flags uint32, mode uint32, context *fuse.Context) (file nodefs.File, code fuse.Status)
// Directory handling
OpenDir(name string, context *fuse.Context) (stream []fuse.DirEntry, code fuse.Status)
// Symlinks.
Symlink(value string, linkName string, context *fuse.Context) (code fuse.Status)
Readlink(name string, context *fuse.Context) (string, fuse.Status)
StatFs(name string) *fuse.StatfsOut
}
A filesystem API that uses paths rather than inodes. A minimal file system should have at least a functional GetAttr method. Typically, each call happens in its own goroutine, so take care to make the file system thread-safe.
NewDefaultFileSystem provides a null implementation of required methods.
func NewDefaultFileSystem ¶
func NewDefaultFileSystem() FileSystem
NewDefaultFileSystem creates a filesystem that responds ENOSYS for all methods
func NewLockingFileSystem ¶
func NewLockingFileSystem(pfs FileSystem) FileSystem
NewLockingFileSystem is a wrapper that makes a FileSystem threadsafe by serializing each operation.
func NewLoopbackFileSystem ¶
func NewLoopbackFileSystem(root string) FileSystem
A FUSE filesystem that shunts all request to an underlying file system. Its main purpose is to provide test coverage without having to build a synthetic filesystem.
func NewPrefixFileSystem ¶
func NewPrefixFileSystem(fs FileSystem, prefix string) FileSystem
func NewReadonlyFileSystem ¶
func NewReadonlyFileSystem(fs FileSystem) FileSystem
NewReadonlyFileSystem returns a wrapper that only exposes read-only operations.
type PathNodeFs ¶
type PathNodeFs struct {
// contains filtered or unexported fields
}
PathNodeFs is the file system that can translate an inode back to a path. The path name is then used to call into an object that has the FileSystem interface.
Lookups (ie. FileSystem.GetAttr) may return a inode number in its return value. The inode number ("clientInode") is used to indicate linked files. The clientInode is never exported back to the kernel; it is only used to maintain a list of all names of an inode.
func NewPathNodeFs ¶
func NewPathNodeFs(fs FileSystem, opts *PathNodeFsOptions) *PathNodeFs
NewPathNodeFs returns a file system that translates from inodes to path names.
func (*PathNodeFs) AllFiles ¶
func (fs *PathNodeFs) AllFiles(name string, mask uint32) []nodefs.WithFlags
AllFiles returns all open files for the inode corresponding with the given mask.
func (*PathNodeFs) Connector ¶
func (fs *PathNodeFs) Connector() *nodefs.FileSystemConnector
Connector returns the FileSystemConnector (the bridge to the raw protocol) for this PathNodeFs.
func (*PathNodeFs) EntryNotify ¶
func (fs *PathNodeFs) EntryNotify(dir string, name string) fuse.Status
EntryNotify makes the kernel forget the entry data from the given name from a directory. After this call, the kernel will issue a new lookup request for the given name when necessary.
func (*PathNodeFs) FileNotify ¶
FileNotify notifies that file contents were changed within the given range. Use negative offset for metadata-only invalidation, and zero-length for invalidating all content.
func (*PathNodeFs) ForgetClientInodes ¶
func (fs *PathNodeFs) ForgetClientInodes()
ForgetClientInodes forgets all known information on client inodes.
func (*PathNodeFs) LastNode ¶
func (fs *PathNodeFs) LastNode(name string) (*nodefs.Inode, []string)
LastNode finds the deepest inode known corresponding to a path. The unknown part of the filename is also returned.
func (*PathNodeFs) LookupNode ¶
func (fs *PathNodeFs) LookupNode(name string) *nodefs.Inode
Like Node, but use Lookup to discover inodes we may not have yet.
func (*PathNodeFs) Mount ¶
Mount mounts a another node filesystem with the given root on the path. The last component of the path should not exist yet.
func (*PathNodeFs) Node ¶
func (fs *PathNodeFs) Node(name string) *nodefs.Inode
Node looks up the Inode that corresponds to the given path name, or returns nil if not found.
func (*PathNodeFs) Notify ¶
func (fs *PathNodeFs) Notify(path string) fuse.Status
Notify ensures that the path name is invalidates: if the inode is known, it issues an file content Notify, if not, an entry notify for the path is issued. The latter will clear out non-existence cache entries.
func (*PathNodeFs) Path ¶
func (fs *PathNodeFs) Path(node *nodefs.Inode) string
Path constructs a path for the given Inode. If the file system implements hard links through client-inode numbers, the path may not be unique.
func (*PathNodeFs) RereadClientInodes ¶
func (fs *PathNodeFs) RereadClientInodes()
Rereads all inode numbers for all known files.
func (*PathNodeFs) Root ¶
func (fs *PathNodeFs) Root() nodefs.Node
Root returns the root node for the path filesystem.
func (*PathNodeFs) SetDebug ¶
func (fs *PathNodeFs) SetDebug(dbg bool)
SetDebug toggles debug information: it will log path names for each operation processed.
func (*PathNodeFs) String ¶
func (fs *PathNodeFs) String() string
String returns a name for this file system
func (*PathNodeFs) Unmount ¶
func (fs *PathNodeFs) Unmount(path string) fuse.Status
UnmountNode unmounts the node filesystem with the given root.
func (*PathNodeFs) UnmountNode ¶
func (fs *PathNodeFs) UnmountNode(node *nodefs.Inode) fuse.Status
UnmountNode unmounts the node filesystem with the given root.
type PathNodeFsOptions ¶
type PathNodeFsOptions struct {
// If ClientInodes is set, use Inode returned from GetAttr to
// find hard-linked files.
ClientInodes bool
}