summaryrefslogtreecommitdiffstats
path: root/winsup
diff options
context:
space:
mode:
authorEric Blake <eblake@redhat.com>2010-07-19 18:22:40 +0000
committerEric Blake <eblake@redhat.com>2010-07-19 18:22:40 +0000
commit3083fa9447f7a98bf23562097cf82746fe9d9c5b (patch)
tree8e8a9046fe15057b18eac288deb3846b524e4e06 /winsup
parent8092f467704a09cbfffb553e38f6ca1408c0d9ed (diff)
downloadcygnal-3083fa9447f7a98bf23562097cf82746fe9d9c5b.tar.gz
cygnal-3083fa9447f7a98bf23562097cf82746fe9d9c5b.tar.bz2
cygnal-3083fa9447f7a98bf23562097cf82746fe9d9c5b.zip
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.
Diffstat (limited to 'winsup')
-rw-r--r--winsup/cygwin/ChangeLog8
-rw-r--r--winsup/cygwin/cygwin.din2
-rw-r--r--winsup/cygwin/include/cygwin/version.h3
-rw-r--r--winsup/cygwin/mktemp.cc28
-rw-r--r--winsup/cygwin/posix.sgml2
5 files changed, 35 insertions, 8 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index ca9a326c0..c9bd3fc1f 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -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>
* autoload.cc (noload): Use "pushl" rather than "push".
diff --git a/winsup/cygwin/cygwin.din b/winsup/cygwin/cygwin.din
index fa5c77dd7..9253d2cbe 100644
--- a/winsup/cygwin/cygwin.din
+++ b/winsup/cygwin/cygwin.din
@@ -995,6 +995,8 @@ mknod SIGFE
_mknod = mknod SIGFE
_mknod32 = mknod32 SIGFE
mknodat SIGFE
+mkostemp SIGFE
+mkostemps SIGFE
mkstemp SIGFE
_mkstemp = mkstemp SIGFE
mkstemps SIGFE
diff --git a/winsup/cygwin/include/cygwin/version.h b/winsup/cygwin/include/cygwin/version.h
index 3a95e51e5..9924e4212 100644
--- a/winsup/cygwin/include/cygwin/version.h
+++ b/winsup/cygwin/include/cygwin/version.h
@@ -388,12 +388,13 @@ details. */
226: Export __locale_mb_cur_max.
227: Add pseudo_reloc_start, pseudo_reloc_end, image_base to per_process.
228: CW_STRERROR added.
+ 229: Add mkostemp, mkostemps.
*/
/* Note that we forgot to bump the api for ualarm, strtoll, strtoull */
#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
shared memory regions. It is incremented when incompatible
diff --git a/winsup/cygwin/mktemp.cc b/winsup/cygwin/mktemp.cc
index b8a1381c4..7770c3bff 100644
--- a/winsup/cygwin/mktemp.cc
+++ b/winsup/cygwin/mktemp.cc
@@ -10,7 +10,7 @@ See the copyright at the bottom of this file. */
#include <sys/stat.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 const char padchar[] =
@@ -20,30 +20,44 @@ extern "C" int
mkstemp(char *path)
{
int fd;
- return _gettemp(path, &fd, 0, 0) ? fd : -1;
+ return _gettemp(path, &fd, 0, 0, O_BINARY) ? fd : -1;
}
extern "C" char *
mkdtemp(char *path)
{
- return _gettemp(path, NULL, 1, 0) ? path : NULL;
+ return _gettemp(path, NULL, 1, 0, 0) ? path : NULL;
}
extern "C" int
mkstemps(char *path, int len)
{
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 *
mktemp(char *path)
{
- return _gettemp(path, NULL, 0, 0) ? path : (char *) NULL;
+ return _gettemp(path, NULL, 0, 0, 0) ? path : (char *) NULL;
}
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 *pad;
@@ -105,7 +119,7 @@ _gettemp(char *path, int *doopen, int domkdir, size_t suffixlen)
{
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)
return 1;
if (errno != EEXIST)
diff --git a/winsup/cygwin/posix.sgml b/winsup/cygwin/posix.sgml
index 6a3bc2298..fdd7589c1 100644
--- a/winsup/cygwin/posix.sgml
+++ b/winsup/cygwin/posix.sgml
@@ -1043,6 +1043,8 @@ also IEEE Std 1003.1-2008 (POSIX.1-2008).</para>
lsetxattr
memmem
mempcpy
+ mkostemp
+ mkostemps
pipe2
pow10
pow10f