fusefrontend

package
v1.7.1 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2019 License: MIT Imports: 27 Imported by: 0

Documentation

Overview

Package fusefrontend interfaces directly with the go-fuse library.

Package fusefrontend interfaces directly with the go-fuse library.

Package fusefrontend interfaces directly with the go-fuse library.

Index

Constants

View Source
const FALLOC_DEFAULT = 0x00

FALLOC_DEFAULT is a "normal" fallocate operation

View Source
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
	// Try to serialize read operations, "-serialize_reads"
	SerializeReads bool
	// Force decode even if integrity check fails (openSSL only)
	ForceDecode 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
}

Args is a container for arguments that are passed from main() to fusefrontend

type FS

type FS struct {
	// Embed pathfs.defaultFileSystem to avoid compile failure when the
	// pathfs.FileSystem interface gets new functions. defaultFileSystem
	// provides a no-op implementation for all functions.
	pathfs.FileSystem

	// 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
	// This 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
}

FS implements the go-fuse virtual filesystem interface.

func NewFS

NewFS returns a new encrypted FUSE overlay filesystem.

func (*FS) Access

func (fs *FS) Access(relPath string, mode uint32, context *fuse.Context) (code fuse.Status)

Access - FUSE call. Check if a file can be accessed in the specified mode(s) (read, write, execute).

From https://github.com/libfuse/libfuse/blob/master/include/fuse.h :

> Check file access permissions > > If the 'default_permissions' mount option is given, this method is not > called.

We always enable default_permissions when -allow_other is passed, so there is no need for this function to check the uid in fuse.Context.

Symlink-safe through use of faccessat.

func (*FS) Chmod

func (fs *FS) Chmod(path string, mode uint32, context *fuse.Context) (code fuse.Status)

Chmod - FUSE call. Change permissions on "path".

Symlink-safe through use of Fchmodat().

func (*FS) Chown

func (fs *FS) Chown(path string, uid uint32, gid uint32, context *fuse.Context) (code fuse.Status)

Chown - FUSE call. Change the owner of "path".

Symlink-safe through use of Fchownat().

func (*FS) Create

func (fs *FS) Create(path string, flags uint32, mode uint32, context *fuse.Context) (nodefs.File, fuse.Status)

Create - FUSE call. Creates a new file.

Symlink-safe through the use of Openat().

func (*FS) DecryptPath added in v1.2.1

func (fs *FS) DecryptPath(cipherPath string) (plainPath string, err error)

DecryptPath implements ctlsock.Backend

DecryptPath is symlink-safe because openBackingDir() and decryptPathAt() are symlink-safe.

func (*FS) EncryptPath added in v1.2.1

func (fs *FS) EncryptPath(plainPath string) (string, error)

EncryptPath implements ctlsock.Backend

Symlink-safe through openBackingDir().

func (*FS) GetAttr

func (fs *FS) GetAttr(relPath string, context *fuse.Context) (*fuse.Attr, fuse.Status)

GetAttr implements pathfs.Filesystem.

GetAttr is symlink-safe through use of openBackingDir() and Fstatat().

func (*FS) GetXAttr

func (fs *FS) GetXAttr(relPath string, attr string, context *fuse.Context) ([]byte, fuse.Status)

GetXAttr - FUSE call. Reads the value of extended attribute "attr".

This function is symlink-safe through Fgetxattr.

func (fs *FS) Link(oldPath string, newPath string, context *fuse.Context) (code fuse.Status)

Link - FUSE call. Creates a hard link at "newPath" pointing to file "oldPath".

Symlink-safe through use of Linkat().

func (*FS) ListXAttr

func (fs *FS) ListXAttr(relPath string, context *fuse.Context) ([]string, fuse.Status)

ListXAttr - FUSE call. Lists extended attributes on the file at "relPath".

This function is symlink-safe through Flistxattr.

func (*FS) Mkdir

func (fs *FS) Mkdir(newPath string, mode uint32, context *fuse.Context) (code fuse.Status)

Mkdir - FUSE call. Create a directory at "newPath" with permissions "mode".

Symlink-safe through use of Mkdirat().

func (*FS) Mknod

func (fs *FS) Mknod(path string, mode uint32, dev uint32, context *fuse.Context) (code fuse.Status)

Mknod - FUSE call. Create a device file.

Symlink-safe through use of Mknodat().

func (*FS) Open

func (fs *FS) Open(path string, flags uint32, context *fuse.Context) (fuseFile nodefs.File, status fuse.Status)

Open - FUSE call. Open already-existing file.

Symlink-safe through Openat().

func (*FS) OpenDir

func (fs *FS) OpenDir(dirName string, context *fuse.Context) ([]fuse.DirEntry, fuse.Status)

OpenDir - FUSE call

