sisyphus: github.com/ev3go/sisyphus Index | Files

package sisyphus

import "github.com/ev3go/sisyphus"

Package sisyphus provides tools to build a simple user FUSE-based sysfs-like interface.

Index

Package Files

dir.go fs.go ro_node.go rw_node.go sisyphus.go wo_node.go

Variables

var ErrBadName = errors.New("sisyphus: base contains filepath separator")

ErrBadName is returned when a new Node is created with a base name that contains a filepath separator.

func Serve Uses

func Serve(mnt string, filesys *FileSystem, config *fs.Config, mntopts ...fuse.MountOption) (io.Closer, error)

Serve starts a server for filesys mounted at the specified mount point. It is the responsibility of the caller to close the returned io.Closer when the server is no longer required.

type Bytes Uses

type Bytes []byte

Bytes is a ReadWriter backed by a byte slice.

func NewBytes Uses

func NewBytes(data []byte) *Bytes

NewBytes returns a new Bytes backed by the provided data.

func (*Bytes) ReadAt Uses

func (f *Bytes) ReadAt(b []byte, offset int64) (int, error)

ReadAt satisfies the io.ReaderAt interface.

func (*Bytes) Size Uses

func (f *Bytes) Size() (int64, error)

Size returns the length of the backing data and a nil error.

func (*Bytes) Truncate Uses

func (f *Bytes) Truncate(n int64) error

Truncate truncates the Bytes at n bytes from the beginning of the slice.

func (*Bytes) WriteAt Uses

func (f *Bytes) WriteAt(b []byte, off int64) (int, error)

WriteAt satisfies the io.WriterAt interface.

type Dir Uses

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

Dir is a directory node.

func MustNewDir Uses

func MustNewDir(name string, mode os.FileMode) *Dir

MustNewDir returns a new Dir with the given name and file mode. It will panic if name contains a filepath separator unless name is "/".

func NewDir Uses

func NewDir(name string, mode os.FileMode) (*Dir, error)

NewDir returns a new Dir with the given name and file mode.

func (*Dir) Attr Uses

func (d *Dir) Attr(ctx context.Context, a *fuse.Attr) error

Attr satisfies the bazil.org/fuse/fs.Node interface.

func (*Dir) Invalidate Uses

func (d *Dir) Invalidate() error

Invalidate invalidates the kernel cache of the directory.

func (*Dir) Lookup Uses

func (d *Dir) Lookup(ctx context.Context, name string) (fs.Node, error)

Lookup satisfies the bazil.org/fuse/NodeStringLookuper.Node interface.

func (*Dir) Name Uses

func (d *Dir) Name() string

Name returns the name of the directory.

func (*Dir) Own Uses

func (d *Dir) Own(uid, gid uint32) *Dir

Own sets the uid and gid of the directory.

func (*Dir) ReadDirAll Uses

func (d *Dir) ReadDirAll(ctx context.Context) ([]fuse.Dirent, error)

ReadDirAll satisfies the bazil.org/fuse/HandleReadDirAller.Node interface.

func (*Dir) SetSys Uses

func (d *Dir) SetSys(filesys *FileSystem)

SetSys sets the directory's containing file system.

func (*Dir) Sys Uses

func (d *Dir) Sys() *FileSystem

Sys returns the directory's containing filesystem.

func (*Dir) With Uses

func (d *Dir) With(nodes ...Node) Node

With adds nodes to the dirctory. If with is used the FileSystem Sync method should be called when all nodes have been added.

type FileSystem Uses

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

FileSystem is a virtual file system.

func NewFileSystem Uses

func NewFileSystem(mode os.FileMode, clock func() time.Time) *FileSystem

NewFileSystem returns a new file system setting the mode of the root and the clock.

func (*FileSystem) Bind Uses

func (fs *FileSystem) Bind(dir string, n Node) error

Bind binds the node at the given directory path.

func (*FileSystem) Invalidate Uses

func (fs *FileSystem) Invalidate(n Node) error

Invalidate invalidates the kernel cache of the given node.

func (*FileSystem) InvalidatePath Uses

