Documentation ¶
Overview ¶
Package fusefrontend interfaces directly with the go-fuse library.
Index ¶
- Constants
- type Args
- type File
- func (f *File) Allocate(ctx context.Context, off uint64, sz uint64, mode uint32) syscall.Errno
- func (f *File) Flush(ctx context.Context) syscall.Errno
- func (f *File) Fsync(ctx context.Context, flags uint32) (errno syscall.Errno)
- func (f *File) Getattr(ctx context.Context, a *fuse.AttrOut) syscall.Errno
- func (f *File) Lseek(ctx context.Context, off uint64, whence uint32) (uint64, syscall.Errno)
- func (f *File) Read(ctx context.Context, buf []byte, off int64) (resultData fuse.ReadResult, errno syscall.Errno)
- func (f *File) Release(ctx context.Context) syscall.Errno
- func (f *File) Setattr(ctx context.Context, in *fuse.SetAttrIn, out *fuse.AttrOut) (errno syscall.Errno)
- func (f *File) Write(ctx context.Context, data []byte, off int64) (uint32, syscall.Errno)
- type Node
- func (n *Node) Access(ctx context.Context, mode uint32) syscall.Errno
- func (n *Node) Create(ctx context.Context, name string, flags uint32, mode uint32, ...) (inode *fs.Inode, fh fs.FileHandle, fuseFlags uint32, errno syscall.Errno)
- func (n *Node) Fsync(ctx context.Context, f fs.FileHandle, flags uint32) syscall.Errno
- func (n *Node) Getattr(ctx context.Context, f fs.FileHandle, out *fuse.AttrOut) (errno syscall.Errno)
- func (n *Node) Getxattr(ctx context.Context, attr string, dest []byte) (uint32, syscall.Errno)
- func (n *Node) Link(ctx context.Context, target fs.InodeEmbedder, name string, out *fuse.EntryOut) (inode *fs.Inode, errno 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) (ch *fs.Inode, errno syscall.Errno)
- func (n *Node) Mkdir(ctx context.Context, name string, mode uint32, out *fuse.EntryOut) (*fs.Inode, syscall.Errno)
- func (n *Node) Mknod(ctx context.Context, name string, mode, rdev uint32, out *fuse.EntryOut) (inode *fs.Inode, errno syscall.Errno)
- func (n *Node) Open(ctx context.Context, flags uint32) (fh fs.FileHandle, fuseFlags uint32, errno syscall.Errno)
- func (n *Node) Opendir(ctx context.Context) (errno syscall.Errno)
- func (n *Node) Path() string
- func (n *Node) Readdir(ctx context.Context) (fs.DirStream, syscall.Errno)
- func (n *Node) Readlink(ctx context.Context) (out []byte, errno syscall.Errno)
- func (n *Node) Removexattr(ctx context.Context, attr string) syscall.Errno
- func (n *Node) Rename(ctx context.Context, name string, newParent fs.InodeEmbedder, newName string, ...) (errno syscall.Errno)
- func (n *Node) Rmdir(ctx context.Context, name string) (code syscall.Errno)
- func (n *Node) Setattr(ctx context.Context, f fs.FileHandle, in *fuse.SetAttrIn, out *fuse.AttrOut) (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) Symlink(ctx context.Context, target, name string, out *fuse.EntryOut) (inode *fs.Inode, errno syscall.Errno)
- func (n *Node) Unlink(ctx context.Context, name string) (errno syscall.Errno)
- type RootNode
Constants ¶
const FALLOC_DEFAULT = 0x00
FALLOC_DEFAULT is a "normal" fallocate operation
const FALLOC_FL_KEEP_SIZE = 0x01
FALLOC_FL_KEEP_SIZE allocates disk space while not modifying the file size
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Args ¶
type Args struct { // Cipherdir is the backing storage directory (absolute path). // For reverse mode, Cipherdir actually contains *plaintext* files. Cipherdir string PlaintextNames bool LongNames bool // Should we chown a file after it has been created? // This only makes sense if (1) allow_other is set and (2) we run as root. PreserveOwner bool // Should we force ownership to be presented with a given user and group? // This only makes sense if allow_other is set. In *most* cases, it also // only makes sense with PreserveOwner set, but can also make sense without // PreserveOwner if the underlying filesystem acting as backing store // enforces ownership itself. ForceOwner *fuse.Owner // ConfigCustom is true when the user select a non-default config file // location. If it is false, reverse mode maps ".gocryptfs.reverse.conf" // to "gocryptfs.conf" in the plaintext dir. ConfigCustom bool // NoPrealloc disables automatic preallocation before writing NoPrealloc bool // Exclude is a list of paths to make inaccessible, starting match at // the filesystem root Exclude []string // ExcludeWildcards is a list of paths to make inaccessible, matched // anywhere, and supporting wildcards ExcludeWildcard []string // ExcludeFrom is a list of files from which to read exclusion patterns // (with wildcard syntax) ExcludeFrom []string // Suid is true if the filesystem has been mounted with the "-suid" flag. // If it is false, we can ignore the GETXATTR "security.capability" calls, // which are a performance problem for writes. See // https://github.com/rfjakob/gocryptfs/issues/515 for details. Suid bool // Enable the FUSE kernel_cache option KernelCache bool // enabled via cli flag "-sharedstorage" SharedStorage bool // OneFileSystem disables crossing filesystem boundaries, // like rsync's `--one-file-system` does. // Only applicable to reverse mode. OneFileSystem bool // DeterministicNames disables gocryptfs.diriv files DeterministicNames bool }
Args is a container for arguments that are passed from main() to fusefrontend
type File ¶
type File struct {
// contains filtered or unexported fields
}
File implements the go-fuse v2 API (github.com/hanwen/go-fuse/v2/fs)
func NewFile ¶
NewFile returns a new go-fuse File instance based on an already-open file descriptor. NewFile internally calls Fstat() on the fd. The resulting Stat_t is returned because node.Create() needs it.
`cName` is only used for error logging and may be left blank.
func (*File) Allocate ¶
Allocate - FUSE call for fallocate(2)
mode=FALLOC_FL_KEEP_SIZE is implemented directly.
mode=FALLOC_DEFAULT is implemented as a two-step process:
(1) Allocate the space using FALLOC_FL_KEEP_SIZE (2) Set the file size using ftruncate (via truncateGrowFile)
This allows us to reuse the file grow mechanics from Truncate as they are complicated and hard to get right.
Other modes (hole punching, zeroing) are not supported.
func (*File) Fsync ¶
Fsync: handles FUSE opcode FSYNC
Unfortunately, as Node.Fsync is also defined and takes precedence, File.Fsync is never called at the moment.
func (*File) Lseek ¶
Lseek - FUSE call.
Looking at fuse_file_llseek @ https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/tree/fs/fuse/file.c?h=v5.12.7#n2634 this function is only called for SEEK_HOLE & SEEK_DATA.
func (*File) Read ¶
func (f *File) Read(ctx context.Context, buf []byte, off int64) (resultData fuse.ReadResult, errno syscall.Errno)
Read - FUSE call
type Node ¶
Node is a file or directory in the filesystem tree in a gocryptfs mount.
func (*Node) Create ¶
func (n *Node) Create(ctx context.Context, name string, flags uint32, mode uint32, out *fuse.EntryOut) (inode *fs.Inode, fh fs.FileHandle, fuseFlags uint32, errno syscall.Errno)
Create - FUSE call. Creates a new file.
Symlink-safe through the use of Openat().
func (*Node) Fsync ¶
Fsync: handles FUSE opcodes FSYNC & FDIRSYNC
Note: f is always set to nil by go-fuse
func (*Node) Getattr ¶
func (n *Node) Getattr(ctx context.Context, f fs.FileHandle, out *fuse.AttrOut) (errno syscall.Errno)
GetAttr - FUSE call for stat()ing a file.
GetAttr is symlink-safe through use of openBackingDir() and Fstatat().
func (*Node) Getxattr ¶
GetXAttr - FUSE call. Reads the value of extended attribute "attr".
This function is symlink-safe through Fgetxattr.
func (*Node) Link ¶
func (n *Node) Link(ctx context.Context, target fs.InodeEmbedder, name string, out *fuse.EntryOut) (inode *fs.Inode, errno syscall.Errno)
Link - FUSE call. Creates a hard link at "newPath" pointing to file "oldPath".
Symlink-safe through use of Linkat().
func (*Node) Listxattr ¶
ListXAttr - FUSE call. Lists extended attributes on the file at "relPath".
This function is symlink-safe through Flistxattr.
func (*Node) Lookup ¶
func (n *Node) Lookup(ctx context.Context, name string, out *fuse.EntryOut) (ch *fs.Inode, errno syscall.Errno)
Lookup - FUSE call for discovering a file.
func (*Node) Mkdir ¶
func (n *Node) Mkdir(ctx context.Context, name string, mode uint32, out *fuse.EntryOut) (*fs.Inode, syscall.Errno)
Mkdir - FUSE call. Create a directory at "newPath" with permissions "mode".
Symlink-safe through use of Mkdirat().
func (*Node) Mknod ¶
func (n *Node) Mknod(ctx context.Context, name string, mode, rdev uint32, out *fuse.EntryOut) (inode *fs.Inode, errno syscall.Errno)
Mknod - FUSE call. Create a device file.
Symlink-safe through use of Mknodat().
func (*Node) Open ¶
func (n *Node) Open(ctx context.Context, flags uint32) (fh fs.FileHandle, fuseFlags uint32, errno syscall.Errno)
Open - FUSE call. Open already-existing file.
Symlink-safe through Openat().
func (*Node) Readdir ¶
Readdir - FUSE call.
This function is symlink-safe through use of openBackingDir() and ReadDirIVAt().
func (*Node) Removexattr ¶
RemoveXAttr - FUSE call.
This function is symlink-safe through Fremovexattr.
func (*Node) Rename ¶
func (n *Node) Rename(ctx context.Context, name string, newParent fs.InodeEmbedder, newName string, flags uint32) (errno syscall.Errno)
Rename - FUSE call. This function is called on the PARENT DIRECTORY of `name`.
Symlink-safe through Renameat().
func (*Node) Setattr ¶
func (n *Node) Setattr(ctx context.Context, f fs.FileHandle, in *fuse.SetAttrIn, out *fuse.AttrOut) (errno syscall.Errno)
Setattr - FUSE call. Called for chmod, truncate, utimens, ...
func (*Node) Setxattr ¶
SetXAttr - FUSE call. Set extended attribute.
This function is symlink-safe through Fsetxattr.
func (*Node) Statfs ¶
StatFs - FUSE call. Returns information about the filesystem.
Symlink-safe because the path is ignored.
type RootNode ¶
type RootNode struct { Node // MitigatedCorruptions is used to report data corruption that is internally // mitigated by ignoring the corrupt item. For example, when OpenDir() finds // a corrupt filename, we still return the other valid filenames. // The corruption is logged to syslog to inform the user, and in addition, // the corrupt filename is logged to this channel via // reportMitigatedCorruption(). // "gocryptfs -fsck" reads from the channel to also catch these transparently- // mitigated corruptions. MitigatedCorruptions chan string // IsIdle flag is set to zero each time fs.isFiltered() is called // (uint32 so that it can be reset with CompareAndSwapUint32). // When -idle was used when mounting, idleMonitor() sets it to 1 // periodically. IsIdle uint32 // contains filtered or unexported fields }
RootNode is the root of the filesystem tree of Nodes.
func NewRootNode ¶
func NewRootNode(args Args, c *contentenc.ContentEnc, n *nametransform.NameTransform) *RootNode
func (*RootNode) AfterUnmount ¶
func (rn *RootNode) AfterUnmount()
main.doMount() calls this after unmount
func (*RootNode) DecryptPath ¶
DecryptPath implements ctlsock.Backend
DecryptPath is symlink-safe because openBackingDir() and decryptPathAt() are symlink-safe.