[systemd-devel] [RFC PATCH 1/2] Replace mkostemp+unlink with open(O_TMPFILE)

Lennart Poettering lennart at poettering.net
Mon Jan 27 06:14:28 PST 2014


On Sun, 26.01.14 00:21, Zbigniew Jędrzejewski-Szmek (zbyszek at in.waw.pl) wrote:

> This will only work on Linux >= 3.11, and probably not on all
> filesystems. Fallback code is provided.
> ---
> Hi,
> 
> because on bug https://bugzilla.gnome.org/show_bug.cgi?id=722889, I
> was looking into async signal safety of the journal logging functions.
> All that do any formatting are unsafe, but sd_journal_sendv *almost*
> is. Currently it calls mkostemp and writev, but only in the fallback
> path.  So for the purpose of simple logging without multi-megabyte
> messages it already is safe. But it would be nice to turn this into an
> explicit guarantee. When O_TMPFILE is not available, it is hard to

Yupp, it's certainly a good idea to make our logging functions safe for
execution in any context.

What I don't understands though is why mkostemp() would not be safe here?

> +#ifdef O_TMPFILE
> +        fd = open(path, flags | O_TMPFILE, S_IRUSR | S_IWUSR);
> +        if (fd >= 0)
> +                return fd;
> +#endif

Hmm, O_TMPFILE sounds like something to define in missing.h and then
unconditionally use...

Lennart

-- 
Lennart Poettering, Red Hat


More information about the systemd-devel mailing list