func (fs *FileSystem) InvalidatePath(path string) error

InvalidatePath invalidates the kernel cache of the node at the given path.

func (*FileSystem) Root Uses

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

Root satisfies the bazil.org/fuse/fs.FS interface.

func (*FileSystem) Sync Uses

func (fs *FileSystem) Sync() *FileSystem

Sync updates all internal data links within the file system. Sync must be called if a file system has been constructed using With.

func (*FileSystem) Unbind Uses

func (fs *FileSystem) Unbind(path string) (Node, error)

Unbind unbinds to node at the given path, returning the node if successful.

func (*FileSystem) With Uses

func (fs *FileSystem) With(nodes ...Node) *FileSystem

With adds nodes to the file system's root.

type Func Uses

type Func func([]byte, int64) (int, error)

Func is a Writer backed by a user defined function.

func (Func) Size Uses

func (f Func) Size() (int64, error)

Size returns zero and a nil error.

func (Func) Truncate Uses

func (f Func) Truncate(_ int64) error

Truncate is a no-op.

func (Func) WriteAt Uses

func (f Func) WriteAt(b []byte, off int64) (int, error)

WriteAt satisfies the io.WriterAt interface.

type Node Uses

type Node interface {
    fs.Node

    // Name returns the name of the node.
    Name() string

    // Sys returns a pointer to the FileSystem
    // holding the Node.
    Sys() *FileSystem

    // SetSys sets the pointer to the FileSystem
    // holding the node. SetSys must accept a nil
    // parameter.
    SetSys(*FileSystem)
}

Node is a node in a FileSystem.

type RO Uses

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

RO is a read only file node.

func MustNewRO Uses

func MustNewRO(name string, mode os.FileMode, dev Reader) *RO

MustNewRO returns a new RO with the given name and file mode. It will panic if name contains a filepath separator.

func NewRO Uses

func NewRO(name string, mode os.FileMode, dev Reader) (*RO, error)

NewRO returns a new RO file with the given name and file mode.

func (*RO) Attr Uses

func (f *RO) Attr(ctx context.Context, a *fuse.Attr) error

Attr satisfies the bazil.org/fuse/fs.Node interface.

func (*RO) Invalidate Uses

func (f *RO) Invalidate() error

Invalidate invalidates the kernel cache of the file.

func (*RO) Name Uses

func (f *RO) Name() string

Name returns the name of the file.

func (*RO) Open Uses

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

Open satisfies the bazil.org/fuse/fs.NodeOpener interface.

func (*RO) Own Uses

func (f *RO) Own(uid, gid uint32) *RO

Own sets the uid and gid of the file.

func (*RO) Read Uses

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

Read satisfies the bazil.org/fuse/fs.HandleReader interface.

func (*RO) Release Uses

func (f *RO) Release(ctx context.Context, req *fuse.ReleaseRequest) error

Release satisfies the bazil.org/fuse/fs.HandleReleaser interface. If the RO Reader device is an io.Closer, its Close method is called.

func (*RO) SetSys Uses

func (f *RO) SetSys(filesys *FileSystem)

SetSys sets the file's containing file system.

func (*RO) Sys Uses

func (f *RO) Sys() *FileSystem

Sys returns the file's containing filesystem.

type RW Uses

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

RW is a read write file node.

func MustNewRW Uses

func MustNewRW(name string, mode os.FileMode, dev ReadWriter) *RW

MustNewRW returns a new RW with the given name and file mode. It will panic if name contains a filepath separator.

func NewRW Uses

func NewRW(name string, mode os.FileMode, dev ReadWriter) (*RW, error)

NewRW returns a new RW file with the given name and file mode.

func (*RW) Attr Uses

func (f *RW) Attr(ctx context.Context, a *fuse.Attr) error

Attr satisfies the bazil.org/fuse/fs.Node interface.

func (*RW) Flush Uses

func (f *RW) Flush(ctx context.Context, req *fuse.FlushRequest) error

Flush satisfies the bazil.org/fuse/fs.HandleFlusher interface.

func (*RW) Invalidate Uses

func (f *RW) Invalidate() error

Invalidate invalidates the kernel cache of the file.

