Part of the accepted-design index.
The usage guide owns configuration, attachment, and cleanup workflows. Verification owns isolated-runner requirements, runtime results, and unexecuted paths.
Config and Handle model distinct Linux resources. Configuration preserves the kernel’s separate parameter forms and passes each through an x/sys binding. A path supplies a lookup base and name for the filesystem to interpret. A file parameter supplies an open object from which the filesystem may take its own reference. Converting either form to a string would lose those semantics. Both borrow caller-owned files through the syscall. Create is explicit, and Mount acquires a detached handle. The application owns namespace entry and propagation policy.
A handle’s descriptor lifetime differs from the mount’s namespace lifetime. Closing it leaves an attachment in place, and failed attachment leaves the handle available for cleanup or another attempt. Unmount is therefore explicit. Pick and Reconfigure operate on the underlying superblock. Keeping them on Config shares the diagnostic owner and honors the kernel’s transition from Mount to reconfiguration and its reuse after success. The kernel owns phase checks and partial application. A mirrored userspace state machine or automatic retry would falsely imply rollback or safely repeatable transitions.
The four mount restrictions use explicit set/clear masks. Access-time updates use a mode and a separate directory override because Linux replaces the atime group as a unit and applies the directory bit independently. Dedicated operations preserve existing AttributeChange struct literals. Propagation accepts a single mode although discovery can report several bits. The path form can make an existing root private before the caller attaches anything, and the handle form acts on a captured mount reference. These operations build on the existing x/sys binding for mount_setattr. Linux 7.0 mount implementation.
mount already depends on namespace for discovery. ID mapping borrows the same module-private namespace representation, pins both handles through the syscall, and checks the namespace type while the descriptor is pinned. The kernel determines mapping eligibility and retains its own mapping. Applying it before attachment keeps the existing prepare-and-attach lifecycle and makes the failure boundary visible to callers.
Root switching uses the x/sys pivot_root binding. A single operation ends at the kernel switch, so an error detaching the old mount cannot be mistaken for a failed switch. Working-directory adjustment and unmount use their existing Go operations. Running this sequence in a private mount-namespace child confines changes to filesystem context and the mount tree while keeping startup and process supervision with os/exec.
A container supervisor can compare a live tree with its intended layout using the kernel’s nonreused mount IDs. A page returns IDs only. Record queries are separate and can observe later attributes or a disappeared mount. Looking up a record by file or mount handle uses the existing reference, which can still identify a detached mount. Numeric namespace selectors use the kernel lookup and a namespace handle supplies a borrowed, lifetime-protected reference. The two selectors preserve Linux’s different visibility rules.
The pinned x/sys module supplies syscall numbers, request size, and mount flags. A fixed-layout request and a bounded response decoder cover the remaining ABI without another dependency. Native masks retain unknown bits. Options and paths are decoded from the returned record size, with NUL boundaries preserved. An allocation cap keeps oversized records visible as errors and limits retries when observations change. Procfs mountinfo remains available for reusable IDs and its own text format. Linux 7.0 mount UAPI.
The filesystem-context diagnostic queue belongs to the Config, not to an individual syscall. Config methods serialize the command and failure drain so another goroutine cannot steal its diagnostics. Successful calls leave warnings available; later failures may therefore carry earlier records. Automatic draining favors useful errors over a separate racy “read last error” protocol. See configuration serialization.
A structured Error preserves the primary operation cause separately from diagnostic retrieval failure. Unwrap exposes only the primary cause, preventing errors.Is from reporting the retrieval errno as the reason configuration failed. Already read records survive a later retrieval error.
The Linux 7.0 producer formats messages dynamically; its eight-record queue does not bound message bytes. The reader retains an oversized record on EMSGSIZE. Reads therefore grow from 4 KiB to a 1 MiB allocation cap, returning partial records and an explicit error at the cap rather than truncating text or allocating without bound. This is bounded diagnostics, not a lossless log. The decoder preserves unknown severity and unframed records for the same reason.