datafs

package
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2026 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Overview

Package datafs classifies the filesystem under Ether's data folder and checks, in that folder, the semantics the payload store and SQLite rely on.

The payload store proves a crashed process is gone by taking the exclusive lock it held on a witness file. That proof needs locks that really exclude and are released when the holder dies, stable file identity, in-place rewrite with fsync, and atomic rename and remove. A known local filesystem has all of them. A network filesystem cannot give the first across machines, whatever a local test shows. Anything else is probed.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Held

func Held(err error) bool

Held reports that TryLock failed because another open file holds the lock, as opposed to the filesystem not supporting locks.

func Hint

func Hint(fstype string) string

Hint says, in English for logs and startup errors, what to change for a filesystem Ether cannot fully trust, or "" (#259).

func HintKind

func HintKind(fstype string) string

HintKind classifies what to change for a filesystem Ether cannot fully trust: "unraid", "docker-desktop", "network", "fuse", or "" when there is nothing specific to say. The console translates by kind.

func Kind

func Kind(dir string) (string, error)

Kind is a cheap identity of the filesystem holding dir (one statfs on Unix), for re-checking that it has not changed since Inspect.

func Probe

func Probe(dir string) (err error)

Probe tests, in a scratch folder inside dir, what the payload store's crash recovery relies on: write and fsync, read back, atomic rename over an existing file, stable and distinct file identity, exclusive locks that a second open file cannot take and that closing releases, in-place rewrite, and remove. nil means every check passed. The scratch folder is removed; one left by a crash is removed by the next probe.

A local probe cannot see another machine, so it never makes a network filesystem trustworthy; callers do not probe those.

func SQLiteUnsafe

func SQLiteUnsafe(info Info) string

SQLiteUnsafe reports why SQLite cannot keep a database consistent on this filesystem, or "" when it can. SQLite needs POSIX locks and the shared memory of its write-ahead log, which network filesystems do not provide reliably; Unraid user shares (fuse.shfs) are the documented source of corrupted app databases on Unraid.

func TryLock

func TryLock(f *os.File) error

TryLock takes an exclusive, non-blocking lock on f. It is released when f is closed or the process dies.

Types

type Class

type Class uint8

Class is what Ether knows about a filesystem before probing it.

const (
	// Unknown is not recognised; Probe decides.
	Unknown Class = iota
	// Local is a known filesystem on a disk in this machine.
	Local
	// Network is shared with other machines (NFS, SMB, Ceph, sshfs...).
	// Locks there do not exclude another machine.
	Network
)

func (Class) String

func (c Class) String() string

type Info

type Info struct {
	Path string
	// Type names the filesystem: the mount type from /proc/self/mountinfo
	// (fuse.shfs, nfs4, virtiofs), the BSD/macOS type name, the Windows
	// volume format, or the statfs magic in hex when nothing names it.
	Type  string
	Class Class
	// Kind is the cheap identity Kind returns. A later Kind that differs
	// means the folder now lives on another filesystem.
	Kind string
}

Info describes the filesystem holding a folder.

func Inspect

func Inspect(dir string) (Info, error)

Inspect classifies the filesystem holding dir. The error is the raw statfs error (ENOENT, EACCES...) when dir cannot be examined.

type ProbeError

type ProbeError struct {
	Step string
	Err  error
}

ProbeError names the semantic a filesystem failed.

func (*ProbeError) Error

func (e *ProbeError) Error() string

func (*ProbeError) Unwrap

func (e *ProbeError) Unwrap() error

Jump to

Keyboard shortcuts

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