# eb-local.storage ::::{zig:module} eb-local.storage :file: src/storage.zig :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/storage.zig Where a build may write: the allocation's own node-local mount, and a durable installation prefix that is neither node-local nor shared scratch. Mounts are read from /proc/self/mountinfo. :::: ## Types ::::{zig:type} eb-local.storage.Refusal :signature: pub const Refusal = struct :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/storage.zig#L16 Why a path was refused: in `message`, what was refused and why, as one clause; in `fix`, what changes that, naming the setting, variable or command, and for a setting its value and where it was set. :::{zig:field} eb-local.storage.Refusal.message :signature: message: []const u8 = "" :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/storage.zig#L17 ::: :::{zig:field} eb-local.storage.Refusal.fix :signature: fix: []const u8 = "" :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/storage.zig#L18 ::: :::: ::::{zig:type} eb-local.storage.Mount :signature: pub const Mount = struct :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/storage.zig#L44 A line of `/proc/self/mountinfo`: where the file system is mounted, its type, and its mount options. :::{zig:field} eb-local.storage.Mount.target :signature: target: []const u8 :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/storage.zig#L45 ::: :::{zig:field} eb-local.storage.Mount.fstype :signature: fstype: []const u8 :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/storage.zig#L46 ::: :::{zig:field} eb-local.storage.Mount.options :signature: options: []const u8 :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/storage.zig#L47 ::: :::: ::::{zig:type} eb-local.storage.JobRoot :signature: pub const JobRoot = struct :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/storage.zig#L227 The allocation's node-local mount that `jobRoot` checked. :::{zig:field} eb-local.storage.JobRoot.path :signature: path: []const u8 :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/storage.zig#L228 ::: :::: ::::{zig:type} eb-local.storage.NodeLocal :signature: pub const NodeLocal = struct :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/storage.zig#L237 The site file's node-local settings, each with where it was set, as `eb-local config` shows it. :::{zig:field} eb-local.storage.NodeLocal.root :signature: root: []const u8 :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/storage.zig#L238 ::: :::{zig:field} eb-local.storage.NodeLocal.root_from :signature: root_from: []const u8 = "default" :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/storage.zig#L239 ::: :::{zig:field} eb-local.storage.NodeLocal.mount :signature: mount: []const u8 = default_mount :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/storage.zig#L240 ::: :::{zig:field} eb-local.storage.NodeLocal.mount_from :signature: mount_from: []const u8 = "default" :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/storage.zig#L241 ::: :::{zig:field} eb-local.storage.NodeLocal.fstype :signature: fstype: []const u8 = "xfs" :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/storage.zig#L242 ::: :::{zig:field} eb-local.storage.NodeLocal.fstype_from :signature: fstype_from: []const u8 = "default" :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/storage.zig#L243 ::: :::: ::::{zig:type} eb-local.storage.LockedWorkspace :signature: pub const LockedWorkspace = struct :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/storage.zig#L447 A newly created workspace directory and its held `.eb-local.lock` descriptor. :::{zig:field} eb-local.storage.LockedWorkspace.path :signature: path: []const u8 :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/storage.zig#L448 ::: :::{zig:field} eb-local.storage.LockedWorkspace.lock :signature: lock: ?sys.fd_t :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/storage.zig#L449 ::: :::: ::::{zig:type} eb-local.storage.Capacity :signature: pub const Capacity = struct :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/storage.zig#L506 Capacity available to an unprivileged caller. :::{zig:field} eb-local.storage.Capacity.bytes :signature: bytes: u64 :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/storage.zig#L507 ::: :::{zig:field} eb-local.storage.Capacity.inodes :signature: inodes: u64 :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/storage.zig#L509 Free inodes; meaningful only while `inodes_counted` is true. ::: :::{zig:field} eb-local.storage.Capacity.inodes_counted :signature: inodes_counted: bool = true :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/storage.zig#L513 False for a file system with no inode table to run out of. btrfs allocates inodes on demand and statfs reports zero total and zero free there, which is not a full file system. ::: :::{zig:function} eb-local.storage.Capacity.exhausted :signature: pub fn exhausted(self: Capacity) bool :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/storage.zig#L517 Whether nothing more can be written: no free bytes, or no free inodes on a file system that counts them. ::: :::: ::::{zig:type} eb-local.storage.WorkspaceProbe :signature: pub const WorkspaceProbe = struct :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/storage.zig#L580 Result of creating, writing, renaming, executing and removing one probe. :::{zig:field} eb-local.storage.WorkspaceProbe.created :signature: created: bool = false :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/storage.zig#L581 ::: :::{zig:field} eb-local.storage.WorkspaceProbe.written :signature: written: bool = false :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/storage.zig#L582 ::: :::{zig:field} eb-local.storage.WorkspaceProbe.renamed :signature: renamed: bool = false :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/storage.zig#L583 ::: :::{zig:field} eb-local.storage.WorkspaceProbe.executed :signature: executed: bool = false :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/storage.zig#L584 ::: :::{zig:field} eb-local.storage.WorkspaceProbe.removed :signature: removed: bool = false :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/storage.zig#L585 ::: :::: ::::{zig:type} eb-local.storage.LockResult :signature: pub const LockResult = union(enum) :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/storage.zig#L643 Outcome of acquiring a bounded exclusive lock. :::{zig:field} eb-local.storage.LockResult.held :signature: held: sys.fd_t :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/storage.zig#L644 ::: :::{zig:field} eb-local.storage.LockResult.unlocked :signature: unlocked :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/storage.zig#L645 ::: :::{zig:field} eb-local.storage.LockResult.failed :signature: failed :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/storage.zig#L646 ::: :::: ::::{zig:type} eb-local.storage.CancelLockResult :signature: pub const CancelLockResult = union(enum) :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/storage.zig#L650 Outcome of acquiring a bounded exclusive lock with signal cancellation. :::{zig:field} eb-local.storage.CancelLockResult.held :signature: held: sys.fd_t :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/storage.zig#L651 ::: :::{zig:field} eb-local.storage.CancelLockResult.unlocked :signature: unlocked :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/storage.zig#L652 ::: :::{zig:field} eb-local.storage.CancelLockResult.canceled :signature: canceled :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/storage.zig#L653 ::: :::{zig:field} eb-local.storage.CancelLockResult.failed :signature: failed :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/storage.zig#L654 ::: :::: ::::{zig:type} eb-local.storage.LockCancel :signature: pub const LockCancel = struct :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/storage.zig#L668 Captures non-ignored termination signals while waiting on a contended lock so `acquireBoundedLockCancel` aborts immediately and the caller can clean up. :::{zig:field} eb-local.storage.LockCancel.old :signature: old: [lock_signals.len]linux.Sigaction :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/storage.zig#L669 ::: :::{zig:function} eb-local.storage.LockCancel.hold :signature: pub fn hold() LockCancel :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/storage.zig#L672 Install cancellation handlers for non-ignored termination signals. ::: :::{zig:function} eb-local.storage.LockCancel.release :signature: pub fn release(lc: *const LockCancel) void :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/storage.zig#L691 Restore the signal actions that were in effect before `hold`. ::: :::{zig:function} eb-local.storage.LockCancel.received :signature: pub fn received(_: *const LockCancel) ?linux.SIG :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/storage.zig#L696 Return the first guarded signal received since `hold`, or `null`. ::: :::{zig:function} eb-local.storage.LockCancel.flag :signature: pub fn flag(_: *const LockCancel) *const std.atomic.Value(bool) :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/storage.zig#L702 Return the atomic cancellation flag observed by `lockExclusiveCancel`. ::: :::: ## Error sets ::::{zig:errorset} eb-local.storage.Error :signature: pub const Error = error{Refused} || Allocator.Error :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/storage.zig#L23 `error.Refused` when a path may not be used, with what and why in the `Refusal`. :::: ## Functions :::{zig:function} eb-local.storage.describeError :signature: pub fn describeError(e: anyerror) []const u8 :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/storage.zig#L38 Format `e` with its kernel errno when it maps to `sys.Error`, otherwise return the Zig error name. ::: :::{zig:function} eb-local.storage.mountOf :signature: pub fn mountOf(a: Allocator, mountinfo: []const u8, path: []const u8) Allocator.Error!?Mount :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/storage.zig#L72 The mount `path` lies on: the last entry (a later mount covers an earlier one) whose target is `path` or a parent of it. ::: :::{zig:function} eb-local.storage.canonical :signature: pub fn canonical(a: Allocator, path: []const u8, cwd: []const u8) Allocator.Error![]const u8 :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/storage.zig#L128 `path` made absolute and normal as `readlink -m` does. A symbolic link is resolved even when its target does not exist yet, so `link/..` is the parent of the link's target and a dangling link onto shared scratch is visible to the prefix check. A link cycle is kept as a literal component, which is what `readlink -m` prints, instead of being walked forever. ::: :::{zig:function} eb-local.storage.under :signature: pub fn under(path: []const u8, root: []const u8) bool :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/storage.zig#L220 Whether `path` is `root` or below it, compared by whole components; both are already canonical. ::: :::{zig:function} eb-local.storage.validMountPattern :signature: pub fn validMountPattern(p: []const u8) bool :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/storage.zig#L272 A storage.node_local_mount: one file name of letters, digits, '.', '_', '-', %u (the user) and %j (the job id). It must hold %j, so that each allocation has a mount of its own. ::: :::{zig:function} eb-local.storage.jobRoot :signature: pub fn jobRoot( a: Allocator, nl: NodeLocal, job_id: []const u8, user: []const u8, mountinfo: []const u8, uid: linux.uid_t, r: *Refusal) Error!JobRoot :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/storage.zig#L310 The allocation's node-local mount: /, the mount name with the user and the job id filled in, an owned, writable, canonical directory that is its own mount of `nl.fstype`. ::: :::{zig:function} eb-local.storage.ownWorkspace :signature: pub fn ownWorkspace(job_root: []const u8, path: []const u8, uid: linux.uid_t) bool :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/storage.zig#L365 A workspace eb-local made: a real directory of the caller named eb-local.XXXXXXXX directly in the job mount. ::: :::{zig:function} eb-local.storage.removeTreeDevice :signature: pub fn removeTreeDevice(a: Allocator, path: []const u8, dev: u64) (fsx.Error || Allocator.Error)!void :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/storage.zig#L377 Remove `path` and everything under it that is on `dev`. A mount point, whose device differs, is left in place, as `rm --one-file-system` does. Symbolic links are removed, not followed. ::: :::{zig:function} eb-local.storage.removeTree :signature: pub fn removeTree(a: Allocator, path: []const u8) (fsx.Error || Allocator.Error)!void :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/storage.zig#L383 Remove `path` and everything under it on its own file system, as `removeTreeDevice` does for the device `path` is on. ::: :::{zig:function} eb-local.storage.makeWorkspace :signature: pub fn makeWorkspace(a: Allocator, job_root: []const u8) (fsx.Error || Allocator.Error)![]const u8 :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/storage.zig#L418 A new eb-local.XXXXXXXX directory, mode 0700, in `job_root`. ::: :::{zig:function} eb-local.storage.makeLockedWorkspace :signature: pub fn makeLockedWorkspace(a: Allocator, job_root: []const u8, subdirs: []const []const u8) (fsx.Error || Allocator.Error)!LockedWorkspace :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/storage.zig#L455 Create a workspace directory in `job_root` whose `.eb-local.lock` and subdirectories exist and are locked before `eb-local.XXXXXXXX` becomes visible to `clean --workspaces`. ::: :::{zig:function} eb-local.storage.capacity :signature: pub fn capacity(path: []const u8) sys.Error!Capacity :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/storage.zig#L546 Free bytes and inodes on the file system containing `path`. ::: :::{zig:function} eb-local.storage.hasMountOption :signature: pub fn hasMountOption(options: []const u8, wanted: []const u8) bool :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/storage.zig#L561 Whether a mount option is present as one whole comma-separated word. ::: :::{zig:function} eb-local.storage.workspaceClass :signature: pub fn workspaceClass(path: []const u8, fstype: []const u8, shared_roots: []const []const u8) []const u8 :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/storage.zig#L569 Operational storage class for a workspace. Configured shared roots and network file systems are shared; other file systems are node-local. ::: :::{zig:function} eb-local.storage.probeWorkspace :signature: pub fn probeWorkspace( io: std.Io, a: Allocator, path: []const u8, execute_result: ?bool) (fsx.Error || sys.Error || common.proc.Error || Allocator.Error)!WorkspaceProbe :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/storage.zig#L590 Exercise the file operations a build workspace needs. `execute_result` is a test seam; null executes the renamed probe. ::: :::{zig:function} eb-local.storage.lockTimeoutMs :signature: pub fn lockTimeoutMs(env: ?*const std.process.Environ.Map, err_msg: *[]const u8) ?u32 :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/storage.zig#L708 Resolve the lock wait timeout in milliseconds from `EB_LOCAL_LOCK_TIMEOUT_MS`. ::: :::{zig:function} eb-local.storage.flockUnsupported :signature: pub fn flockUnsupported(e: sys.Error) bool :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/storage.zig#L732 True when `e` represents an unsupported `flock` operation on this filesystem. ::: :::{zig:function} eb-local.storage.acquireBoundedLock :signature: pub fn acquireBoundedLock(a: Allocator, lock_path: []const u8, timeout_ms: u32, notify: bool, err_msg: *[]const u8) LockResult :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/storage.zig#L742 Open `lock_path` without following symlinks and hold an exclusive lock via `common.state.lockExclusive` with a bounded timeout. When `notify` is true and another process holds the lock, prints one waiting line on stderr before waiting. When `flock` is unsupported (`ENOLCK`, `ENOTSUP`, `EOPNOTSUPP`, `ENOSYS`), prints one warning on stderr when `notify` is true and returns `.unlocked`. ::: :::{zig:function} eb-local.storage.acquireBoundedLockCancel :signature: pub fn acquireBoundedLockCancel( a: Allocator, lock_path: []const u8, timeout_ms: u32, notify: bool, cancel: ?*const std.atomic.Value(bool), err_msg: *[]const u8) CancelLockResult :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/storage.zig#L753 Like `acquireBoundedLock`, also returning `.canceled` when `cancel` is set while waiting on a contended lock via `common.state.lockExclusiveCancel`. ::: :::{zig:function} eb-local.storage.acquireOptionalLock :signature: pub fn acquireOptionalLock(path: []const u8) ?sys.fd_t :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/storage.zig#L846 Acquire a non-blocking exclusive lock on `path` without printing errors, returning null when it cannot be opened or locked. ::: :::{zig:function} eb-local.storage.releaseLock :signature: pub fn releaseLock(lock: *?sys.fd_t) sys.Error!void :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/storage.zig#L888 Release a lock descriptor returned by `acquireBoundedLock` or `acquireOptionalLock`. The descriptor is closed whatever `LOCK_UN` returns; a failed `LOCK_UN` is then returned, as Python's `fcntl.flock` raises it, with `sys.last_errno` its errno. ::: :::{zig:function} eb-local.storage.releaseLockAfterError :signature: pub fn releaseLockAfterError(lock: *?sys.fd_t) void :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/storage.zig#L903 `releaseLock` in cleanup after another failure. A failed release is dropped and `sys.last_errno` is put back, so the earlier failure's errno is the one its message describes. ::: :::{zig:function} eb-local.storage.takeWriteErrno :signature: pub fn takeWriteErrno() ?linux.E :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/storage.zig#L963 The next `EB_LOCAL_TEST_WRITE_ERRNO`, or null. A release build cannot see it. ::: :::{zig:function} eb-local.storage.injectedSysError :signature: pub fn injectedSysError(e: linux.E) sys.Error :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/storage.zig#L972 `e` as the `sys.Error` a failed write returns, with `last_errno` set so the message names that errno. ::: :::{zig:function} eb-local.storage.testErrno :signature: pub fn testErrno(name: []const u8) ?linux.E :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/storage.zig#L983 The errno a close or fsync hook names, as `EIO` for `.IO`. Null for a name that is not an errno and for EINTR, which neither call reports. ::: :::{zig:function} eb-local.storage.closeWritten :signature: pub fn closeWritten(fd: sys.fd_t) sys.Error!void :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/storage.zig#L1022 Close a descriptor this process wrote a file through. A failed close is returned, with `sys.last_errno` its errno, because NFS and some quota setups report a lost write only there. Linux frees the descriptor whatever close returns, so it is not closed again, and EINTR is not an error. ::: :::{zig:function} eb-local.storage.fsyncWritten :signature: pub fn fsyncWritten(fd: sys.fd_t) sys.Error!void :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/storage.zig#L1028 fsync(2) of a file this process wrote, or of the directory that names it. A failure is returned, with `sys.last_errno` its errno. ::: :::{zig:function} eb-local.storage.tryLockFree :signature: pub fn tryLockFree(path: []const u8) bool :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/storage.zig#L1034 True when `path` is absent, unlocked, or on a filesystem without `flock`. A probe lock whose release fails counts as held, so `clean` keeps it. ::: ## Constants :::{zig:constant} eb-local.storage.default_mount :signature: pub const default_mount = "%u.%j" :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/storage.zig#L233 storage.node_local_mount unless the site sets it: the user, a dot and the job id. ::: :::{zig:constant} eb-local.storage.default_lock_timeout_ms :signature: pub const default_lock_timeout_ms: u32 = 300_000 :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/storage.zig#L640 Default milliseconds to wait on a contended `flock` lock. ::: ## Variables :::{zig:variable} eb-local.storage.test_flock_errno :signature: pub var test_flock_errno: ?linux.E = null :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/storage.zig#L729 Set in `main` from `EB_LOCAL_TEST_FLOCK_ERRNO`, only in the test artifact, so a test can emulate `ENOLCK` or `EOPNOTSUPP` from `flock`. ::: :::{zig:variable} eb-local.storage.test_release_errno :signature: pub var test_release_errno: ?linux.E = null :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/storage.zig#L875 Set in `main` from `EB_LOCAL_TEST_RELEASE_ERRNO`, only in the test artifact, and by unit tests, so the `LOCK_UN` of every release fails with that errno. ::: :::{zig:variable} eb-local.storage.test_close_errno :signature: pub var test_close_errno: ?linux.E = null :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/storage.zig#L914 Set in `main` from `EB_LOCAL_TEST_CLOSE_ERRNO`, only in the test artifact, so each `closeWritten` after the first `test_close_after` closes its descriptor and then fails with that errno. `testErrno` refuses EINTR, which `closeWritten` counts as a success. ::: :::{zig:variable} eb-local.storage.test_close_after :signature: pub var test_close_after: u32 = 0 :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/storage.zig#L918 Set in `main` from `EB_LOCAL_TEST_CLOSE_AFTER`: how many calls of `closeWritten` succeed before `test_close_errno` applies. ::: :::{zig:variable} eb-local.storage.test_close_count :signature: pub var test_close_count: ?u32 = null :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/storage.zig#L923 Set in `main` from `EB_LOCAL_TEST_CLOSE_COUNT`: how many calls of `closeWritten` fail once `test_close_errno` applies; the calls after them succeed. Null fails every one. ::: :::{zig:variable} eb-local.storage.test_fsync_errno :signature: pub var test_fsync_errno: ?linux.E = null :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/storage.zig#L929 Set in `main` from `EB_LOCAL_TEST_FSYNC_ERRNO`, only in the test artifact, so each `fsyncWritten` after the first `test_fsync_after` fails with that errno without syncing. `testErrno` refuses EINTR, which `fsyncWritten` would retry without end. ::: :::{zig:variable} eb-local.storage.test_fsync_after :signature: pub var test_fsync_after: u32 = 0 :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/storage.zig#L933 Set in `main` from `EB_LOCAL_TEST_FSYNC_AFTER`: how many calls of `fsyncWritten` succeed before `test_fsync_errno` applies. ::: :::{zig:variable} eb-local.storage.test_fsync_count :signature: pub var test_fsync_count: ?u32 = null :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/storage.zig#L938 Set in `main` from `EB_LOCAL_TEST_FSYNC_COUNT`: how many calls of `fsyncWritten` fail once `test_fsync_errno` applies; the calls after them succeed. Null fails every one. ::: :::{zig:variable} eb-local.storage.test_prefix_errno :signature: pub var test_prefix_errno: ?linux.E = null :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/storage.zig#L942 Set in `main` from `EB_LOCAL_TEST_PREFIX_ERRNO`, only in the test artifact. The prefix writability check fails with this errno. ::: :::{zig:variable} eb-local.storage.test_logs_errno :signature: pub var test_logs_errno: ?linux.E = null :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/storage.zig#L946 Set in `main` from `EB_LOCAL_TEST_LOGS_ERRNO`. The logs-directory writability check fails with this errno. ::: :::{zig:variable} eb-local.storage.test_redact_errno :signature: pub var test_redact_errno: ?linux.E = null :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/storage.zig#L950 Set in `main` from `EB_LOCAL_TEST_REDACT_ERRNO`. Replacing a log during redaction fails with this errno. ::: :::{zig:variable} eb-local.storage.test_workspace_errno :signature: pub var test_workspace_errno: ?linux.E = null :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/storage.zig#L955 Set in `main` from `EB_LOCAL_TEST_WORKSPACE_ERRNO`. Creating a directory inside a new workspace fails with this errno, and the workspace is removed. ::: :::{zig:variable} eb-local.storage.test_write_errno :signature: pub var test_write_errno: ?linux.E = null :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/storage.zig#L959 Set in `main` from `EB_LOCAL_TEST_WRITE_ERRNO`. The next durable write fails with this errno. One write, then it is clear. :::