mount2

package
v1.66.2 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package mount2 implements a FUSE mounting system for rclone remotes.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FS

type FS struct {
	VFS *vfs.VFS
	// contains filtered or unexported fields
}

FS represents the top level filing system

func NewFS

func NewFS(VFS *vfs.VFS, opt *mountlib.Options) *FS

NewFS creates a pathfs.FileSystem from the fs.Fs passed in

func (*FS) Root

func (f *FS) Root() (node *Node, err error)

Root returns the root node

func (*FS) SetDebug

func (f *FS) SetDebug(debug bool)

SetDebug if called, provide debug output through the log package.

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

func (f *FileHandle) Fsync(ctx context.Context, flags uint32) (errno syscall.Errno)

Fsync is a signal to ensure writes to the Inode are flushed to stable storage.

func (*FileHandle) Getattr

func (f *FileHandle) Getattr(ctx context.Context, out *fuse.AttrOut) (errno syscall.Errno)

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.

func (*FileHandle) Write

func (f *FileHandle) Write(ctx context.Context, data []byte, off int64) (written uint32, errno syscall.Errno)

Write the data into the file handle at given offset. After returning, the data will be reused and may not referenced.

type Node

type Node struct {
	fusefs.Inode
	// contains filtered or unexported fields
}

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

func (n *Node) Getattr(ctx context.Context, f fusefs.FileHandle, out *fuse.AttrOut) syscall.Errno

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 added in v1.62.1

func (n *Node) Getxattr(ctx context.Context, attr string, dest []byte) (uint32, syscall.Errno)

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 added in v1.62.1

func (n *Node) Listxattr(ctx context.Context, dest []byte) (uint32, syscall.Errno)

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

func (n *Node) Opendir(ctx context.Context) syscall.Errno

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

func (n *Node) Readdir(ctx context.Context) (ds fusefs.DirStream, errno syscall.Errno)

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 added in v1.62.1

func (n *Node) Removexattr(ctx context.Context, attr string) syscall.Errno

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) Rmdir

func (n *Node) Rmdir(ctx context.Context, name string) (errno syscall.Errno)

Rmdir is like Unlink but for directories. 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 added in v1.62.1

func (n *Node) Setxattr(ctx context.Context, attr string, data []byte, flags uint32) syscall.Errno

Setxattr should store data for the given attribute. See setxattr(2) for information about flags. If not defined, Setxattr will return ENOATTR.

func (*Node) Statfs

func (n *Node) Statfs(ctx context.Context, out *fuse.StatfsOut) syscall.Errno

Statfs implements statistics for the filesystem that holds this Inode. If not defined, the `out` argument will zeroed with an OK result. This is because OSX filesystems must Statfs, or the mount will not work.

func (*Node) String

func (n *Node) String() string

String used for pretty printing.

func (n *Node) Unlink(ctx context.Context, name string) (errno syscall.Errno)

Unlink should remove a child from this directory. If the return status is OK, the Inode is removed as child in the FS tree automatically. Default is to return EROFS.

Jump to

Keyboard shortcuts

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