[systemd-devel] [RFC PATCH 1/2] Replace mkostemp+unlink with open(O_TMPFILE)
Zbigniew Jędrzejewski-Szmek
zbyszek at in.waw.pl
Mon Jan 27 08:35:38 PST 2014
On Mon, Jan 27, 2014 at 03:14:28PM +0100, Lennart Poettering wrote:
> 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?
mkostemp is not on the list of "safe" functions. I looked at the
implementation, and it actually has a static variable, so it really
cannot be called.
> > +#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...
It has different values on different archs... Possible to replicate, but
ugly.
Zbyszek
More information about the systemd-devel
mailing list