This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Other format: | [Raw text] |
On Thu, Aug 31, 2017 at 05:34:16PM -0300, Adhemerval Zanella wrote: > This patch adds support to use O_TMPFILE on tmpfile on Linux. This is ... adds O_TMPFILE support to tmpfile on Linux. > similar previous suggestion by Andreas Schwab [1] with the difference similar to the previous ... with the difference that > the file descriptor creation is parameterized to compartmentalize Linux > only open flags (O_TMPFILE) on sysdep folder. ... into sysdeps. [...] > diff --git a/stdio-common/tmpfile.c b/stdio-common/tmpfile.c > index e6030be..3e35345 100644 > --- a/stdio-common/tmpfile.c > +++ b/stdio-common/tmpfile.c > @@ -34,23 +34,34 @@ > FILE * > tmpfile (void) > { > - char buf[FILENAME_MAX]; > int fd; > FILE *f; > - > - if (__path_search (buf, FILENAME_MAX, NULL, "tmpf", 0)) > - return NULL; > int flags = 0; > #ifdef FLAGS > flags = FLAGS; > #endif > - fd = __gen_tempname (buf, 0, flags, __GT_FILE); > + > + /* First try a system specific method. */ > + fd = __gen_tempfd (flags); > + > if (fd < 0) > - return NULL; > + { > + char buf[FILENAME_MAX]; > > - /* Note that this relies on the Unix semantics that > - a file is not really removed until it is closed. */ > - (void) __unlink (buf); > + if (__path_search (buf, sizeof buf, NULL, "tmpf", 0)) > + return NULL; > + > + fd = __gen_tempname (buf, 0, flags, __GT_FILE); > + if (fd < 0) > + return NULL; > + > + /* Note that this relies on the Unix semantics that > + a file is not really removed until it is closed. */ > + (void) __unlink (buf); > + } > + > + if (fd < 0) > + return NULL; The last "if (fd < 0)" check is redundant. -- ldv
Attachment:
signature.asc
Description: PGP signature
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |