Documentation
¶
Overview ¶
Package bcfuse implements a filesystem interface for blobcache. bcfuse handles the frontend components of a filesystem, like FUSE and NFS mounting. The backend is provided by a blobcache volume. Translating the filesystem operations into blobcache operations is handled by a Scheme. bcfuse provides write buffering before the data is flushed to the volume.
Index ¶
- func SetupDB(ctx context.Context, db *sqlx.DB) error
- func TestFS[K comparable](t *testing.T, newScheme func(testing.TB) Scheme[K])
- type DirEntry
- type Extent
- type FS
- func (fsx *FS[K]) FUSERoot() *Node[K]
- func (fs *FS[K]) Flush(ctx context.Context) error
- func (fs *FS[K]) GetID(ino int64) (K, bool)
- func (fs *FS[K]) GetInode(id K) int64
- func (fs *FS[K]) GetOrCreateInode(id K) int64
- func (fs *FS[K]) PutExtent(ctx context.Context, id K, startAt int64, data []byte) error
- type Node
- func (n *Node[K]) Create(ctx context.Context, name string, flags uint32, mode uint32, ...) (node *fs.Inode, fh fs.FileHandle, fuseFlags uint32, errno syscall.Errno)
- func (n *Node[K]) Getattr(ctx context.Context, f fs.FileHandle, out *fuse.AttrOut) syscall.Errno
- func (n *Node[K]) Lookup(ctx context.Context, name string, out *fuse.EntryOut) (*fs.Inode, syscall.Errno)
- func (n *Node[K]) Read(ctx context.Context, f fs.FileHandle, dest []byte, off int64) (fuse.ReadResult, syscall.Errno)
- func (n *Node[K]) Readdir(ctx context.Context) (fs.DirStream, syscall.Errno)
- func (n *Node[K]) Unlink(ctx context.Context, name string) syscall.Errno
- func (n *Node[K]) Write(ctx context.Context, f fs.FileHandle, data []byte, off int64) (written uint32, errno syscall.Errno)
- type Scheme
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type DirEntry ¶
type DirEntry[K comparable] struct { Name string Child K Mode uint32 }
DirEntry represents a directory entry with generic ID
type Extent ¶
type Extent[K comparable] struct { ID K Start int64 Data []byte }
Extent represents a data extent with generic ID
type FS ¶
type FS[K comparable] struct { // contains filtered or unexported fields }
FS represents the filesystem with thread-safe operations
func New ¶
func New[K comparable](db *sqlx.DB, svc blobcache.Service, vol blobcache.Handle, scheme Scheme[K]) *FS[K]
New creates a new filesystem instance
func (*FS[K]) GetOrCreateInode ¶
GetOrCreateInode returns the POSIX inode for a scheme identifier, creating one if needed
type Node ¶
type Node[K comparable] struct { fs.Inode // contains filtered or unexported fields }
Node represents a FUSE node with generic filesystem reference
func (*Node[K]) Create ¶
func (n *Node[K]) Create(ctx context.Context, name string, flags uint32, mode uint32, out *fuse.EntryOut) (node *fs.Inode, fh fs.FileHandle, fuseFlags uint32, errno syscall.Errno)
Create creates a new file
func (*Node[K]) Lookup ¶
func (n *Node[K]) Lookup(ctx context.Context, name string, out *fuse.EntryOut) (*fs.Inode, syscall.Errno)
Lookup finds a child node by name
func (*Node[K]) Read ¶
func (n *Node[K]) Read(ctx context.Context, f fs.FileHandle, dest []byte, off int64) (fuse.ReadResult, syscall.Errno)
Read reads file data
type Scheme ¶
type Scheme[K comparable] interface { // FlushExtents writes all the extents to the volume. FlushExtents(ctx context.Context, dst cadata.PostExister, src cadata.Getter, root []byte, extents []Extent[K]) ([]byte, error) // ReadFile reads a file from the volume by identifier into the provided buffer ReadFile(ctx context.Context, src cadata.Getter, root []byte, id K, buf []byte) (int, error) // ReadDir reads directory entries for the given identifier ReadDir(ctx context.Context, src cadata.Getter, root []byte, id K) ([]DirEntry[K], error) // CreateAt creates a new file in the directory CreateAt(ctx context.Context, dst cadata.PostExister, src cadata.Getter, root []byte, parentID K, name string, mode uint32) (K, []byte, error) // DeleteAt removes a file from the directory DeleteAt(ctx context.Context, dst cadata.PostExister, src cadata.Getter, root []byte, parentID K, name string) ([]byte, error) }
Scheme handles filesystem operations on blobcache volumes. All reading methods follow the pattern: func(ctx context.Context, src cadata.Getter, root []byte, ...) (..., error) All writing methods follow the pattern: func(ctx context.Context, dst cadata.PostExister, src cadata.Getter, root []byte, ...) (..., []byte, error)