Bug 283179 - Support O_TMPFILE in open()
Summary: Support O_TMPFILE in open()
Status: New
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: 15.0-CURRENT
Hardware: Any Any
: --- Affects Only Me
Assignee: freebsd-bugs (Nobody)
URL:
Keywords: feature
Depends on:
Blocks:
 
Reported: 2024-12-07 13:12 UTC by vini.ipsmaker
Modified: 2024-12-08 18:06 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description vini.ipsmaker 2024-12-07 13:12:56 UTC
Linux supports the creation of unlinked inodes (unnamed temporary regular files) that can later be linked in the filesystem with linkat(): https://www.mankier.com/2/open#Description-O_TMPFILE

> Create an unnamed temporary regular file. The pathname argument specifies a directory; an unnamed inode will be created in that directory's filesystem. Anything written to the resulting file will be lost when the last file descriptor is closed, unless the file is given a name.

I believe OpenZFS already supports this feature given the history of fixed bug reports such as <https://github.com/openzfs/zfs/issues/14301>.

Could FreeBSD just expose this feature already supported by OpenZFS?

The main use cases:

> * Improved tmpfile(3) functionality: race-free creation of temporary files that (1) are automatically deleted when closed; (2) can never be reached via any pathname; (3) are not subject to symlink attacks; and (4) do not require the caller to devise unique names.
>
> * Creating a file that is initially invisible, which is then populated with data and adjusted to have appropriate filesystem attributes (fchown(2), fchmod(2), fsetxattr(2), etc.) before being atomically linked into the filesystem in a fully formed state (using linkat(2) as described above).