On Tue, Sep 25, 2018 at 07:35:11PM +0200, Adam Borowski wrote: > Isn't this what the snippet for O_TMPFILE in "man 2 open" does?: > > char path[PATH_MAX]; > fd = open("/path/to/dir", O_TMPFILE | O_RDWR, > S_IRUSR | S_IWUSR); > > /* File I/O on 'fd'... */ > > snprintf(path, PATH_MAX, "/proc/self/fd/%d", fd); > linkat(AT_FDCWD, path, AT_FDCWD, "/path/for/file", > AT_SYMLINK_FOLLOW); Huh. I stand corrected. I had assumed O_TMPFILE worked like any other file where the link count was zero, and linkat(2) wouldn't allow this. But obviously, this does work. In fact, from the linkat(2) man page, using: linkat(fd, NULL, AT_FDCWD, "/path/for/file", AT_EMPTY_PATH); is an even simpler way that doesn't /proc being mounted. TIL... - Ted