fuse

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2026 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrReloadRequiresRestart indicates the requested config change cannot be applied without restarting the mount.
	ErrReloadRequiresRestart = errkind.SentinelError("reload requires restart")
)

Functions

func NewRoot

func NewRoot(mountName string, m *config.MountConfig, primaryRootPath string, db *indexdb.DB, baseLog zerolog.Logger, diskCfg DiskAccessConfig) (fs.InodeEmbedder, error)

NewRoot creates the PolicyFS root node for mounting.

Currently this is a thin wrapper around go-fuse's loopback root to keep behavior identical while we incrementally add PolicyFS operations.

func NewRootWithReload

func NewRootWithReload(mountName string, m *config.MountConfig, primaryRootPath string, db *indexdb.DB, baseLog zerolog.Logger, diskCfg DiskAccessConfig, fuseAllowOther bool, rootLogCfg config.LogConfig) (fs.InodeEmbedder, error)

NewRootWithReload creates the PolicyFS root node for mounting, including reload state.

Types

type DirHandle

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

DirHandle is a directory handle backed by a fixed list of entries.

func (*DirHandle) Readdirent

func (h *DirHandle) Readdirent(ctx context.Context) (*gofuse.DirEntry, syscall.Errno)

Readdirent returns directory entries one by one.

func (*DirHandle) Releasedir

func (h *DirHandle) Releasedir(ctx context.Context, releaseFlags uint32)

Releasedir releases any resources held by the directory handle.

func (*DirHandle) Seekdir

func (h *DirHandle) Seekdir(ctx context.Context, off uint64) syscall.Errno

Seekdir seeks to an opaque directory offset.

type DiskAccessConfig

type DiskAccessConfig struct {
	Enabled bool
	// DedupTTL is a best-effort deduplication window for identical events.
	// When <= 0, deduplication is disabled.
	DedupTTL time.Duration
	// SummaryInterval controls periodic summary emission.
	// When <= 0, summary emission is disabled.
	SummaryInterval time.Duration
}

DiskAccessConfig controls the optional disk access logging mode for `pfs mount`.

The intent is debugging: identify which process wakes up indexed storage by opening files. All durations are interpreted as seconds-based flags in the CLI.

type FileHandle

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

FileHandle caches open-time resolution for performance.

The key invariant is: READ/WRITE must not redo any path/routing work; they only use the cached `fd`.

func (*FileHandle) Fsync

func (h *FileHandle) Fsync(ctx context.Context, flags uint32) syscall.Errno

Fsync flushes writes to stable storage.

func (*FileHandle) Read

func (h *FileHandle) Read(ctx context.Context, dest []byte, off int64) (gofuse.ReadResult, syscall.Errno)

Read reads bytes from the already-open file descriptor.

func (*FileHandle) Release

func (h *FileHandle) Release(ctx context.Context) syscall.Errno

Release closes the underlying file descriptor.

func (*FileHandle) Write

func (h *FileHandle) Write(ctx context.Context, data []byte, off int64) (uint32, syscall.Errno)

Write writes bytes to the already-open file descriptor.

type Node

type Node struct {
	*fs.LoopbackNode
	// contains filtered or unexported fields
}

Node is a PolicyFS inode implementation (including the root inode).

func (*Node) Create

func (n *Node) Create(ctx context.Context, name string, flags uint32, mode uint32, out *gofuse.EntryOut) (*fs.Inode, fs.FileHandle, uint32, syscall.Errno)

Create creates a new file on a selected write target.

func (*Node) Flush

func (n *Node) Flush(ctx context.Context, f fs.FileHandle) syscall.Errno

Flush is called on close(2). We keep this lightweight for indexed=false.

func (*Node) Fsync

func (n *Node) Fsync(ctx context.Context, f fs.FileHandle, flags uint32) syscall.Errno

Fsync flushes file content to stable storage.

func (*Node) Getattr

func (n *Node) Getattr(ctx context.Context, f fs.FileHandle, out *gofuse.AttrOut) syscall.Errno

Getattr reads attributes using the router's read target order.

func (*Node) Getxattr

func (n *Node) Getxattr(ctx context.Context, attr string, dest []byte) (uint32, syscall.Errno)

Getxattr reports no supported xattrs to avoid ls ACL probing showing '?'.

func (n *Node) Link(ctx context.Context, target fs.InodeEmbedder, name string, out *gofuse.EntryOut) (*fs.Inode, syscall.Errno)

Link creates a hardlink to an existing inode.

