nodefs
packageThis package is not in the latest version of its module.
Details
Validgo.mod file
The Go module system was introduced in Go 1.11 and is the official dependency management solution for Go.
Redistributable license
Redistributable licenses place minimal restrictions on how software can be used, modified, and redistributed.
Tagged version
Modules with tagged versions give importers more predictable builds.
Stable version
When a project reaches major version v1 it is considered stable.
- Learn more about best practices
Repository
Links
Documentation¶
Overview¶
This package is deprecated. New projects should use the package"github.com/hanwen/go-fuse/v2/fs" instead.
The nodefs package offers a high level API that resembles thekernel's idea of what an FS looks like. File systems can havemultiple hard-links to one file, for example. It is also suited ifthe data to represent fits in memory: you can construct thecomplete file system tree at mount time
Index¶
- Constants
- type File
- type FileSystemConnector
- func Mount(mountpoint string, root Node, mountOptions *fuse.MountOptions, ...) (*fuse.Server, *FileSystemConnector, error)
- func MountRoot(mountpoint string, root Node, opts *Options) (*fuse.Server, *FileSystemConnector, error)
- func NewFileSystemConnector(root Node, opts *Options) (c *FileSystemConnector)
- func (c *FileSystemConnector) DeleteNotify(dir *Inode, child *Inode, name string) fuse.Status
- func (c *FileSystemConnector) EntryNotify(node *Inode, name string) fuse.Status
- func (c *FileSystemConnector) FileNotify(node *Inode, off int64, length int64) fuse.Status
- func (c *FileSystemConnector) FileNotifyStoreCache(node *Inode, off int64, data []byte) fuse.Status
- func (c *FileSystemConnector) FileRetrieveCache(node *Inode, off int64, dest []byte) (n int, st fuse.Status)
- func (c *FileSystemConnector) InodeHandleCount() int
- func (c *FileSystemConnector) LookupNode(parent *Inode, path string) *Inode
- func (c *FileSystemConnector) Mount(parent *Inode, name string, root Node, opts *Options) fuse.Status
- func (c *FileSystemConnector) Node(parent *Inode, fullPath string) (*Inode, []string)
- func (c *FileSystemConnector) RawFS() fuse.RawFileSystem
- func (c *FileSystemConnector) Server() *fuse.Server
- func (c *FileSystemConnector) SetDebug(debug bool)
- func (c *FileSystemConnector) Unmount(node *Inode) fuse.Status
- type Inode
- func (n *Inode) AddChild(name string, child *Inode)
- func (n *Inode) AnyFile() (file File)
- func (n *Inode) Children() (out map[string]*Inode)
- func (n *Inode) Files(mask uint32) (files []WithFlags)
- func (n *Inode) FsChildren() (out map[string]*Inode)
- func (n *Inode) GetChild(name string) (child *Inode)
- func (n *Inode) IsDir() bool
- func (n *Inode) NewChild(name string, isDir bool, fsi Node) *Inode
- func (n *Inode) Node() Node
- func (n *Inode) Parent() (parent *Inode, name string)
- func (n *Inode) RmChild(name string) (ch *Inode)
- func (n *Inode) String() string
- type Node
- type Options
- type TreeWatcher
- type WithFlags
Constants¶
const (F_OFD_GETLK = 36F_OFD_SETLK = 37F_OFD_SETLKW = 38)
Variables¶
This section is empty.
Functions¶
This section is empty.
Types¶
typeFile¶
type File interface {// Called upon registering the filehandle in the inode. This// is useful in that PathFS API, where Create/Open have no// access to the Inode at hand.SetInode(*Inode)// The String method is for debug printing.String()string// Wrappers around other File implementations, should return// the inner file here.InnerFile()FileRead(dest []byte, offint64) (fuse.ReadResult,fuse.Status)Write(data []byte, offint64) (writtenuint32, codefuse.Status)// File lockingGetLk(owneruint64, lk *fuse.FileLock, flagsuint32, out *fuse.FileLock) (codefuse.Status)SetLk(owneruint64, lk *fuse.FileLock, flagsuint32) (codefuse.Status)SetLkw(owneruint64, lk *fuse.FileLock, flagsuint32) (codefuse.Status)// Flush is called for close() call on a file descriptor. In// case of duplicated descriptor, it may be called more than// once for a file.Flush()fuse.Status// This is called to before the file handle is forgotten. This// method has no return value, so nothing can synchronizes on// the call. Any cleanup that requires specific synchronization or// could fail with I/O errors should happen in Flush instead.Release()Fsync(flagsint) (codefuse.Status)// The methods below may be called on closed files, due to// concurrency. In that case, you should return EBADF.Truncate(sizeuint64)fuse.StatusGetAttr(out *fuse.Attr)fuse.StatusChown(uiduint32, giduint32)fuse.StatusChmod(permsuint32)fuse.StatusUtimens(atime *time.Time, mtime *time.Time)fuse.StatusAllocate(offuint64, sizeuint64, modeuint32) (codefuse.Status)}A File object is returned from FileSystem.Open andFileSystem.Create. Include the NewDefaultFile return value intothe struct to inherit a null implementation.
funcNewDataFile¶
funcNewDefaultFile¶
func NewDefaultFile()File
NewDefaultFile returns a File instance that returns ENOSYS forevery operation.
funcNewDevNullFile¶
func NewDevNullFile()File
NewDevNullFile returns a file that accepts any write, and alwaysreturns EOF for reads.
funcNewLockingFile¶
NewLockingFile serializes operations an existing File.
funcNewLoopbackFile¶
LoopbackFile delegates all operations back to an underlying os.File.
funcNewReadOnlyFile¶
NewReadOnlyFile wraps a File so all write operations are denied.
typeFileSystemConnector¶
type FileSystemConnector struct {// contains filtered or unexported fields}FileSystemConnector translates the raw FUSE protocol (serializedstructs of uint32/uint64) to operations on Go objects representingfiles and directories.
funcMount¶
func Mount(mountpointstring, rootNode, mountOptions *fuse.MountOptions, nodefsOptions *Options) (*fuse.Server, *FileSystemConnector,error)
Mount mounts a filesystem with the given root node on the given directory.Convenience wrapper around fuse.NewServer
funcMountRoot¶
func MountRoot(mountpointstring, rootNode, opts *Options) (*fuse.Server, *FileSystemConnector,error)
MountRoot is like Mount but uses default fuse mount options.
funcNewFileSystemConnector¶
func NewFileSystemConnector(rootNode, opts *Options) (c *FileSystemConnector)
NewFileSystemConnector creates a FileSystemConnector with the givenoptions.
func (*FileSystemConnector)DeleteNotify¶
DeleteNotify signals to the kernel that the named entry in dir forthe child disappeared. No filesystem related locks should be heldwhen calling this.
func (*FileSystemConnector)EntryNotify¶
func (c *FileSystemConnector) EntryNotify(node *Inode, namestring)fuse.Status
EntryNotify makes the kernel forget the entry data from the givenname from a directory. After this call, the kernel will issue anew lookup request for the given name when necessary. No filesystemrelated locks should be held when calling this.
func (*FileSystemConnector)FileNotify¶
FileNotify notifies the kernel that data and metadata of this inodehas changed. After this call completes, the kernel will issue anew GetAttr requests for metadata and new Read calls for content.Use negative offset for metadata-only invalidation, and zero-lengthfor invalidating all content.
func (*FileSystemConnector)FileNotifyStoreCache¶
FileNotifyStoreCache notifies the kernel about changed data of the inode.
This call is similar to FileNotify, but instead of only invalidating a dataregion, it puts updated data directly to the kernel cache:
After this call completes, the kernel has put updated data into the inode's cache,and will use data from that cache for non direct-IO reads from the inodein corresponding data region. After kernel's cache data is evicted, the kernelwill have to issue new Read calls on user request to get data content.
ENOENT is returned if the kernel does not currently have entry for thisinode in its dentry cache.
func (*FileSystemConnector)FileRetrieveCache¶
func (c *FileSystemConnector) FileRetrieveCache(node *Inode, offint64, dest []byte) (nint, stfuse.Status)
FileRetrieveCache retrieves data from kernel's inode cache.
This call retrieves data from kernel's inode cache @ offset and up tolen(dest) bytes. If kernel cache has fewer consecutive data starting atoffset, that fewer amount is returned. In particular if inode data at offsetis not cached (0, OK) is returned.
If the kernel does not currently have entry for this inode in its dentrycache (0, OK) is still returned, pretending that the inode could be known tothe kernel, but kernel's inode cache is empty.
func (*FileSystemConnector)InodeHandleCount¶
func (c *FileSystemConnector) InodeHandleCount()int
InodeCount returns the number of inodes registered with the kernel.
func (*FileSystemConnector)LookupNode¶
func (c *FileSystemConnector) LookupNode(parent *Inode, pathstring) *Inode
Follows the path from the given parent, doing lookups asnecessary. The path should be '/' separated without leading slash.
func (*FileSystemConnector)Mount¶
Mount() generates a synthetic directory node, and mounts the filesystem there. If opts is nil, the mount options of the root filesystem are inherited. The encompassing filesystem should pretendthe mount point does not exist.
It returns ENOENT if the directory containing the mount point doesnot exist, and EBUSY if the intended mount point already exists.
func (*FileSystemConnector)Node¶
func (c *FileSystemConnector) Node(parent *Inode, fullPathstring) (*Inode, []string)
Finds a node within the currently known inodes, returns the lastknown node and the remaining unknown path components. If parent isnil, start from FUSE mountpoint.
func (*FileSystemConnector)RawFS¶
func (c *FileSystemConnector) RawFS()fuse.RawFileSystem
Returns the RawFileSystem so it can be mounted.
func (*FileSystemConnector)Server¶
func (c *FileSystemConnector) Server() *fuse.Server
Server returns the fuse.Server that talking to the kernel.
func (*FileSystemConnector)SetDebug¶
func (c *FileSystemConnector) SetDebug(debugbool)
SetDebug toggles printing of debug information. This function isdeprecated. Set the Debug option in the Options struct instead.
typeInode¶
type Inode struct {// contains filtered or unexported fields}An Inode reflects the kernel's idea of the inode. Inodes have IDsthat are communicated to the kernel, and they have a treestructure: a directory Inode may contain named children. EachInode object is paired with a Node object, which file systemimplementers should supply.
func (*Inode)Files¶
Files() returns an opens file that have bits in common with thegive mask. Use mask==0 to return all files.
func (*Inode)FsChildren¶
FsChildren returns all the children from the same filesystem. Itwill skip mountpoints.
func (*Inode)GetChild¶
GetChild returns a child inode with the given name, or nil if itdoes not exist.
func (*Inode)Parent¶
Parent returns a random parent and the name this inode has under this parent.This function can be used to walk up the directory tree. It will not crosssub-mounts.
typeNode¶
type Node interface {// Inode and SetInode are basic getter/setters. They are// called by the FileSystemConnector. You get them for free by// embedding the result of NewDefaultNode() in your node// struct.Inode() *InodeSetInode(node *Inode)// OnMount is called on the root node just after a mount is// executed, either when the actual root is mounted, or when a// filesystem is mounted in-process. The passed-in// FileSystemConnector gives access to Notify methods and// Debug settings.OnMount(conn *FileSystemConnector)// OnUnmount is executed just before a submount is removed,// and when the process receives a forget for the FUSE root// node.OnUnmount()// Lookup finds a child node to this node; it is only called// for directory Nodes. Lookup may be called on nodes that are// already known.Lookup(out *fuse.Attr, namestring, context *fuse.Context) (*Inode,fuse.Status)// Deletable() should return true if this node may be discarded once// the kernel forgets its reference.// If it returns false, OnForget will never get called for this node. This// is appropriate if the filesystem has no persistent backing store// (in-memory filesystems) where discarding the node loses the stored data.// Deletable will be called from within the treeLock critical section, so you// cannot look at other nodes.Deletable()bool// OnForget is called when the kernel forgets its reference to this node and// sends a FORGET request. It should perform cleanup and free memory as// appropriate for the filesystem.// OnForget is not called if the node is a directory and has children.// This is called from within a treeLock critical section.OnForget()// Misc.Access(modeuint32, context *fuse.Context) (codefuse.Status)Readlink(c *fuse.Context) ([]byte,fuse.Status)// Mknod should create the node, add it to the receiver's// inode, and return itMknod(namestring, modeuint32, devuint32, context *fuse.Context) (newNode *Inode, codefuse.Status)// Mkdir should create the directory Inode, add it to the// receiver's Inode, and return itMkdir(namestring, modeuint32, context *fuse.Context) (newNode *Inode, codefuse.Status)Unlink(namestring, context *fuse.Context) (codefuse.Status)Rmdir(namestring, context *fuse.Context) (codefuse.Status)// Symlink should create a child inode to the receiver, and// return it.Symlink(namestring, contentstring, context *fuse.Context) (*Inode,fuse.Status)Rename(oldNamestring, newParentNode, newNamestring, context *fuse.Context) (codefuse.Status)// Link should return the Inode of the resulting link. In// a POSIX conformant file system, this should add 'existing'// to the receiver, and return the Inode corresponding to// 'existing'.Link(namestring, existingNode, context *fuse.Context) (newNode *Inode, codefuse.Status)// Create should return an open file, and the Inode for that file.Create(namestring, flagsuint32, modeuint32, context *fuse.Context) (fileFile, child *Inode, codefuse.Status)// Open opens a file, and returns a File which is associated// with a file handle. It is OK to return (nil, OK) here. In// that case, the Node should implement Read or Write// directly.Open(flagsuint32, context *fuse.Context) (fileFile, codefuse.Status)OpenDir(context *fuse.Context) ([]fuse.DirEntry,fuse.Status)Read(fileFile, dest []byte, offint64, context *fuse.Context) (fuse.ReadResult,fuse.Status)Write(fileFile, data []byte, offint64, context *fuse.Context) (writtenuint32, codefuse.Status)// XAttrsGetXAttr(attributestring, context *fuse.Context) (data []byte, codefuse.Status)RemoveXAttr(attrstring, context *fuse.Context)fuse.StatusSetXAttr(attrstring, data []byte, flagsint, context *fuse.Context)fuse.StatusListXAttr(context *fuse.Context) (attrs []string, codefuse.Status)// File locking//// GetLk returns existing lock information for file.GetLk(fileFile, owneruint64, lk *fuse.FileLock, flagsuint32, out *fuse.FileLock, context *fuse.Context) (codefuse.Status)// Sets or clears the lock described by lk on file.SetLk(fileFile, owneruint64, lk *fuse.FileLock, flagsuint32, context *fuse.Context) (codefuse.Status)// Sets or clears the lock described by lk. This call blocks until the operation can be completed.SetLkw(fileFile, owneruint64, lk *fuse.FileLock, flagsuint32, context *fuse.Context) (codefuse.Status)// AttributesGetAttr(out *fuse.Attr, fileFile, context *fuse.Context) (codefuse.Status)Chmod(fileFile, permsuint32, context *fuse.Context) (codefuse.Status)Chown(fileFile, uiduint32, giduint32, context *fuse.Context) (codefuse.Status)Truncate(fileFile, sizeuint64, context *fuse.Context) (codefuse.Status)Utimens(fileFile, atime *time.Time, mtime *time.Time, context *fuse.Context) (codefuse.Status)Fallocate(fileFile, offuint64, sizeuint64, modeuint32, context *fuse.Context) (codefuse.Status)StatFs() *fuse.StatfsOut}The Node interface implements the user-defined file systemfunctionality
funcNewDefaultNode¶
func NewDefaultNode()Node
NewDefaultNode returns an implementation of Node that returnsENOSYS for all operations.
funcNewMemNodeFSRoot¶
NewMemNodeFSRoot creates an in-memory node-based filesystem. Filesare written into a backing store under the given prefix.
typeOptions¶
type Options struct {EntryTimeouttime.DurationAttrTimeouttime.DurationNegativeTimeouttime.Duration// If set, replace all uids with given UID.// NewOptions() will set this to the daemon's// uid/gid.*fuse.Owner// This option exists for compatibility and is ignored.PortableInodesbool// If set, print debug information.Debugbool// If set, issue Lookup rather than GetAttr calls for known// children. This allows the filesystem to update its inode// hierarchy in response to kernel calls.LookupKnownChildrenbool}Options contains time out options for a node FileSystem. Thedefault copied from libfuse and set in NewMountOptions() is(1s,1s,0s).
funcNewOptions¶
func NewOptions() *Options
NewOptions generates FUSE options that correspond to libfuse'sdefaults.
typeTreeWatcher¶
TreeWatcher is an additional interface that Nodes can implement.If they do, the OnAdd and OnRemove are called for operations on thefile system tree. These functions run under a lock, so they shouldnot do blocking operations.