fs

package
v0.4.5-pre2 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2017 License: BSD-2-Clause, BSD-3-Clause, HPND, + 1 more Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateDynamicInode

func GenerateDynamicInode(parent uint64, name string) uint64

GenerateDynamicInode returns a dynamic inode.

The parent inode and current entry name are used as the criteria for choosing a pseudorandom inode. This makes it likely the same entry will get the same inode on multiple runs.

func Serve

func Serve(c *fuse.Conn, fs FS) error

Serve serves a FUSE connection with the default settings. See Server.Serve.

Types

type FS

type FS interface {
	// Root is called to obtain the Node for the file system root.
	Root() (Node, error)
}

An FS is the interface required of a file system.

Other FUSE requests can be handled by implementing methods from the FS* interfaces, for example FSIniter.

type FSDestroyer

type FSDestroyer interface {
	// Destroy is called when the file system is shutting down.
	//
	// Linux only sends this request for block device backed (fuseblk)
	// filesystems, to allow them to flush writes to disk before the
	// unmount completes.
	Destroy()
}

type FSIniter

type FSIniter interface {
	// Init is called to initialize the FUSE connection.
	// It can inspect the request and adjust the response as desired.
	// Init must return promptly.
	Init(ctx context.Context, req *fuse.InitRequest, resp *fuse.InitResponse) error
}

type FSInodeGenerator

type FSInodeGenerator interface {
	// GenerateInode is called to pick a dynamic inode number when it
	// would otherwise be 0.
	//
	// Not all filesystems bother tracking inodes, but FUSE requires
	// the inode to be set, and fewer duplicates in general makes UNIX
	// tools work better.
	//
	// Operations where the nodes may return 0 inodes include Getattr,
	// Setattr and ReadDir.
	//
	// If FS does not implement FSInodeGenerator, GenerateDynamicInode
	// is used.
	//
	// Implementing this is useful to e.g. constrain the range of
	// inode values used for dynamic inodes.
	GenerateInode(parentInode uint64, name string) uint64
}

type FSStatfser

type FSStatfser interface {
	// Statfs is called to obtain file system metadata.
	// It should write that data to resp.
	Statfs(ctx context.Context, req *fuse.StatfsRequest, resp *fuse.StatfsResponse) error
}

type Handle

type Handle interface {
}

A Handle is the interface required of an opened file or directory. See the documentation for type FS for general information pertaining to all methods.

Other FUSE requests can be handled by implementing methods from the Handle* interfaces. The most common to implement are HandleReader, HandleReadDirer, and HandleWriter.

TODO implement methods: Getlk, Setlk, Setlkw

func DataHandle

func DataHandle(data []byte) Handle

DataHandle returns a read-only Handle that satisfies reads using the given data.

type HandleFlusher

type HandleFlusher interface {
	// Flush is called each time the file or directory is closed.
	// Because there can be multiple file descriptors referring to a
	// single opened file, Flush can be called multiple times.
	Flush(ctx context.Context, req *fuse.FlushRequest) error
}

type HandleReadAller

type HandleReadAller interface {
	ReadAll(ctx context.Context) ([]byte, error)
}

type HandleReadDirAller added in v0.3.2

type HandleReadDirAller interface {
	ReadDirAll(ctx context.Context) ([]fuse.Dirent, error)
}

type HandleReader

type HandleReader interface {
	// Read requests to read data from the handle.
	//
	// There is a page cache in the kernel that normally submits only
	// page-aligned reads spanning one or more pages. However, you
	// should not rely on this. To see individual requests as
	// submitted by the file system clients, set OpenDirectIO.
	//
	// Note that reads beyond the size of the file as reported by Attr
	// are not even attempted (except in OpenDirectIO mode).
	Read(ctx context.Context, req *fuse.ReadRequest, resp *fuse.ReadResponse) error
}

type HandleReleaser

type HandleReleaser interface {
	Release(ctx context.Context, req *fuse.ReleaseRequest) error
}

type HandleWriter