This function is symlink-safe through use of openBackingDir() and ReadDirIVAt().

func (fs *FS) Readlink(relPath string, context *fuse.Context) (out string, status fuse.Status)

Readlink - FUSE call.

Symlink-safe through openBackingDir() + Readlinkat().

func (*FS) RemoveXAttr

func (fs *FS) RemoveXAttr(relPath string, attr string, context *fuse.Context) fuse.Status

RemoveXAttr - FUSE call.

This function is symlink-safe through Fremovexattr.

func (*FS) Rename

func (fs *FS) Rename(oldPath string, newPath string, context *fuse.Context) (code fuse.Status)

Rename - FUSE call.

Symlink-safe through Renameat().

func (*FS) Rmdir

func (fs *FS) Rmdir(relPath string, context *fuse.Context) (code fuse.Status)

Rmdir - FUSE call.

Symlink-safe through Unlinkat() + AT_REMOVEDIR.

func (*FS) SetXAttr

func (fs *FS) SetXAttr(relPath string, attr string, data []byte, flags int, context *fuse.Context) fuse.Status

SetXAttr - FUSE call. Set extended attribute.

This function is symlink-safe through Fsetxattr.

func (*FS) StatFs

func (fs *FS) StatFs(path string) *fuse.StatfsOut

StatFs - FUSE call. Returns information about the filesystem.

Symlink-safe because the passed path is ignored.

func (fs *FS) Symlink(target string, linkName string, context *fuse.Context) (code fuse.Status)

Symlink - FUSE call. Create a symlink.

Symlink-safe through use of Symlinkat.

func (*FS) Truncate

func (fs *FS) Truncate(path string, offset uint64, context *fuse.Context) (code fuse.Status)

Truncate - FUSE call. Truncates a file.

Support truncate(2) by opening the file and calling ftruncate(2) While the glibc "truncate" wrapper seems to always use ftruncate, fsstress from xfstests uses this a lot by calling "truncate64" directly.

Symlink-safe by letting file.Truncate() do all the work.

func (fs *FS) Unlink(path string, context *fuse.Context) (code fuse.Status)

Unlink - FUSE call. Delete a file.

Symlink-safe through use of Unlinkat().

func (*FS) Utimens

func (fs *FS) Utimens(path string, a *time.Time, m *time.Time, context *fuse.Context) (code fuse.Status)

Utimens - FUSE call. Set the timestamps on file "path".

Symlink-safe through UtimesNanoAt.

type File added in v1.6.1

type File struct {

	// We embed a nodefs.NewDefaultFile() that returns ENOSYS for every operation we
	// have not implemented. This prevents build breakage when the go-fuse library
	// adds new methods to the nodefs.File interface.
	nodefs.File
	// contains filtered or unexported fields
}

File - based on loopbackFile in go-fuse/fuse/nodefs/files.go

func NewFile

func NewFile(fd *os.File, fs *FS) (*File, fuse.Status)

NewFile returns a new go-fuse File instance.

func (*File) Allocate added in v1.6.1

func (f *File) Allocate(off uint64, sz uint64, mode uint32) fuse.Status

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) Chmod added in v1.6.1

func (f *File) Chmod(mode uint32) fuse.Status

Chmod FUSE call

func (*File) Chown added in v1.6.1

func (f *File) Chown(uid uint32, gid uint32) fuse.Status

Chown FUSE call

func (*File) Flush added in v1.6.1

func (f *File) Flush() fuse.Status

Flush - FUSE call

func (*File) Fsync added in v1.6.1

func (f *File) Fsync(flags int) (code fuse.Status)

Fsync FUSE call

func (*File) GetAttr added in v1.6.1

func (f *File) GetAttr(a *fuse.Attr) fuse.Status

GetAttr FUSE call (like stat)

func (*File) Read added in v1.6.1

func (f *File) Read(buf []byte, off int64) (resultData fuse.ReadResult, code fuse.Status)

Read - FUSE call

func (*File) Release added in v1.6.1

func (f *File) Release()

Release - FUSE call, close file

func (*File) SeekData added in v1.6.1

func (f *File) SeekData(oldOffset int64) (int64, error)

SeekData calls the lseek syscall with SEEK_DATA. It returns the offset of the next data bytes, skipping over file holes.

func (*File) Truncate added in v1.6.1

func (f *File) Truncate(newSize uint64) fuse.Status

Truncate - FUSE call

func (*File) Utimens added in v1.6.1

func (f *File) Utimens(a *time.Time, m *time.Time) fuse.Status

Utimens FUSE call

func (*File) Write added in v1.6.1

func (f *File) Write(data []byte, off int64) (uint32, fuse.Status)

Write - FUSE call

If the write creates a hole, pads the file to the next block boundary.

Jump to

Keyboard shortcuts

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