Module atomic

Module atomic 

Source
Expand description

Atomic symlink swap primitives and helpers.

This module implements a TOCTOU-safe sequence using directory handles: open_dir_nofollow(parent) -> symlinkat(tmp) -> renameat(tmp, final) -> fsync(dirfd).

Test override knobs:

  • SWITCHYARD_FORCE_EXDEV=1 — simulate a cross-filesystem rename error (EXDEV) to exercise degraded fallback paths and telemetry in higher layers.

Functions§

atomic_symlink_swap
Atomically swap a symlink target using a temporary file and renameat.
fsync_parent_dir
Fsync the parent directory of path for durability.
open_dir_nofollow
Open a directory with O_DIRECTORY | O_NOFOLLOW for atomic operations.