type HandleWriter interface {
	// Write requests to write data into the handle.
	//
	// There is a writeback page cache in the kernel that normally submits
	// only page-aligned writes spanning one or more pages. However,
	// you should not rely on this. To see individual requests as
	// submitted by the file system clients, set OpenDirectIO.
	//
	// Note that file size changes are communicated through Setattr.
	// Writes beyond the size of the file as reported by Attr are not
	// even attempted (except in OpenDirectIO mode).
	Write(ctx context.Context, req *fuse.WriteRequest, resp *fuse.WriteResponse) error
}

type Node

type Node interface {
	// Attr fills attr with the standard metadata for the node.
	Attr(ctx context.Context, attr *fuse.Attr) error
}

A Node is the interface required of a file or directory. See the documentation for type FS for general information pertaining to all methods.

Other FUSE requests can be handled by implementing methods from the Node* interfaces, for example NodeOpener.

type NodeAccesser

type NodeAccesser interface {
	// Access checks whether the calling context has permission for
	// the given operations on the receiver. If so, Access should
	// return nil. If not, Access should return EPERM.
	//
	// Note that this call affects the result of the access(2) system
	// call but not the open(2) system call. If Access is not
	// implemented, the Node behaves as if it always returns nil
	// (permission granted), relying on checks in Open instead.
	Access(ctx context.Context, req *fuse.AccessRequest) error
}

type NodeCreater

type NodeCreater interface {
	// Create creates a new directory entry in the receiver, which
	// must be a directory.
	Create(ctx context.Context, req *fuse.CreateRequest, resp *fuse.CreateResponse) (Node, Handle, error)
}

type NodeForgetter

type NodeForgetter interface {
	// Forget about this node. This node will not receive further
	// method calls.
	//
	// Forget is not necessarily seen on unmount, as all nodes are
	// implicitly forgotten as part part of the unmount.
	Forget()
}

type NodeFsyncer

type NodeFsyncer interface {
	Fsync(ctx context.Context, req *fuse.FsyncRequest) error
}

TODO this should be on Handle not Node

type NodeGetattrer

type NodeGetattrer interface {
	// Getattr obtains the standard metadata for the receiver.
	// It should store that metadata in resp.
	//
	// If this method is not implemented, the attributes will be
	// generated based on Attr(), with zero values filled in.
	Getattr(ctx context.Context, req *fuse.GetattrRequest, resp *fuse.GetattrResponse) error
}

type NodeGetxattrer

type NodeGetxattrer interface {
	// Getxattr gets an extended attribute by the given name from the
	// node.
	//
	// If there is no xattr by that name, returns fuse.ErrNoXattr.
	Getxattr(ctx context.Context, req *fuse.GetxattrRequest, resp *fuse.GetxattrResponse) error
}

type NodeLinker

type NodeLinker interface {
	// Link creates a new directory entry in the receiver based on an
	// existing Node. Receiver must be a directory.
	Link(ctx context.Context, req *fuse.LinkRequest, old Node) (Node, error)
}

type NodeListxattrer

type NodeListxattrer interface {
	// Listxattr lists the extended attributes recorded for the node.
	Listxattr(ctx context.Context, req *fuse.ListxattrRequest, resp *fuse.ListxattrResponse) error
}

type NodeMkdirer

type NodeMkdirer interface {
	Mkdir(ctx context.Context, req *fuse.MkdirRequest) (Node, error)
}

type NodeMknoder

type NodeMknoder interface {
	Mknod(ctx context.Context, req *fuse.MknodRequest) (Node, error)
}

type NodeOpener

type NodeOpener interface {
	// Open opens the receiver. After a successful open, a client
	// process has a file descriptor referring to this Handle.
	//
	// Open can also be also called on non-files. For example,
	// directories are Opened for ReadDir or fchdir(2).
	//
	// If this method is not implemented, the open will always
	// succeed, and the Node itself will be used as the Handle.
	//
	// XXX note about access.  XXX OpenFlags.
	Open(ctx context.Context, req *fuse.OpenRequest, resp *fuse.OpenResponse) (Handle, error)
}

type NodeReadlinker

type NodeReadlinker interface {
	// Readlink reads a symbolic link.
	Readlink(ctx context.Context, req *fuse.ReadlinkRequest) (string, error)
}

This optional request will be called only for symbolic link nodes.

type NodeRef

type NodeRef struct {
	// contains filtered or unexported fields
}

NodeRef can be embedded in a Node to recognize the same Node being returned from multiple Lookup, Create etc calls.

