fuse

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2019 License: AGPL-3.0 Imports: 21 Imported by: 1

Documentation

Overview

Package fuse implements a FUSE layer for brig. Using it, a repository may be represented as a "normal" directory. There are three different structs in the FUSE API:

  • fuse.Node : A file or a directory (depending on it's type)
  • fuse.FS : The filesystem. Used to find out the root node.
  • fuse.Handle: An open file.

This implementation offers File (a fuse.Node and fuse.Handle), Dir (fuse.Node) and FS (fuse.FS).

Fuse will call the respective handlers if it needs information about your nodes. Each request handlers will usually get a `ctx` used to cancel operations, a request structure `req` with detailed query infos and a response structure `resp` where results are written. Usually the request handlers might return an error or a new node/handle/fs.

Every request handle that may run for a long time should be made interruptible. Especially read and write operations should check the ctx.Done() channel passed to each request handler.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotCached = errors.New("content is not cached and may not download")
)

Functions

func FsTabAdd added in v0.2.0

func FsTabAdd(cfg *config.Config, name, path string, opts MountOptions) error

FsTabAdd adds the mount at `path` with `name` and `opts` to `cfg`. It does not yet do the mounting.

func FsTabApply added in v0.2.0

func FsTabApply(cfg *config.Config, mounts *MountTable) error

FsTabApply takes all configured mounts and makes sure that all of them are opened.

func FsTabRemove added in v0.2.0

func FsTabRemove(cfg *config.Config, name string) error

FsTabRemove removes a mount. It does not directly unmount it, call FsTabApply for this.

func FsTabUnmountAll added in v0.2.0

func FsTabUnmountAll(cfg *config.Config, mounts *MountTable) error

FsTabUnmountAll will unmount all currently mounted mounts.

Types

type Directory

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

Directory represents a directory node.

func (*Directory) Attr

func (dir *Directory) Attr(ctx context.Context, attr *fuse.Attr) error

Attr is called to retrieve stat-metadata about the directory.

func (*Directory) Create

func (dir *Directory) Create(ctx context.Context, req *fuse.CreateRequest, resp *fuse.CreateResponse) (fs.Node, fs.Handle, error)

Create is called to create an opened file or directory as child of the receiver.

func (*Directory) Getxattr

func (dir *Directory) Getxattr(ctx context.Context, req *fuse.GetxattrRequest, resp *fuse.GetxattrResponse) error

Getxattr is called to get a single xattr (extended attribute) of a file.

func (*Directory) Listxattr

func (dir *Directory) Listxattr(ctx context.Context, req *fuse.ListxattrRequest, resp *fuse.ListxattrResponse) error

Listxattr is called to list all xattrs of this file.

func (*Directory) Lookup

func (dir *Directory) Lookup(ctx context.Context, name string) (fs.Node, error)

Lookup is called to lookup a direct child of the directory.

func (*Directory) Mkdir

func (dir *Directory) Mkdir(ctx context.Context, req *fuse.MkdirRequest) (fs.Node, error)

Mkdir is called to create a new directory node inside the receiver.

func (*Directory) ReadDirAll

func (dir *Directory) ReadDirAll(ctx context.Context) ([]fuse.Dirent, error)

ReadDirAll is called to get a directory listing of the receiver.

func (*Directory) Remove

func (dir *Directory) Remove(ctx context.Context, req *fuse.RemoveRequest) error

Remove is called when a direct child in the directory needs to be removed.

type File

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

File is a file inside a directory.

func (*File) Attr

func (fi *File) Attr(ctx context.Context, attr *fuse.Attr) error

Attr is called to get the stat(2) attributes of a file.

func (*File) Fsync

func (fi *File) Fsync(ctx context.Context, req *fuse.FsyncRequest) error

Fsync is called when any open buffers need to be written to disk. Currently, fsync is completely ignored.

func (*File) Getxattr

func (fi *File) Getxattr(ctx context.Context, req *fuse.GetxattrRequest, resp *fuse.GetxattrResponse) error

Getxattr is called to get a single xattr (extended attribute) of a file.

func (*File) Listxattr

func (fi *File) Listxattr(ctx context.Context, req *fuse.ListxattrRequest, resp *fuse.ListxattrResponse) error

Listxattr is called to list all xattrs of this file.