Cross-target hardlinks are not supported and must return EXDEV.

func (*Node) Listxattr

func (n *Node) Listxattr(ctx context.Context, dest []byte) (uint32, syscall.Errno)

Listxattr returns an empty list to indicate no supported xattrs.

func (*Node) Lookup

func (n *Node) Lookup(ctx context.Context, name string, out *gofuse.EntryOut) (*fs.Inode, syscall.Errno)

Lookup resolves a child entry using the router's read target order.

func (*Node) Mkdir

func (n *Node) Mkdir(ctx context.Context, name string, mode uint32, out *gofuse.EntryOut) (*fs.Inode, syscall.Errno)

Mkdir creates a new directory on a selected write target.

func (*Node) Open

func (n *Node) Open(ctx context.Context, flags uint32) (fs.FileHandle, uint32, syscall.Errno)

Open opens a file and returns a cached FileHandle.

func (*Node) OpenCounts

func (n *Node) OpenCounts(ctx context.Context, files []daemonctl.OpenFileID) ([]daemonctl.OpenStat, error)

OpenCounts implements daemonctl.OpenCountsProvider for the daemon control socket.

func (*Node) OpendirHandle

func (n *Node) OpendirHandle(ctx context.Context, flags uint32) (fs.FileHandle, uint32, syscall.Errno)

OpendirHandle returns a directory handle that merges entries across read targets.

func (*Node) Readdir

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

Readdir returns a union of directory entries across read targets, deduped by name.

func (*Node) Release

func (n *Node) Release(ctx context.Context, f fs.FileHandle) syscall.Errno

Release closes any file handles we created.

func (*Node) Reload

func (n *Node) Reload(ctx context.Context, configPath string) (bool, []string, error)

Reload hot-reloads mount-scoped config in the running daemon.

func (*Node) Removexattr

func (n *Node) Removexattr(ctx context.Context, attr string) syscall.Errno

Removexattr rejects all xattrs on the virtual mount.

func (*Node) Rename

func (n *Node) Rename(ctx context.Context, name string, newParent fs.InodeEmbedder, newName string, flags uint32) syscall.Errno

Rename renames a child within the same underlying target.

Cross-target renames return EXDEV.

func (*Node) Rmdir

func (n *Node) Rmdir(ctx context.Context, name string) syscall.Errno

Rmdir removes a child directory on the first existing read target.

func (*Node) Setattr

func (n *Node) Setattr(ctx context.Context, f fs.FileHandle, in *gofuse.SetAttrIn, out *gofuse.AttrOut) syscall.Errno

Setattr applies attribute changes to the underlying storage.

func (*Node) Setxattr

func (n *Node) Setxattr(ctx context.Context, attr string, data []byte, flags uint32) syscall.Errno

Setxattr rejects all xattrs on the virtual mount.

func (*Node) Statfs

func (n *Node) Statfs(ctx context.Context, out *gofuse.StatfsOut) syscall.Errno

Statfs returns filesystem stats for the mount.

The default loopback Statfs reports stats for the primaryRootPath filesystem, which may differ from where writes actually land. This override resolves write targets via the router so that tools like df and sabnzbd see the correct free space for the filesystem that will receive writes at this path.

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

Unlink removes a child file on the first existing read target.

func (*Node) WrapChild

func (n *Node) WrapChild(ctx context.Context, ops fs.InodeEmbedder) fs.InodeEmbedder

WrapChild wraps descendant nodes.

type OpenTracker

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

OpenTracker tracks open file handles held by FUSE clients.

It is used by maintenance jobs (e.g. mover) to avoid moving files that are currently open. The key is a stable file identity (storage_id + dev + ino).

This is best-effort and intentionally simple: counts are in-memory only.

func NewOpenTracker

func NewOpenTracker() *OpenTracker

NewOpenTracker constructs a ready-to-use OpenTracker.

func (*OpenTracker) Dec

func (t *OpenTracker) Dec(id daemonctl.OpenFileID, write bool)

Dec decrements the open counters for a file ID.

func (*OpenTracker) Inc

func (t *OpenTracker) Inc(id daemonctl.OpenFileID, write bool)

Inc increments the open counters for a file ID.

func (*OpenTracker) OpenCounts

func (t *OpenTracker) OpenCounts(ctx context.Context, files []daemonctl.OpenFileID) ([]daemonctl.OpenStat, error)

OpenCounts returns open-count snapshots for the given file IDs.

Jump to

Keyboard shortcuts

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