Documentation ¶
Overview ¶
Package mount2 implements a FUSE mounting system for rclone remotes.
Index ¶
- type FS
- type FileHandle
- func (f *FileHandle) Flush(ctx context.Context) syscall.Errno
- func (f *FileHandle) Fsync(ctx context.Context, flags uint32) (errno syscall.Errno)
- func (f *FileHandle) Getattr(ctx context.Context, out *fuse.AttrOut) (errno syscall.Errno)
- func (f *FileHandle) Read(ctx context.Context, dest []byte, off int64) (res fuse.ReadResult, errno syscall.Errno)
- func (f *FileHandle) Release(ctx context.Context) syscall.Errno
- func (f *FileHandle) Setattr(ctx context.Context, in *fuse.SetAttrIn, out *fuse.AttrOut) (errno syscall.Errno)
- func (f *FileHandle) String() string
- func (f *FileHandle) Write(ctx context.Context, data []byte, off int64) (written uint32, errno syscall.Errno)
- type Node
- func (n *Node) Create(ctx context.Context, name string, flags uint32, mode uint32, ...) (node *fusefs.Inode, fh fusefs.FileHandle, fuseFlags uint32, ...)
- func (n *Node) Getattr(ctx context.Context, f fusefs.FileHandle, out *fuse.AttrOut) syscall.Errno
- func (n *Node) Getxattr(ctx context.Context, attr string, dest []byte) (uint32, syscall.Errno)
- func (n *Node) Listxattr(ctx context.Context, dest []byte) (uint32, syscall.Errno)
- func (n *Node) Lookup(ctx context.Context, name string, out *fuse.EntryOut) (inode *fusefs.Inode, errno syscall.Errno)
- func (n *Node) Mkdir(ctx context.Context, name string, mode uint32, out *fuse.EntryOut) (inode *fusefs.Inode, errno syscall.Errno)
- func (n *Node) Open(ctx context.Context, flags uint32) (fh fusefs.FileHandle, fuseFlags uint32, errno syscall.Errno)
- func (n *Node) Opendir(ctx context.Context) syscall.Errno
- func (n *Node) Readdir(ctx context.Context) (ds fusefs.DirStream, errno syscall.Errno)
- func (n *Node) Removexattr(ctx context.Context, attr string) syscall.Errno
- func (n *Node) Rename(ctx context.Context, oldName string, newParent fusefs.InodeEmbedder, ...) (errno syscall.Errno)
- func (n *Node) Rmdir(ctx context.Context, name string) (errno syscall.Errno)
- func (n *Node) Setattr(ctx context.Context, f fusefs.FileHandle, in *fuse.SetAttrIn, ...) (errno syscall.Errno)
- func (n *Node) Setxattr(ctx context.Context, attr string, data []byte, flags uint32) syscall.Errno
- func (n *Node) Statfs(ctx context.Context, out *fuse.StatfsOut) syscall.Errno
- func (n *Node) String() string
- func (n *Node) Unlink(ctx context.Context, name string) (errno syscall.Errno)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FS ¶
FS represents the top level filing system
type FileHandle ¶
type FileHandle struct {
// contains filtered or unexported fields
}
FileHandle is a resource identifier for opened files. Usually, a FileHandle should implement some of the FileXxxx interfaces.
All of the FileXxxx operations can also be implemented at the InodeEmbedder level, for example, one can implement NodeReader instead of FileReader.
FileHandles are useful in two cases: First, if the underlying storage systems needs a handle for reading/writing. This is the case with Unix system calls, which need a file descriptor (See also the function `NewLoopbackFile`). Second, it is useful for implementing files whose contents are not tied to an inode. For example, a file like `/proc/interrupts` has no fixed content, but changes on each open call. This means that each file handle must have its own view of the content; this view can be tied to a FileHandle. Files that have such dynamic content should return the FOPEN_DIRECT_IO flag from their `Open` method. See directio_test.go for an example.
func (*FileHandle) Flush ¶
func (f *FileHandle) Flush(ctx context.Context) syscall.Errno
Flush is called for the close(2) call on a file descriptor. In case of a descriptor that was duplicated using dup(2), it may be called more than once for the same FileHandle.
func (*FileHandle) Fsync ¶
Fsync is a signal to ensure writes to the Inode are flushed to stable storage.
func (*FileHandle) Getattr ¶
Getattr reads attributes for an Inode. The library will ensure that Mode and Ino are set correctly. For files that are not opened with FOPEN_DIRECTIO, Size should be set so it can be read correctly. If returning zeroed permissions, the default behavior is to change the mode of 0755 (directory) or 0644 (files). This can be switched off with the Options.NullPermissions setting. If blksize is unset, 4096 is assumed, and the 'blocks' field is set accordingly.
func (*FileHandle) Read ¶
func (f *FileHandle) Read(ctx context.Context, dest []byte, off int64) (res fuse.ReadResult, errno syscall.Errno)
Read data from a file. The data should be returned as ReadResult, which may be constructed from the incoming `dest` buffer.
func (*FileHandle) Release ¶
func (f *FileHandle) Release(ctx context.Context) syscall.Errno
Release is called to before a FileHandle is forgotten. The kernel ignores the return value of this method, so any cleanup that requires specific synchronization or could fail with I/O errors should happen in Flush instead.
func (*FileHandle) Setattr ¶
func (f *FileHandle) Setattr(ctx context.Context, in *fuse.SetAttrIn, out *fuse.AttrOut) (errno syscall.Errno)
Setattr sets attributes for an Inode.
func (*FileHandle) String ¶
func (f *FileHandle) String() string
The String method is for debug printing.
type Node ¶
Node represents a directory or file
func (*Node) Create ¶
func (n *Node) Create(ctx context.Context, name string, flags uint32, mode uint32, out *fuse.EntryOut) (node *fusefs.Inode, fh fusefs.FileHandle, fuseFlags uint32, errno syscall.Errno)
Create is similar to Lookup, but should create a new child. It typically also returns a FileHandle as a reference for future reads/writes. Default is to return EROFS.
func (*Node) Getattr ¶
Getattr reads attributes for an Inode. The library will ensure that Mode and Ino are set correctly. For files that are not opened with FOPEN_DIRECTIO, Size should be set so it can be read correctly. If returning zeroed permissions, the default behavior is to change the mode of 0755 (directory) or 0644 (files). This can be switched off with the Options.NullPermissions setting. If blksize is unset, 4096 is assumed, and the 'blocks' field is set accordingly.
func (*Node) Getxattr ¶
Getxattr should read data for the given attribute into `dest` and return the number of bytes. If `dest` is too small, it should return ERANGE and the size of the attribute. If not defined, Getxattr will return ENOATTR.
func (*Node) Listxattr ¶
Listxattr should read all attributes (null terminated) into `dest`. If the `dest` buffer is too small, it should return ERANGE and the correct size. If not defined, return an empty list and success.
func (*Node) Lookup ¶
func (n *Node) Lookup(ctx context.Context, name string, out *fuse.EntryOut) (inode *fusefs.Inode, errno syscall.Errno)
Lookup should find a direct child of a directory by the child's name. If the entry does not exist, it should return ENOENT and optionally set a NegativeTimeout in `out`. If it does exist, it should return attribute data in `out` and return the Inode for the child. A new inode can be created using `Inode.NewInode`. The new Inode will be added to the FS tree automatically if the return status is OK.
If a directory does not implement NodeLookuper, the library looks for an existing child with the given name.
The input to a Lookup is {parent directory, name string}.
Lookup, if successful, must return an *Inode. Once the Inode is returned to the kernel, the kernel can issue further operations, such as Open or Getxattr on that node.
A successful Lookup also returns an EntryOut. Among others, this contains file attributes (mode, size, mtime, etc.).
FUSE supports other operations that modify the namespace. For example, the Symlink, Create, Mknod, Link methods all create new children in directories. Hence, they also return *Inode and must populate their fuse.EntryOut arguments.
func (*Node) Mkdir ¶
func (n *Node) Mkdir(ctx context.Context, name string, mode uint32, out *fuse.EntryOut) (inode *fusefs.Inode, errno syscall.Errno)
Mkdir is similar to Lookup, but must create a directory entry and Inode. Default is to return EROFS.
func (*Node) Open ¶
func (n *Node) Open(ctx context.Context, flags uint32) (fh fusefs.FileHandle, fuseFlags uint32, errno syscall.Errno)
Open opens an Inode (of regular file type) for reading. It is optional but recommended to return a FileHandle.
func (*Node) Opendir ¶
Opendir opens a directory Inode for reading its contents. The actual reading is driven from Readdir, so this method is just for performing sanity/permission checks. The default is to return success.
func (*Node) Readdir ¶
Readdir opens a stream of directory entries.
Readdir essentially returns a list of strings, and it is allowed for Readdir to return different results from Lookup. For example, you can return nothing for Readdir ("ls my-fuse-mount" is empty), while still implementing Lookup ("ls my-fuse-mount/a-specific-file" shows a single file).
If a directory does not implement NodeReaddirer, a list of currently known children from the tree is returned. This means that static in-memory file systems need not implement NodeReaddirer.
func (*Node) Removexattr ¶
Removexattr should delete the given attribute. If not defined, Removexattr will return ENOATTR.
func (*Node) Rename ¶
func (n *Node) Rename(ctx context.Context, oldName string, newParent fusefs.InodeEmbedder, newName string, flags uint32) (errno syscall.Errno)
Rename should move a child from one directory to a different one. The change is effected in the FS tree if the return status is OK. Default is to return EROFS.
func (*Node) Setattr ¶
func (n *Node) Setattr(ctx context.Context, f fusefs.FileHandle, in *fuse.SetAttrIn, out *fuse.AttrOut) (errno syscall.Errno)
Setattr sets attributes for an Inode.
func (*Node) Setxattr ¶
Setxattr should store data for the given attribute. See setxattr(2) for information about flags. If not defined, Setxattr will return ENOATTR.