Research notes / Filesystem interfaces
Unnamed files: publishing is not replacing
Published 17 October 2026 / Updated 14 November 2026 / API review and native Linux observation
Preparing a file, assigning its first name, replacing an existing name and exchanging two names are different operations. None alone establishes a durable application commit.
On this page6 sections
Choose the namespace operation explicitly
O_TMPFILE creates an unnamed regular file in the chosen directory's filesystem. Supply a writable access mode and permission mode. Filesystem support is required. Adding O_EXCL prevents later linking; it does not request no-overwrite publication. An unnamed file is not inherently confidential. [1]
linkat() can publish that file, but it does not replace an occupied destination. The documented unprivileged route follows /proc/self/fd/N with AT_SYMLINK_FOLLOW. It needs accessible procfs and a live descriptor; the alternative AT_EMPTY_PATH route needs CAP_DAC_READ_SEARCH. Cross-mount linking is not allowed. [2]
A zero link count is not sufficient to identify a publishable temporary file. An ordinary file whose last name was removed can remain readable through an open descriptor, yet Linux rejects an attempt to relink it through procfs. O_TMPFILE without O_EXCL is a specific exception, not a general undelete mechanism. [2]
For an already named source, RENAME_NOREPLACE refuses an occupied destination. RENAME_EXCHANGE swaps two existing names; the flags cannot be combined. Support depends on the filesystem. An existence check followed by ordinary rename is not a substitute for no-replace semantics. [3]
Two names need not identify two files. In Linux v6.12, an exchange of hard links to the same inode can succeed without changing either name or emitting the normal move notifications. RENAME_NOREPLACE instead rejects the occupied destination with EEXIST, even for that same inode. A same-inode success therefore does not test the file system's exchange support. This follows from the kernel's check order, not from the ten-case observation below. [6]
Hesela's design implication: a workflow that links an unnamed file to a staging name and then renames it has two namespace steps. Only the final rename is the replacement; the staging entry can be visible. Use a trusted directory descriptor and controlled relative names, not an assumption that descriptor-relative operations provide a sandbox.
Ten measured outcomes, three repetitions
The native C probe ran as UID 1001 on Linux 6.8.0-146-generic, x86_64, ext4, with cc (Ubuntu 13.3.0-6ubuntu2~24.04.1) 13.3.0. Each repetition used a fresh private directory. All ten asserted outcomes agreed across the three runs; these repetitions are consistency checks, not a statistical sample of devices.
Before exchange
moved names file A
right names file B
After exchange
moved names file B
right names file A
left-data; the descriptor opened for B still read right-data.| Case | Observed invariant | Return / errno |
|---|---|---|
| Stage without a name | Link count 0; no published entry. | 0 / 0 |
| Publish an absent name | Link count 1; name and descriptor identify the same inode and payload. | 0 / 0 |
| Link onto an existing name | EEXIST; existing inode and payload unchanged; candidate remains unnamed. | -1 / 17 |
| Publish O_TMPFILE | O_EXCL | ENOENT; no destination entry created. | -1 / 2 |
| Relink an ordinary file after unlink | ENOENT; link count stays 0, no name is recreated, and the open descriptor still reads the original payload. | -1 / 2 |
| NOREPLACE collision | EEXIST; both input identities and payloads preserved. | -1 / 17 |
| NOREPLACE to an absent name | Source name removed; destination identifies the original source inode. | 0 / 0 |
| Exchange existing names | Names swap inode identities; open descriptors retain their original payloads. | 0 / 0 |
| Exchange with missing destination | ENOENT; destination remains absent. | -1 / 2 |
| Combine EXCHANGE and NOREPLACE | EINVAL; the previously exchanged bindings remain in place. | -1 / 22 |
The initial row records a successful state check, not the numeric descriptor returned by openat(). Other rows record the namespace-call return and its error number; zero in the error column is the probe's success marker, not a claim about libc's residual errno. The source contains the assertions behind every row.
The exchange diagram does not promise a reader snapshot: two separate lookups can occur on opposite sides of an exchange. No concurrent observer ran in this experiment. Nor does one ext4 run demonstrate support on another filesystem or a network mount.
Two names and two good copies can still miss an object
An atomic exchange protects one namespace operation, not an entire reader scan. In a separate controlled experiment, opening the first name, exchanging the names and opening the second selected the same original object twice. Both copied payloads matched their captured-byte hashes, while the other object remained named and readable. All names had been enumerated first; no read or exchange failed. [7]
The fixture contained two distinct 64-byte objects, except for the intentional hard-link control. Seven schedules, two read orders, ext4 and tmpfs, and two repetitions produced 56 recorded executions on one Linux host. A second 56-execution capture agreed. These are ordered native calls, not a random race, a backup-product test or a failure-rate estimate.
| Schedule | Captured names | Distinct captured / expected objects | Copy digests match | Endpoint identities equal | Matches a namespace state | Accepted |
|---|---|---|---|---|---|---|
| No exchange | 2 | 2 / 2 | Yes | Yes | Yes | Yes |
| Exchange before both opens | 2 | 2 / 2 | Yes | No | Yes | Yes |
| Both descriptors opened first | 2 | 2 / 2 | Yes | No | Yes | Yes |
| Exchange between opens | 2 | 1 / 2 | Yes | No | No | Yes |
| Between opens, then exchange back | 2 | 1 / 2 | Yes | Yes | No | Yes |
| Same, with identity guard | 1 | 1 / 2 | Yes | Yes | No | No |
| Two intended hard links | 2 | 1 / 1 | Yes | Yes | Yes | Yes |
Exchanging back after both reads restored the starting name-to-inode map without repairing the captured pair. With immutable objects A and B and only atomic exchanges, the legal bindings are a:A, b:B or a:B, b:A; a capture of a:A, b:A matches neither. This inference uses the documented exchange contract and the fixture's complete mutation schedule. It does not assert unchanged timestamps or an undetectable operation. [3] [7]
Opening both descriptors before the only exchange captured the initial pair. That does not make sequential descriptor acquisition atomic: the failing schedule opens one on each side. A held descriptor retains its object, not frozen contents. Directory-operation locking likewise does not supply an application transaction across several opens. [1] [8]
The identity guard rejected the second selection against the fixture's retained initial descriptors and marked capture incomplete. It detected this mismatch; it did not finish or repair the copy. Obtaining such a reference on a changing real tree itself needs coordination. Nor is one unique inode per name a general fix: the hard-link control correctly has two names for one object.
Four separate checks for a capture protocol
- Name coverage: which required entries were discovered, and which errors or exclusions remain?
- Object identity: which object did each actual open select, including intended hard-link relationships?
- Byte integrity: which reference do matching hashes verify?
- View consistency: what evidence ties the captured bindings and contents to one valid view?
ViewBox, a FAST 2014 research design, illustrates that last layer: it freezes filesystem views at journal epoch boundaries. For Dropbox's file-level versioning, its prototype records pathnames and revision numbers as view metadata; with Seafile, it can use a snapshot commit ID. The manifest therefore identifies the versions belonging together, not just their names or byte checksums. Multi-client consistency additionally requires a view-aware synchronization protocol that does not expose partially uploaded views. These are the paper's historical designs, not claims about today's services. This experiment did not execute ViewBox or establish application-consistent recovery. [9] Compare the separate directory-walk coverage problem and backup verification versus restore acceptance.
Download the offline experiment, recorded observations, generated table data and claim-to-evidence map. The archive includes the runner, tests, second capture, source receipts and method. No third-party full text is redistributed.
python3 study.py --replay observations.json --output checked.json --summary checked-summary.json
python3 -m unittest -v test_study test_packageOffline replay needs Python 3; the test suite also executes small native controls and requires Linux with libc renameat2 support. Unsupported native operations fail rather than silently passing. This study tests no network filesystem, in-place content change, crash, hard-link restoration or complete backup application.
A visible name is not a recovery guarantee
File synchronization and directory synchronization cover different state. File fsync() alone does not ensure that a new directory entry is durable. [4] The probe checked successful file sync before publication and directory sync afterward, but never interrupted power or remounted a filesystem.
Pillai and colleagues separate persistence ordering from atomicity in their OSDI 2014 study. BOB reorders recorded block I/O within its model and checks recovered states; ALICE derives possible crash states from application traces and a specified persistence model. Neither is equivalent to checking successful syscall returns. [5] This historical methodology motivates an explicit limit here: our sequential probe does not reproduce their crash analysis or establish present-day filesystem guarantees.
A protocol must distinguish at least three outcomes: preparation failed; publication succeeded but its directory sync failed; publication and required synchronization succeeded. The second state can leave a visible file with unconfirmed post-crash persistence. Reporting it as an unchanged namespace would conceal uncertainty. This is Hesela's synthesis of the separate operation contracts, not a crash-test result.
Do not classify every failure as lack of feature support. Permission failures, invalid arguments and unsupported operations require different handling. NFS can report link or rename failure after server-side execution, so local error observations must not become universal rollback claims. [2] [3] Continue with atomic rename and durable commit boundaries and synchronization failure handling.
Reproduce the observation
C probe, Python runner and raw JSON with source hashes. Run the two source files together in a directory you control:
python3 observe.py --output observation.json --directory /path/on/test/filesystemThe runner requires Linux, a C compiler, procfs and the findmnt utility. It creates and cleans private test directories. Unexpected or unsupported operations abort without writing a passing result. An existing output from an earlier run must not be mistaken for fresh evidence after failure.
Sequential local observation, not a concurrency proof, network-filesystem test or power-loss experiment. Runtime support, permissions and error handling remain deployment-specific. Neither this probe nor its successful sync calls certify a storage device, mount configuration or application transaction.
Primary sources
- Linux man-pages: open(2), O_TMPFILE
- Linux man-pages: link(2), linkat flags and errors
- Linux man-pages: rename(2), renameat2 flags
- Linux man-pages: fsync(2), file and directory persistence
- Pillai et al., All File Systems Are Not Created Equal, OSDI 2014, sections 2.2 and 3.2
- Linux v6.12, fs/namei.c: vfs_rename same-inode return and do_renameat2 destination checks
- Hesela: atomic exchange read-set experiment, method and frozen evidence
- Linux v6.8: directory locking, individual namespace primitives
- Zhang et al., ViewBox, FAST 2014, sections 3.3.1-3.3.2 and 4.2.2
Original sources accessed 17 October 2026; rename(2) and Linux v6.12 source reviewed 7 November 2026. Read-set sources reviewed 14 November 2026. API descriptions are paraphrased; the local observation and its limitations are Hesela's work.