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 ¶
- func FsTabAdd(cfg *config.Config, name, path string, opts MountOptions) error
- func FsTabApply(cfg *config.Config, mounts *MountTable) error
- func FsTabRemove(cfg *config.Config, name string) error
- func FsTabUnmountAll(cfg *config.Config, mounts *MountTable) error
- type Directory
- func (dir *Directory) Attr(ctx context.Context, attr *fuse.Attr) error
- func (dir *Directory) Create(ctx context.Context, req *fuse.CreateRequest, resp *fuse.CreateResponse) (fs.Node, fs.Handle, error)
- func (dir *Directory) Getxattr(ctx context.Context, req *fuse.GetxattrRequest, resp *fuse.GetxattrResponse) error
- func (dir *Directory) Listxattr(ctx context.Context, req *fuse.ListxattrRequest, resp *fuse.ListxattrResponse) error
- func (dir *Directory) Lookup(ctx context.Context, name string) (fs.Node, error)
- func (dir *Directory) Mkdir(ctx context.Context, req *fuse.MkdirRequest) (fs.Node, error)
- func (dir *Directory) ReadDirAll(ctx context.Context) ([]fuse.Dirent, error)
- func (dir *Directory) Remove(ctx context.Context, req *fuse.RemoveRequest) error
- type File
- func (fi *File) Attr(ctx context.Context, attr *fuse.Attr) error
- func (fi *File) Fsync(ctx context.Context, req *fuse.FsyncRequest) error
- func (fi *File) Getxattr(ctx context.Context, req *fuse.GetxattrRequest, resp *fuse.GetxattrResponse) error
- func (fi *File) Listxattr(ctx context.Context, req *fuse.ListxattrRequest, resp *fuse.ListxattrResponse) error
- func (fi *File) Open(ctx context.Context, req *fuse.OpenRequest, resp *fuse.OpenResponse) (fs.Handle, error)
- func (fi *File) Rename(ctx context.Context, req *fuse.RenameRequest, newDir fs.Node) error
- func (fi *File) Setattr(ctx context.Context, req *fuse.SetattrRequest, resp *fuse.SetattrResponse) error
- type Filesystem
- type FsTabEntry
- type Handle
- func (hd *Handle) Flush(ctx context.Context, req *fuse.FlushRequest) error
- func (hd *Handle) Read(ctx context.Context, req *fuse.ReadRequest, resp *fuse.ReadResponse) error
- func (hd *Handle) Release(ctx context.Context, req *fuse.ReleaseRequest) error
- func (hd *Handle) Write(ctx context.Context, req *fuse.WriteRequest, resp *fuse.WriteResponse) error
- type Mount
- type MountOptions
- type MountTable
Constants ¶
This section is empty.
Variables ¶
This section is empty.
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
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) 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) ReadDirAll ¶
ReadDirAll is called to get a directory listing of the receiver.
type File ¶
type File struct {
// contains filtered or unexported fields
}
File is a file inside a directory.
func (*File) Fsync ¶
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) 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
type FsTabEntry ¶ added in v0.2.0
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) 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) 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 (*Mount) Close ¶
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 }
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) *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.