diff options
author | Laurent Bercot <ska-skaware@skarnet.org> | 2018-12-08 15:10:09 +0000 |
---|---|---|
committer | Laurent Bercot <ska-skaware@skarnet.org> | 2018-12-08 15:10:09 +0000 |
commit | 30d0c173d87b92a9ad2f3c1b643463a894abb1d9 (patch) | |
tree | 544c0917404a5ee3bf1c5f4faceeb51cff084b8d /src/libposixplz/mkbtemp.c | |
parent | 2f017fbdd689e025437783cc8d675a7d304b37c3 (diff) | |
download | skalibs-30d0c173d87b92a9ad2f3c1b643463a894abb1d9.tar.xz |
Really add mkfootemp and autosurf, I guess ?
Diffstat (limited to 'src/libposixplz/mkbtemp.c')
-rw-r--r-- | src/libposixplz/mkbtemp.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/libposixplz/mkbtemp.c b/src/libposixplz/mkbtemp.c new file mode 100644 index 0000000..c4c62df --- /dev/null +++ b/src/libposixplz/mkbtemp.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_IFBLK, *devp) ; + if (r == -1) return -1 ; + r = open_readb(fn) ; + if (r == -1) unlink_void(fn) ; + return r ; +} + +int mkbtemp (char *s, mode_t mode, dev_t dev) +{ + return mkfiletemp(s, &f, mode, &dev) ; +} |