bcfuse

package
v0.0.0-...-575026b Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2025 License: GPL-3.0 Imports: 15 Imported by: 0

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetupDB

func SetupDB(ctx context.Context, db *sqlx.DB) error

func TestFS

func TestFS[K comparable](t *testing.T, newScheme func(testing.TB) Scheme[K])

TestFS tests a filesystem implementation with the given scheme factory

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]) FUSERoot

func (fsx *FS[K]) FUSERoot() *Node[K]

FUSERoot returns the root node for FUSE mounting

func (*FS[K]) Flush

func (fs *FS[K]) Flush(ctx context.Context) error

Flush writes all pending extents to the volume

func (*FS[K]) GetID

func (fs *FS[K]) GetID(ino int64) (K, bool)

GetID returns the scheme identifier for a POSIX inode

func (*FS[K]) GetInode

func (fs *FS[K]) GetInode(id K) int64

GetInode returns the POSIX inode for a scheme identifier

func (*FS[K]) GetOrCreateInode

func (fs *FS[K]) GetOrCreateInode(id K) int64

GetOrCreateInode returns the POSIX inode for a scheme identifier, creating one if needed

func (*FS[K]) PutExtent

func (fs *FS[K]) PutExtent(ctx context.Context, id K, startAt int64, data []byte) error

PutExtent writes data to the extent table. Any overlapping extents are truncated so that they are non-overlapping.

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]) Getattr

func (n *Node[K]) Getattr(ctx context.Context, f fs.FileHandle, out *fuse.AttrOut) syscall.Errno

Getattr returns file attributes

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

func (*Node[K]) Readdir

func (n *Node[K]) Readdir(ctx context.Context) (fs.DirStream, syscall.Errno)

Readdir reads directory entries

func (n *Node[K]) Unlink(ctx context.Context, name string) syscall.Errno

Unlink removes a file

func (*Node[K]) Write

func (n *Node[K]) Write(ctx context.Context, f fs.FileHandle, data []byte, off int64) (written uint32, errno syscall.Errno)

Write writes 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)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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