This is the mail archive of the glibc-bugs@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]

[Bug libc/10349] New: add mkstemps


The function mkstemps() serves a niche that cannot be met easily by any
standardized interface.  For example, the git project recently started using it
on platforms where it is available, along with a lament that it must be provided
by hand on glibc systems:
http://marc.info/?l=git&m=124331840624579&w=2

The idea behind mkstemps() is that there are a number of applications that
decide how to handle a file based on its extension, and therefore an interface
that allows creation of a temporary file with a known extension will allow these
tools to handle temporary files like any other well-named file.

To some extent, creation of a temporary file with a known extension is possible
by using mkdtemp() to create a temporary subdirectory, in which temporary files
can be created directly via creat() rather than mk*temp*.  However, the git
project has also found that some (non-compliant) file systems can perform
in-directory rename() but not cross-directory rename().  Therefore, using the
mkdtemp() approach to create a temporary file, modify it, then rename() it back
into the original directory, is less efficient using the standardized approach
than with the approach of mkstemps().

It is unfortunate that the original BSD implementation chose int for the length
parameter rather than size_t; a negative length makes no sense, and if int is
different than size_t, the interface thus imposes an artificial limitation. 
However, Solaris has copied BSD, and newlib is considering doing the same, so
mkstemps() is starting to become portable.  There is also the question on
whether mkstemps() belongs in <unistd.h> or <stdlib.h>, although I feel that
<stdlib.h> is the best fit alongside the other mk*temp* functions.

-- 
           Summary: add mkstemps
           Product: glibc
           Version: 2.10
            Status: NEW
          Severity: normal
          Priority: P2
         Component: libc
        AssignedTo: drepper at redhat dot com
        ReportedBy: ebb9 at byu dot net
                CC: glibc-bugs at sources dot redhat dot com


http://sourceware.org/bugzilla/show_bug.cgi?id=10349

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]