[llvm-dev] Experiment on how to improve our temporary file handing. (original) (raw)

Rafael Avila de Espindola via llvm-dev llvm-dev at lists.llvm.org
Mon Nov 13 15:29:32 PST 2017


Konstantin Belousov <kostikbel at gmail.com> writes:

On Mon, Nov 13, 2017 at 01:46:32PM -0800, Davide Italiano wrote:

On Mon, Nov 13, 2017 at 11:48 AM, Rafael Avila de Espindola <rafael.espindola at gmail.com> wrote: > Davide Italiano <davide.italiano at gmail.com> writes: > >>> I couldn't find any support for this on FreeBSD. >>> >> >> AFAIK FreeBSD supports some variant of /proc that should map Linux >> (although the mapping isn't 1:1). >> Does it lack support for this? Thanks for looking into this, BTW! > > OTMPFILE is the main thing that seems to be missing. >

It doesn't seem unreasonable to ask FreeBSD to implement this (at least for ufs/zfs), maybe Ed/Kostik have thoughts about it. Can you please explain, how exactly OTMPFILE functionality you asking for relates to the /proc ? Do you want to re-link OTMPFILE-opened inodes into named files ?

The relation to proc seems to be a linux peculiarity.

What we want in the end is to implement "-o foo" in lld with the following guarantees:

1 foo is only created with the final content. 2 We don't leave a temporary file behind on a power failure. 3 Less critical but nice: if foo already exists, it is replaced atomically.

Using mkstemp + rename we get 1 and 3.

On linux we can use O_TMPFILE, but the only way for a non privileged process to then give a name to that fd is:

linkat(AT_FDCWD, "/proc/self/fd/", AT_FDCWD, "destination", AT_SYMLINK_FOLLOW)

which has two problem: It requires proc to be mounted and it is not atomic if the destination already exists.

A system with O_TMPFILE which allows some form of renameat to atomically give that fd a name would be perfect.

Cheers, Rafael



More information about the llvm-dev mailing list