Skip to main content

Module fs_primitive_error

Module fs_primitive_error 

Source
Expand description

The typed failure of one Linux filesystem primitive: the call, the path and the error number. What: The typed failure of one Linux filesystem primitive (statfs, a btrfs ioctl, FICLONE, renameat2): which operation, on which path, and the operating system’s error number. Why: The primitives of the cheap-worktree ladder and the subvolume migration all fall through on failure, never panic; the caller decides from the error number whether the next rung applies (the filesystem lacks the feature) or the work must stop (a real fault), and the message names the operation and path a person can act on.

In TS you’d write (pseudocode):

class PrimitiveError extends Error { constructor(readonly operation: string, readonly path: string, readonly errno: number) { super(`...`); } }

Structs§

PrimitiveError
What: One failed primitive call. &'static str is text compiled into the executable (sibling String is owned); i32 is the C errno value (siblings i64 and u32 exist; the C API returns a 32-bit signed integer). Why: The operation names the call as the kernel documents it (for example BTRFS_IOC_SNAP_CREATE_V2), so a report can be searched in the kernel sources.

Functions§

c_path
What: A path as the NUL-terminated C string the system calls take. Why: A path with an interior NUL byte can name no file, so it fails with EINVAL before any call, instead of reaching a system call with a truncated name.