func (*File) Open

func (fi *File) Open(ctx context.Context, req *fuse.OpenRequest, resp *fuse.OpenResponse) (fs.Handle, error)

Open is called to get an opened handle of a file, suitable for reading and writing.

func (*File) Rename

func (fi *File) Rename(ctx context.Context, req *fuse.RenameRequest, newDir fs.Node) error

Rename is called when the node changed its path.

func (*File) Setattr

func (fi *File) Setattr(ctx context.Context, req *fuse.SetattrRequest, resp *fuse.SetattrResponse) error

Setattr is called once an attribute of a file changes. Most importantly, size changes are reported here, e.g. after truncating a file, the size change is noticed here before Open() is called.

type Filesystem

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

Filesystem is the entry point to the fuse filesystem

func (*Filesystem) Root

func (fs *Filesystem) Root() (fs.Node, error)

Root returns the topmost directory node. This depends on what the user choose to select, but usually it's "/".

type FsTabEntry added in v0.2.0

type FsTabEntry struct {
	Name     string
	Path     string
	Root     string
	Active   bool
	ReadOnly bool
	Offline  bool
}

FsTabEntry is a representation of one entry in the filesystem tab.

func FsTabList added in v0.2.0

func FsTabList(cfg *config.Config, mounts *MountTable) ([]FsTabEntry, error)

FsTabList lists all entries in the filesystem tab in a nice way.

type Handle

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

Handle is an open Entry.

func (*Handle) Flush

func (hd *Handle) Flush(ctx context.Context, req *fuse.FlushRequest) error

Flush is called to make sure all written contents get synced to disk.

func (*Handle) Read

func (hd *Handle) Read(ctx context.Context, req *fuse.ReadRequest, resp *fuse.ReadResponse) error

Read is called to read a block of data at a certain offset.

func (*Handle) Release

func (hd *Handle) Release(ctx context.Context, req *fuse.ReleaseRequest) error

Release is called to close this handle.

func (*Handle) Write

func (hd *Handle) Write(ctx context.Context, req *fuse.WriteRequest, resp *fuse.WriteResponse) error

Write is called to write a block of data at a certain offset.

type Mount

type Mount struct {
	Dir string
	// contains filtered or unexported fields
}

Mount represents a fuse endpoint on the filesystem. It is used as top-level API to control a brigfs fuse mount.

func NewMount

func NewMount(cfs *catfs.FS, mountpoint string, notifier Notifier, opts MountOptions) (*Mount, error)

NewMount mounts a fuse endpoint at `mountpoint` retrieving data from `store`.

func (*Mount) Close

func (m *Mount) Close() error

Close will wait until all I/O operations are done and unmount the fuse mount again.

func (*Mount) EqualOptions added in v0.2.0

func (m *Mount) EqualOptions(opts MountOptions) bool

EqualOptions returns true when the options in `opts` have the same option as currently set in the mount. If so, no re-mount is required.

type MountOptions added in v0.2.0

type MountOptions struct {
	// ReadOnly makes the mount not modifyable
	ReadOnly bool
	// Root determines what the root directory is.
	Root string
	// Offline tells the mount to error out on files that would need
	// to be fetched from far.
	Offline bool
}

MountOptions defines all possible knobs you can turn for a mount. The zero value are the default options.

type MountTable

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

MountTable is a mapping from the mountpoint to the respective `Mount` struct. It's given as convenient way to maintain several mounts. All operations on the table are safe to call from several goroutines.

func NewMountTable

func NewMountTable(fs *catfs.FS, notifier Notifier) *MountTable

NewMountTable returns an empty mount table.

func (*MountTable) AddMount

func (t *MountTable) AddMount(path string, opts MountOptions) (*Mount, error)

AddMount calls NewMount and adds it to the table at `path`.

func (*MountTable) Close

func (t *MountTable) Close() error

Close unmounts all leftover mounts and clears the table.

func (*MountTable) Unmount

func (t *MountTable) Unmount(path string) error

Unmount closes the mount at `path` and deletes it from the table.

type Notifier added in v0.4.0

type Notifier interface {
	// PublishEvent is called whenever a modification happens.
	PublishEvent()
}

Notifier implementors can take notifications from any events happening in the fuse mount.

Jump to

Keyboard shortcuts

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