summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--package/deps.mak3
-rw-r--r--src/include/skalibs/posixplz.h1
-rw-r--r--src/libposixplz/mkptemp.c16
-rw-r--r--src/libposixplz/mkptemp2.c24
4 files changed, 28 insertions, 16 deletions
diff --git a/package/deps.mak b/package/deps.mak
index c744e64..8ee2b3a 100644
--- a/package/deps.mak
+++ b/package/deps.mak
@@ -190,7 +190,8 @@ src/libposixplz/mkfiletemp.o src/libposixplz/mkfiletemp.lo: src/libposixplz/mkfi
src/libposixplz/mkhtemp.o src/libposixplz/mkhtemp.lo: src/libposixplz/mkhtemp.c src/include/skalibs/posixplz.h
src/libposixplz/mklinktemp.o src/libposixplz/mklinktemp.lo: src/libposixplz/mklinktemp.c src/include/skalibs/djbunix.h src/libposixplz/posixplz-internal.h src/include/skalibs/posixplz.h
src/libposixplz/mkltemp.o src/libposixplz/mkltemp.lo: src/libposixplz/mkltemp.c src/include/skalibs/posixplz.h
-src/libposixplz/mkptemp.o src/libposixplz/mkptemp.lo: src/libposixplz/mkptemp.c src/include/skalibs/djbunix.h src/include/skalibs/posixplz.h
+src/libposixplz/mkptemp.o src/libposixplz/mkptemp.lo: src/libposixplz/mkptemp.c src/include/skalibs/posixplz.h
+src/libposixplz/mkptemp2.o src/libposixplz/mkptemp2.lo: src/libposixplz/mkptemp2.c src/include/skalibs/djbunix.h src/include/skalibs/posixplz.h
src/libposixplz/setgroups.o src/libposixplz/setgroups.lo: src/libposixplz/setgroups.c src/include/skalibs/nonposix.h src/include/skalibs/posixishard.h src/include/skalibs/setgroups.h src/include/skalibs/sysdeps.h
src/libposixplz/strnlen.o src/libposixplz/strnlen.lo: src/libposixplz/strnlen.c src/include/skalibs/bytestr.h src/include/skalibs/posixishard.h src/include/skalibs/sysdeps.h
src/libposixplz/touch.o src/libposixplz/touch.lo: src/libposixplz/touch.c src/include/skalibs/djbunix.h src/include/skalibs/nonposix.h src/include/skalibs/posixplz.h src/include/skalibs/sysdeps.h
diff --git a/src/include/skalibs/posixplz.h b/src/include/skalibs/posixplz.h
index 22cdf3a..55e03fc 100644
--- a/src/include/skalibs/posixplz.h
+++ b/src/include/skalibs/posixplz.h
@@ -40,6 +40,7 @@ extern int touch (char const *) ;
extern int mkfiletemp (char *, createfunc_t_ref, mode_t, void *) ;
extern int mklinktemp (char const *, char *, linkfunc_t_ref) ;
extern int mkptemp (char *) ;
+extern int mkptemp2 (char *, unsigned int) ;
extern int mkltemp (char const *, char *) ;
extern int mkhtemp (char const *, char *) ;
extern int mkctemp (char *, mode_t, dev_t) ;
diff --git a/src/libposixplz/mkptemp.c b/src/libposixplz/mkptemp.c
index 64ddb5c..2c3e817 100644
--- a/src/libposixplz/mkptemp.c
+++ b/src/libposixplz/mkptemp.c
@@ -1,22 +1,8 @@
/* ISC license. */
-#include <sys/stat.h>
-
-#include <skalibs/djbunix.h>
#include <skalibs/posixplz.h>
-static int f (char const *fn, mode_t mode, void *data)
-{
- mode_t m = umask(0) ;
- int r = mkfifo(fn, mode) ;
- umask(m) ;
- if (r == -1) return -1 ;
- r = open_readb(fn) ;
- if (r == -1) unlink_void(fn) ;
- return r ;
-}
-
int mkptemp (char *s)
{
- return mkfiletemp(s, &f, 0600, 0) ;
+ return mkptemp2(s, 0) ;
}
diff --git a/src/libposixplz/mkptemp2.c b/src/libposixplz/mkptemp2.c
new file mode 100644
index 0000000..e4e9120
--- /dev/null
+++ b/src/libposixplz/mkptemp2.c
@@ -0,0 +1,24 @@
+/* ISC license. */
+
+#include <fcntl.h>
+#include <sys/stat.h>
+
+#include <skalibs/djbunix.h>
+#include <skalibs/posixplz.h>
+
+static int f (char const *fn, mode_t mode, void *data)
+{
+ unsigned int flags = *(unsigned int *)data ;
+ mode_t m = umask(0) ;
+ int r = mkfifo(fn, mode) ;
+ umask(m) ;
+ if (r == -1) return -1 ;
+ r = flags & O_NONBLOCK ? flags & O_CLOEXEC ? openc_read(fn) : open_read(fn) : flags & O_CLOEXEC ? openc_readb(fn) : open_readb(fn) ;
+ if (r == -1) unlink_void(fn) ;
+ return r ;
+}
+
+int mkptemp2 (char *s, unsigned int flags)
+{
+ return mkfiletemp(s, &f, 0600, &flags) ;
+}