O_TMPFILE
O_TMPFILE is a Linux open flag that creates a regular file without a directory entry in a specified directory's filesystem.
Use a writable access mode and an explicit permission mode. Adding O_EXCL prevents later linking, rather than selecting no-overwrite publication. Support depends on the filesystem. [1]
An ordinary file unlinked while open is not equivalent. Its descriptor can retain readable data, but Linux rejects relinking it after its last name is removed. O_TMPFILE without O_EXCL is a specific exception to the zero-link restriction, not a general undelete mechanism. [2]
Relations
- related
- hard-link, inode, directory-fsync, rename-noreplace
Citations
- Linux man-pages: open(2), O_TMPFILE
- Linux man-pages: link(2), zero-link exception and ENOENT
- Hesela: unnamed-file publication observation
Sources & caveats
- The local ext4 probe measured zero links before O_TMPFILE publication, preserved inode identity after publication, and rejected relinking an ordinary unlinked file; no power-loss recovery was tested. [3]