Repository navigation
feat: implement O_TMPFILE + linkat for anonymous temp file writes - #2918
Merged
Merged
Conversation
oferchen
force-pushed
the
feat/o-tmpfile-anonymous-write
branch
from
March 22, 2026 08:05
2b1e476 to
a85f99a
Compare
Add open_anonymous_tmpfile() and link_anonymous_tmpfile() to fast_io for atomic file creation on Linux 3.11+. The anonymous file has no directory entry until linkat materializes it, eliminating crash-window partial files and temp name collisions. Includes o_tmpfile_available() probe with process-wide atomic cache, non-Linux stubs returning Unsupported, and Linux-gated unit tests.
oferchen
force-pushed
the
feat/o-tmpfile-anonymous-write
branch
from
March 22, 2026 08:59
a85f99a to
cfd98ef
Compare
oferchen
added a commit
that referenced
this pull request
May 1, 2026
) Add open_anonymous_tmpfile() and link_anonymous_tmpfile() to fast_io for atomic file creation on Linux 3.11+. The anonymous file has no directory entry until linkat materializes it, eliminating crash-window partial files and temp name collisions. Includes o_tmpfile_available() probe with process-wide atomic cache, non-Linux stubs returning Unsupported, and Linux-gated unit tests.
oferchen
added a commit
that referenced
this pull request
May 5, 2026
) Add open_anonymous_tmpfile() and link_anonymous_tmpfile() to fast_io for atomic file creation on Linux 3.11+. The anonymous file has no directory entry until linkat materializes it, eliminating crash-window partial files and temp name collisions. Includes o_tmpfile_available() probe with process-wide atomic cache, non-Linux stubs returning Unsupported, and Linux-gated unit tests.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
open_anonymous_tmpfile(dir, mode)- opens an unnamed inode viaO_TMPFILE | O_WRONLY | O_CLOEXECusinglibc::openlink_anonymous_tmpfile(fd, dest)- materializes the anonymous file at the final path vialinkat(AT_FDCWD, "/proc/self/fd/N", AT_FDCWD, dest, AT_SYMLINK_FOLLOW)o_tmpfile_available(dir)- probes filesystem support with process-wide atomic cache#[cfg(target_os = "linux")]; non-Linux stubs returnio::ErrorKind::Unsupportedfast_iocrate root for consumer convenienceThis eliminates the crash-window vulnerability of named temp files: the destination path either appears atomically with full content (via linkat) or does not appear at all (kernel reclaims the anonymous inode). No cleanup needed on failure, no name collisions possible.
Test plan