fuse

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2018 License: AGPL-3.0 Imports: 16 Imported by: 0

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

This section is empty.

Functions

This section is empty.

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

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. It will have the path "/".

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) (*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.

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) *MountTable

NewMountTable returns an empty mount table.

func (*MountTable) AddMount

func (t *MountTable) AddMount(path string) (*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.

Jump to

Keyboard shortcuts

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