Commit 137fa1b9 authored by Han-Wen Nienhuys's avatar Han-Wen Nienhuys

fuse/nodefs: more doc cleanups.

parent fcf1e909
...@@ -98,9 +98,6 @@ type Node interface { ...@@ -98,9 +98,6 @@ type Node interface {
// A File object should be returned from FileSystem.Open and // A File object should be returned from FileSystem.Open and
// FileSystem.Create. Include the NewDefaultFile return value into // FileSystem.Create. Include the NewDefaultFile return value into
// the struct to inherit a default null implementation. // the struct to inherit a default null implementation.
//
// TODO - should File be thread safe?
// TODO - should we pass a *fuse.Context argument?
type File interface { type File interface {
// Called upon registering the filehandle in the inode. // Called upon registering the filehandle in the inode.
SetInode(*Inode) SetInode(*Inode)
......
...@@ -19,9 +19,9 @@ import ( ...@@ -19,9 +19,9 @@ import (
// Tests should set to true. // Tests should set to true.
var paranoia = false var paranoia = false
// FilesystemConnector that translates the raw FUSE protocol // FilesystemConnector translates the raw FUSE protocol (serialized
// (serialized structs of uint32/uint64) to operations on Go objects // structs of uint32/uint64) to operations on Go objects representing
// representing files and directories. // files and directories.
type FileSystemConnector struct { type FileSystemConnector struct {
// Used as the generation inodes. This must be 64-bit aligned, // Used as the generation inodes. This must be 64-bit aligned,
// for sync/atomic on i386 to work properly. // for sync/atomic on i386 to work properly.
...@@ -52,6 +52,8 @@ func NewOptions() *Options { ...@@ -52,6 +52,8 @@ func NewOptions() *Options {
} }
} }
// NewFileSystemConnector creates a FileSystemConnector with the given
// options.
func NewFileSystemConnector(nodeFs FileSystem, opts *Options) (c *FileSystemConnector) { func NewFileSystemConnector(nodeFs FileSystem, opts *Options) (c *FileSystemConnector) {
c = new(FileSystemConnector) c = new(FileSystemConnector)
if opts == nil { if opts == nil {
...@@ -220,6 +222,8 @@ func (c *FileSystemConnector) Node(parent *Inode, fullPath string) (*Inode, []st ...@@ -220,6 +222,8 @@ func (c *FileSystemConnector) Node(parent *Inode, fullPath string) (*Inode, []st
return node, nil return node, nil
} }
// Follows the path from the given parent. The path should be '/'
// separated without leading slash.
func (c *FileSystemConnector) LookupNode(parent *Inode, path string) *Inode { func (c *FileSystemConnector) LookupNode(parent *Inode, path string) *Inode {
// TODO - this is broken. The internalLookups will cause // TODO - this is broken. The internalLookups will cause
// Nlookup increments that the kernel does not know about. // Nlookup increments that the kernel does not know about.
...@@ -251,14 +255,10 @@ func (c *FileSystemConnector) mountRoot(nodeFs FileSystem, opts *Options) { ...@@ -251,14 +255,10 @@ func (c *FileSystemConnector) mountRoot(nodeFs FileSystem, opts *Options) {
// Mount() generates a synthetic directory node, and mounts the file // Mount() generates a synthetic directory node, and mounts the file
// system there. If opts is nil, the mount options of the root file // system there. If opts is nil, the mount options of the root file
// system are inherited. The encompassing filesystem should pretend // system are inherited. The encompassing filesystem should pretend
// the mount point does not exist. If it does, it will generate an // the mount point does not exist.
// Inode with the same, which will cause Mount() to return EBUSY.
// //
// Return values: // It returns ENOENT if the directory containing the mount point does
// // not exist, and EBUSY if the intended mount point already exists.
// ENOENT: the directory containing the mount point does not exist.
//
// EBUSY: the intended mount point already exists.
func (c *FileSystemConnector) Mount(parent *Inode, name string, nodeFs FileSystem, opts *Options) fuse.Status { func (c *FileSystemConnector) Mount(parent *Inode, name string, nodeFs FileSystem, opts *Options) fuse.Status {
defer c.verify() defer c.verify()
parent.mount.treeLock.Lock() parent.mount.treeLock.Lock()
...@@ -286,13 +286,9 @@ func (c *FileSystemConnector) Mount(parent *Inode, name string, nodeFs FileSyste ...@@ -286,13 +286,9 @@ func (c *FileSystemConnector) Mount(parent *Inode, name string, nodeFs FileSyste
return fuse.OK return fuse.OK
} }
// Unmount() tries to unmount the given inode. // Unmount() tries to unmount the given inode. It returns EINVAL if the
// // path does not exist, or is not a mount point, and EBUSY if there
// Returns the following error codes: // are open files or submounts below this node.
//
// EINVAL: path does not exist, or is not a mount point.
//
// EBUSY: there are open files, or submounts below this node.
func (c *FileSystemConnector) Unmount(node *Inode) fuse.Status { func (c *FileSystemConnector) Unmount(node *Inode) fuse.Status {
// TODO - racy. // TODO - racy.
if node.mountPoint == nil { if node.mountPoint == nil {
...@@ -362,6 +358,9 @@ func (c *FileSystemConnector) Unmount(node *Inode) fuse.Status { ...@@ -362,6 +358,9 @@ func (c *FileSystemConnector) Unmount(node *Inode) fuse.Status {
return fuse.OK return fuse.OK
} }
// FileNotify notifies the kernel that data and metadata of this inode
// has changed. After this call completes, the kernel will issue a
// new GetAttr requests for metadata and new Read calls for content.
func (c *FileSystemConnector) FileNotify(node *Inode, off int64, length int64) fuse.Status { func (c *FileSystemConnector) FileNotify(node *Inode, off int64, length int64) fuse.Status {
var nId uint64 var nId uint64
if node == c.rootNode { if node == c.rootNode {
...@@ -376,6 +375,9 @@ func (c *FileSystemConnector) FileNotify(node *Inode, off int64, length int64) f ...@@ -376,6 +375,9 @@ func (c *FileSystemConnector) FileNotify(node *Inode, off int64, length int64) f
return c.server.InodeNotify(nId, off, length) return c.server.InodeNotify(nId, off, length)
} }
// 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 (c *FileSystemConnector) EntryNotify(node *Inode, name string) fuse.Status { func (c *FileSystemConnector) EntryNotify(node *Inode, name string) fuse.Status {
var nId uint64 var nId uint64
if node == c.rootNode { if node == c.rootNode {
...@@ -390,6 +392,8 @@ func (c *FileSystemConnector) EntryNotify(node *Inode, name string) fuse.Status ...@@ -390,6 +392,8 @@ func (c *FileSystemConnector) EntryNotify(node *Inode, name string) fuse.Status
return c.server.EntryNotify(nId, name) return c.server.EntryNotify(nId, name)
} }
// DeleteNotify signals to the kernel that the named entry in dir for
// the child disappeared.
func (c *FileSystemConnector) DeleteNotify(dir *Inode, child *Inode, name string) fuse.Status { func (c *FileSystemConnector) DeleteNotify(dir *Inode, child *Inode, name string) fuse.Status {
var nId uint64 var nId uint64
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment