Add mkostemp and mkostemps.

* mktemp.cc (_gettemp): Add flags argument.  All callers updated.
(mkostemp, mkostemps): New functions.
* cygwin.din (mkostemp, mkostemps): Export.
* posix.sgml: Document them.
* include/cygwin/version.h: Bump version.
This commit is contained in:
Eric Blake 2010-07-19 18:22:40 +00:00
parent 8092f46770
commit 3083fa9447
5 changed files with 35 additions and 8 deletions

View File

@ -1,3 +1,11 @@
2010-07-19 Eric Blake <eblake@redhat.com>
* mktemp.cc (_gettemp): Add flags argument. All callers updated.
(mkostemp, mkostemps): New functions.
* cygwin.din (mkostemp, mkostemps): Export.
* posix.sgml: Document them.
* include/cygwin/version.h: Bump version.
2010-07-18 Christopher Faylor <me+cygwin@cgf.cx> 2010-07-18 Christopher Faylor <me+cygwin@cgf.cx>
* autoload.cc (noload): Use "pushl" rather than "push". * autoload.cc (noload): Use "pushl" rather than "push".

View File

@ -995,6 +995,8 @@ mknod SIGFE
_mknod = mknod SIGFE _mknod = mknod SIGFE
_mknod32 = mknod32 SIGFE _mknod32 = mknod32 SIGFE
mknodat SIGFE mknodat SIGFE
mkostemp SIGFE
mkostemps SIGFE
mkstemp SIGFE mkstemp SIGFE
_mkstemp = mkstemp SIGFE _mkstemp = mkstemp SIGFE
mkstemps SIGFE mkstemps SIGFE

View File

@ -388,12 +388,13 @@ details. */
226: Export __locale_mb_cur_max. 226: Export __locale_mb_cur_max.
227: Add pseudo_reloc_start, pseudo_reloc_end, image_base to per_process. 227: Add pseudo_reloc_start, pseudo_reloc_end, image_base to per_process.
228: CW_STRERROR added. 228: CW_STRERROR added.
229: Add mkostemp, mkostemps.
*/ */
/* Note that we forgot to bump the api for ualarm, strtoll, strtoull */ /* Note that we forgot to bump the api for ualarm, strtoll, strtoull */
#define CYGWIN_VERSION_API_MAJOR 0 #define CYGWIN_VERSION_API_MAJOR 0
#define CYGWIN_VERSION_API_MINOR 228 #define CYGWIN_VERSION_API_MINOR 229
/* There is also a compatibity version number associated with the /* There is also a compatibity version number associated with the
shared memory regions. It is incremented when incompatible shared memory regions. It is incremented when incompatible

View File

@ -10,7 +10,7 @@ See the copyright at the bottom of this file. */
#include <sys/stat.h> #include <sys/stat.h>
#include <unistd.h> #include <unistd.h>
static int _gettemp(char *, int *, int, size_t); static int _gettemp(char *, int *, int, size_t, int);
static uint32_t arc4random (); static uint32_t arc4random ();
static const char padchar[] = static const char padchar[] =
@ -20,30 +20,44 @@ extern "C" int
mkstemp(char *path) mkstemp(char *path)
{ {
int fd; int fd;
return _gettemp(path, &fd, 0, 0) ? fd : -1; return _gettemp(path, &fd, 0, 0, O_BINARY) ? fd : -1;
} }
extern "C" char * extern "C" char *
mkdtemp(char *path) mkdtemp(char *path)
{ {
return _gettemp(path, NULL, 1, 0) ? path : NULL; return _gettemp(path, NULL, 1, 0, 0) ? path : NULL;
} }
extern "C" int extern "C" int
mkstemps(char *path, int len) mkstemps(char *path, int len)
{ {
int fd; int fd;
return _gettemp(path, &fd, 0, len) ? fd : -1; return _gettemp(path, &fd, 0, len, O_BINARY) ? fd : -1;
}
extern "C" int
mkostemp(char *path, int flags)
{
int fd;
return _gettemp(path, &fd, 0, 0, flags & ~O_ACCMODE) ? fd : -1;
}
extern "C" int
mkostemps(char *path, int len, int flags)
{
int fd;
return _gettemp(path, &fd, 0, len, flags & ~O_ACCMODE) ? fd : -1;
} }
extern "C" char * extern "C" char *
mktemp(char *path) mktemp(char *path)
{ {
return _gettemp(path, NULL, 0, 0) ? path : (char *) NULL; return _gettemp(path, NULL, 0, 0, 0) ? path : (char *) NULL;
} }
static int static int
_gettemp(char *path, int *doopen, int domkdir, size_t suffixlen) _gettemp(char *path, int *doopen, int domkdir, size_t suffixlen, int flags)
{ {
char *start, *trv, *suffp; char *start, *trv, *suffp;
char *pad; char *pad;
@ -105,7 +119,7 @@ _gettemp(char *path, int *doopen, int domkdir, size_t suffixlen)
{ {
if (doopen) if (doopen)
{ {
if ((*doopen = open (path, O_CREAT | O_EXCL | O_RDWR | O_BINARY, if ((*doopen = open (path, O_CREAT | O_EXCL | O_RDWR | flags,
S_IRUSR | S_IWUSR)) >= 0) S_IRUSR | S_IWUSR)) >= 0)
return 1; return 1;
if (errno != EEXIST) if (errno != EEXIST)

View File

@ -1043,6 +1043,8 @@ also IEEE Std 1003.1-2008 (POSIX.1-2008).</para>
lsetxattr lsetxattr
memmem memmem
mempcpy mempcpy
mkostemp
mkostemps
pipe2 pipe2
pow10 pow10
pow10f pow10f