diff options
Diffstat (limited to 'src/libposixplz/mkctemp.c')
-rw-r--r-- | src/libposixplz/mkctemp.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/libposixplz/mkctemp.c b/src/libposixplz/mkctemp.c new file mode 100644 index 0000000..69035fb --- /dev/null +++ b/src/libposixplz/mkctemp.c @@ -0,0 +1,21 @@ +/* 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) +{ + dev_t *devp = data ; + int r = mknod(fn, (mode & 00777) | S_IFCHR, *devp) ; + if (r == -1) return -1 ; + r = open_readb(fn) ; + if (r == -1) unlink_void(fn) ; + return r ; +} + +int mkctemp (char *s, mode_t mode, dev_t dev) +{ + return mkfiletemp(s, &f, mode, &dev) ; +} |