func (*RW) Name Uses

func (f *RW) Name() string

Name returns the name of the file.

func (*RW) Open Uses

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

Open satisfies the bazil.org/fuse/fs.NodeOpener interface.

func (*RW) Own Uses

func (f *RW) Own(uid, gid uint32) *RW

Own sets the uid and gid of the file.

func (*RW) Read Uses

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

Read satisfies the bazil.org/fuse/fs.HandleReader interface.

func (*RW) Release Uses

func (f *RW) Release(ctx context.Context, req *fuse.ReleaseRequest) error

Release satisfies the bazil.org/fuse/fs.HandleReleaser interface. If the RW ReadWriter device is an io.Closer, its Close method is called.

func (*RW) SetSys Uses

func (f *RW) SetSys(filesys *FileSystem)

SetSys sets the file's containing file system.

func (*RW) Setattr Uses

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

Setattr satisfies the bazil.org/fuse/fs.NodeSetattrer interface.

func (*RW) Sys Uses

func (f *RW) Sys() *FileSystem

Sys returns the file's containing filesystem.

func (*RW) Write Uses

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

Write satisfies the bazil.org/fuse/fs.HandleWriter interface.

type ReadWriter Uses

type ReadWriter interface {
    io.ReaderAt
    io.WriterAt
    Truncate(int64) error
    Size() (int64, error)
}

ReadWriter is the data interface for a read write file.

type Reader Uses

type Reader interface {
    io.ReaderAt
    Size() (int64, error)
}

Reader is the data interface for a read only file.

type String Uses

type String string

String is a Reader backed by a string.

func (String) ReadAt Uses

func (s String) ReadAt(b []byte, off int64) (int, error)

ReadAt satisfies the io.ReaderAt interface.

func (String) Size Uses

func (s String) Size() (int64, error)

Size returns the length of the backing string and a nil error.

type WO Uses

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

WO is a write only file node.

func MustNewWO Uses

func MustNewWO(name string, mode os.FileMode, dev Writer) *WO

MustNewWO returns a new RO with the given name and file mode. It will panic if name contains a filepath separator.

func NewWO Uses

func NewWO(name string, mode os.FileMode, dev Writer) (*WO, error)

NewWO returns a new WO file with the given name and file mode.

func (*WO) Attr Uses

func (f *WO) Attr(ctx context.Context, a *fuse.Attr) error

Attr satisfies the bazil.org/fuse/fs.Node interface.

func (*WO) Flush Uses

func (f *WO) Flush(ctx context.Context, req *fuse.FlushRequest) error

Flush satisfies the bazil.org/fuse/fs.HandleFlusher interface.

func (*WO) Invalidate Uses

func (f *WO) Invalidate() error

Invalidate invalidates the kernel cache of the file.

func (*WO) Name Uses

func (f *WO) Name() string

Name returns the name of the file.

func (*WO) Open Uses

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

Open satisfies the bazil.org/fuse/fs.NodeOpener interface.

func (*WO) Own Uses

func (f *WO) Own(uid, gid uint32) *WO

Own sets the uid and gid of the file.

func (*WO) Release Uses

func (f *WO) Release(ctx context.Context, req *fuse.ReleaseRequest) error

Release satisfies the bazil.org/fuse/fs.HandleReleaser interface. If the WO Writer device is an io.Closer, its Close method is called.

func (*WO) SetSys Uses

func (f *WO) SetSys(filesys *FileSystem)

SetSys sets the file's containing file system.

func (*WO) Setattr Uses

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

Setattr satisfies the bazil.org/fuse/fs.NodeSetattrer interface.

func (*WO) Sys Uses

func (f *WO) Sys() *FileSystem

Sys returns the file's containing filesystem.

func (*WO) Write Uses

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

Write satisfies the bazil.org/fuse/fs.HandleWriter interface.

type Writer Uses

type Writer interface {
    io.WriterAt
    Truncate(int64) error
    Size() (int64, error)
}

Writer is the data interface for a write only file.

Package sisyphus imports 11 packages (graph). Updated 2020-12-03. Refresh now. Tools for package owners.