Documentation ¶
Overview ¶
Package sisyphus provides tools to build a simple user FUSE-based sysfs-like interface.
Index ¶
- Variables
- func Serve(mnt string, filesys *FileSystem, config *fs.Config, ...) (io.Closer, error)
- type Bytes
- type Dir
- func (d *Dir) Attr(ctx context.Context, a *fuse.Attr) error
- func (d *Dir) Invalidate() error
- func (d *Dir) Lookup(ctx context.Context, name string) (fs.Node, error)
- func (d *Dir) Name() string
- func (d *Dir) Own(uid, gid uint32) *Dir
- func (d *Dir) ReadDirAll(ctx context.Context) ([]fuse.Dirent, error)
- func (d *Dir) SetSys(filesys *FileSystem)
- func (d *Dir) Sys() *FileSystem
- func (d *Dir) With(nodes ...Node) Node
- type FileSystem
- func (fs *FileSystem) Bind(dir string, n Node) error
- func (fs *FileSystem) Invalidate(n Node) error
- func (fs *FileSystem) InvalidatePath(path string) error
- func (fs *FileSystem) Root() (fs.Node, error)
- func (fs *FileSystem) Sync() *FileSystem
- func (fs *FileSystem) Unbind(path string) (Node, error)
- func (fs *FileSystem) With(nodes ...Node) *FileSystem
- type Func
- type Node
- type RO
- func MustNewRO(name string, mode os.FileMode, dev Reader) *RO
- func MustNewROFlags(name string, mode os.FileMode, flags fuse.OpenResponseFlags, dev Reader) *RO
- func NewRO(name string, mode os.FileMode, dev Reader) (*RO, error)
- func NewROFlags(name string, mode os.FileMode, flags fuse.OpenResponseFlags, dev Reader) (*RO, error)
- func (f *RO) Attr(ctx context.Context, a *fuse.Attr) error
- func (f *RO) Invalidate() error
- func (f *RO) Name() string
- func (f *RO) Open(ctx context.Context, req *fuse.OpenRequest, resp *fuse.OpenResponse) (fs.Handle, error)
- func (f *RO) Own(uid, gid uint32) *RO
- func (f *RO) Read(ctx context.Context, req *fuse.ReadRequest, resp *fuse.ReadResponse) error
- func (f *RO) Release(ctx context.Context, req *fuse.ReleaseRequest) error
- func (f *RO) SetSys(filesys *FileSystem)
- func (f *RO) Sys() *FileSystem
- type RW
- func MustNewRW(name string, mode os.FileMode, dev ReadWriter) *RW
- func MustNewRWFlags(name string, mode os.FileMode, flags fuse.OpenResponseFlags, dev ReadWriter) *RW
- func NewRW(name string, mode os.FileMode, dev ReadWriter) (*RW, error)
- func NewRWFlags(name string, mode os.FileMode, flags fuse.OpenResponseFlags, dev ReadWriter) (*RW, error)
- func (f *RW) Attr(ctx context.Context, a *fuse.Attr) error
- func (f *RW) Flush(ctx context.Context, req *fuse.FlushRequest) error
- func (f *RW) Invalidate() error
- func (f *RW) Name() string
- func (f *RW) Open(ctx context.Context, req *fuse.OpenRequest, resp *fuse.OpenResponse) (fs.Handle, error)
- func (f *RW) Own(uid, gid uint32) *RW
- func (f *RW) Read(ctx context.Context, req *fuse.ReadRequest, resp *fuse.ReadResponse) error
- func (f *RW) Release(ctx context.Context, req *fuse.ReleaseRequest) error
- func (f *RW) SetSys(filesys *FileSystem)
- func (f *RW) Setattr(ctx context.Context, req *fuse.SetattrRequest, resp *fuse.SetattrResponse) error
- func (f *RW) Sys() *FileSystem
- func (f *RW) Write(ctx context.Context, req *fuse.WriteRequest, resp *fuse.WriteResponse) error
- type ReadWriter
- type Reader
- type String
- type WO
- func MustNewWO(name string, mode os.FileMode, dev Writer) *WO
- func MustNewWOFlags(name string, mode os.FileMode, flags fuse.OpenResponseFlags, dev Writer) *WO
- func NewWO(name string, mode os.FileMode, dev Writer) (*WO, error)
- func NewWOFlags(name string, mode os.FileMode, flags fuse.OpenResponseFlags, dev Writer) (*WO, error)
- func (f *WO) Attr(ctx context.Context, a *fuse.Attr) error
- func (f *WO) Flush(ctx context.Context, req *fuse.FlushRequest) error
- func (f *WO) Invalidate() error
- func (f *WO) Name() string
- func (f *WO) Open(ctx context.Context, req *fuse.OpenRequest, resp *fuse.OpenResponse) (fs.Handle, error)
- func (f *WO) Own(uid, gid uint32) *WO
- func (f *WO) Release(ctx context.Context, req *fuse.ReleaseRequest) error
- func (f *WO) SetSys(filesys *FileSystem)
- func (f *WO) Setattr(ctx context.Context, req *fuse.SetattrRequest, resp *fuse.SetattrResponse) error
- func (f *WO) Sys() *FileSystem
- func (f *WO) Write(ctx context.Context, req *fuse.WriteRequest, resp *fuse.WriteResponse) error
- type Writer
Constants ¶
This section is empty.
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.
Functions ¶
func Serve ¶
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.
Types ¶
type Bytes ¶
type Bytes []byte
Bytes is a ReadWriter backed by a byte slice.
type Dir ¶
type Dir struct {
// contains filtered or unexported fields
}
Dir is a directory node.
func MustNewDir ¶
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 (*Dir) Invalidate ¶
Invalidate invalidates the kernel cache of the directory.
func (*Dir) ReadDirAll ¶
ReadDirAll satisfies the bazil.org/fuse/HandleReadDirAller.Node interface.
func (*Dir) SetSys ¶
func (d *Dir) SetSys(filesys *FileSystem)
SetSys sets the directory's containing file system.
func (*Dir) Sys ¶
func (d *Dir) Sys() *FileSystem
Sys returns the directory's containing filesystem.
type FileSystem ¶
type FileSystem struct {
// contains filtered or unexported fields
}
FileSystem is a virtual file system.
func NewFileSystem ¶
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 ¶
func (fs *FileSystem) Bind(dir string, n Node) error
Bind binds the node at the given directory path.
func (*FileSystem) Invalidate ¶
func (fs *FileSystem) Invalidate(n Node) error
Invalidate invalidates the kernel cache of the given node.
func (*FileSystem) InvalidatePath ¶
func (fs *FileSystem) InvalidatePath(path string) error
InvalidatePath invalidates the kernel cache of the node at the given path.
func (*FileSystem) Root ¶
func (fs *FileSystem) Root() (fs.Node, error)
Root satisfies the bazil.org/fuse/fs.FS interface.
func (*FileSystem) Sync ¶
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 ¶
func (fs *FileSystem) Unbind(path string) (Node, error)
Unbind unbinds to node at the given path, returning the node if successful.
func (*FileSystem) With ¶
func (fs *FileSystem) With(nodes ...Node) *FileSystem
With adds nodes to the file system's root.
type Node ¶
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 ¶
type RO struct {
// contains filtered or unexported fields
}
RO is a read only file node.
func MustNewRO ¶
MustNewRO returns a new RO with the given name and file mode. It will panic if name contains a filepath separator.
func MustNewROFlags ¶
MustNewRO returns a new RO with the given name and file mode. It will panic if name contains a filepath separator. The provided flags are used when opening the RO node.
func NewROFlags ¶
func NewROFlags(name string, mode os.FileMode, flags fuse.OpenResponseFlags, dev Reader) (*RO, error)
NewRO returns a new RO file with the given name and file mode. The provided flags are used when opening the RO node.
func (*RO) Invalidate ¶
Invalidate invalidates the kernel cache of the file.
func (*RO) Open ¶
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) Read ¶
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 ¶
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 ¶
func (f *RO) SetSys(filesys *FileSystem)
SetSys sets the file's containing file system.
type RW ¶
type RW struct {
// contains filtered or unexported fields
}
RW is a read write file node.
func MustNewRW ¶
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 MustNewRWFlags ¶
func MustNewRWFlags(name string, mode os.FileMode, flags fuse.OpenResponseFlags, dev ReadWriter) *RW
MustNewRWFlags returns a new RW with the given name and file mode. It will panic if name contains a filepath separator. The provided flags are used when opening the RW node.
func NewRWFlags ¶
func NewRWFlags(name string, mode os.FileMode, flags fuse.OpenResponseFlags, dev ReadWriter) (*RW, error)
NewRWFlags returns a new RW file with the given name and file mode. The provided flags are used when opening the RW node.
func (*RW) Invalidate ¶
Invalidate invalidates the kernel cache of the file.
func (*RW) Open ¶
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) Read ¶
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 ¶
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 ¶
func (f *RW) SetSys(filesys *FileSystem)
SetSys sets the file's containing file system.
func (*RW) Setattr ¶
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) Write ¶
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 ¶
ReadWriter is the data interface for a read write file.
type String ¶
type String string
String is a Reader backed by a string.
type WO ¶
type WO struct {
// contains filtered or unexported fields
}
WO is a write only file node.
func MustNewWO ¶
MustNewWO returns a new WO with the given name and file mode. It will panic if name contains a filepath separator.
func MustNewWOFlags ¶
MustNewWOFlags returns a new WO with the given name and file mode. It will panic if name contains a filepath separator. The provided flags are used when opening the WO node.
func NewWOFlags ¶
func NewWOFlags(name string, mode os.FileMode, flags fuse.OpenResponseFlags, dev Writer) (*WO, error)
NewWOFlags returns a new WO file with the given name and file mode. The provided flags are used when opening the WO node.
func (*WO) Invalidate ¶
Invalidate invalidates the kernel cache of the file.
func (*WO) Open ¶
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) Release ¶
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 ¶
func (f *WO) SetSys(filesys *FileSystem)
SetSys sets the file's containing file system.
func (*WO) Setattr ¶
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) Write ¶
func (f *WO) Write(ctx context.Context, req *fuse.WriteRequest, resp *fuse.WriteResponse) error
Write satisfies the bazil.org/fuse/fs.HandleWriter interface.