Without this, each Node will get a new NodeID, causing spurious cache invalidations, extra lookups and aliasing anomalies. This may not matter for a simple, read-only filesystem.

type NodeRemover

type NodeRemover interface {
	// Remove removes the entry with the given name from
	// the receiver, which must be a directory.  The entry to be removed
	// may correspond to a file (unlink) or to a directory (rmdir).
	Remove(ctx context.Context, req *fuse.RemoveRequest) error
}

type NodeRemovexattrer

type NodeRemovexattrer interface {
	// Removexattr removes an extended attribute for the name.
	//
	// If there is no xattr by that name, returns fuse.ErrNoXattr.
	Removexattr(ctx context.Context, req *fuse.RemovexattrRequest) error
}

type NodeRenamer

type NodeRenamer interface {
	Rename(ctx context.Context, req *fuse.RenameRequest, newDir Node) error
}

type NodeRequestLookuper

type NodeRequestLookuper interface {
	// Lookup looks up a specific entry in the receiver.
	// See NodeStringLookuper for more.
	Lookup(ctx context.Context, req *fuse.LookupRequest, resp *fuse.LookupResponse) (Node, error)
}

type NodeSetattrer

type NodeSetattrer interface {
	// Setattr sets the standard metadata for the receiver.
	//
	// Note, this is also used to communicate changes in the size of
	// the file. Not implementing Setattr causes writes to be unable
	// to grow the file (except with OpenDirectIO, which bypasses that
	// mechanism).
	//
	// req.Valid is a bitmask of what fields are actually being set.
	// For example, the method should not change the mode of the file
	// unless req.Valid.Mode() is true.
	Setattr(ctx context.Context, req *fuse.SetattrRequest, resp *fuse.SetattrResponse) error
}

type NodeSetxattrer

type NodeSetxattrer interface {
	// Setxattr sets an extended attribute with the given name and
	// value for the node.
	Setxattr(ctx context.Context, req *fuse.SetxattrRequest) error
}

type NodeStringLookuper

type NodeStringLookuper interface {
	// Lookup looks up a specific entry in the receiver,
	// which must be a directory.  Lookup should return a Node
	// corresponding to the entry.  If the name does not exist in
	// the directory, Lookup should return nil, err.
	//
	// Lookup need not to handle the names "." and "..".
	Lookup(ctx context.Context, name string) (Node, error)
}

type NodeSymlinker

type NodeSymlinker interface {
	// Symlink creates a new symbolic link in the receiver, which must be a directory.
	//
	// TODO is the above true about directories?
	Symlink(ctx context.Context, req *fuse.SymlinkRequest) (Node, error)
}

type Server

type Server struct {
	FS FS

	// Function to send debug log messages to. If nil, use fuse.Debug.
	// Note that changing this or fuse.Debug may not affect existing
	// calls to Serve.
	//
	// See fuse.Debug for the rules that log functions must follow.
	Debug func(msg interface{})
	// contains filtered or unexported fields
}

func (*Server) Serve

func (s *Server) Serve(c *fuse.Conn) error

Serve serves the FUSE connection by making calls to the methods of fs and the Nodes and Handles it makes available. It returns only when the connection has been closed or an unexpected error occurs.

type Tree

type Tree struct {
	// contains filtered or unexported fields
}

A Tree implements a basic read-only directory tree for FUSE. The Nodes contained in it may still be writable.

func (*Tree) Add

func (t *Tree) Add(path string, node Node)

Add adds the path to the tree, resolving to the given node. If path or a prefix of path has already been added to the tree, Add panics.

Add is only safe to call before starting to serve requests.

func (*Tree) Attr

func (t *Tree) Attr(ctx context.Context, a *fuse.Attr) error

func (*Tree) Lookup

func (t *Tree) Lookup(ctx context.Context, name string) (Node, error)

func (*Tree) ReadDirAll added in v0.3.2

func (t *Tree) ReadDirAll(ctx context.Context) ([]fuse.Dirent, error)

func (*Tree) Root

func (t *Tree) Root() (Node, error)

Directories

Path Synopsis
Package bench contains benchmarks.
Package bench contains benchmarks.

Jump to

Keyboard shortcuts

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