diff options
-rwxr-xr-x | configure | 1 | ||||
-rw-r--r-- | package/deps.mak | 4 | ||||
-rw-r--r-- | src/libstddjb/fd_sync.c | 2 | ||||
-rw-r--r-- | src/libunixonacid/opendir_at.c | 31 | ||||
-rw-r--r-- | src/sysdeps/tryfdopendir.c | 22 |
5 files changed, 52 insertions, 8 deletions
@@ -621,6 +621,7 @@ trytypes choose cl accept4 'accept4()' choose c cmsgcloexec 'MSG_CMSG_CLOEXEC' choose cl dirfd 'dirfd()' +choose cl fdopendir 'fdopendir()' choose cl eventfd 'eventfd()' choose cl flock 'flock()' choose cl getpeereid 'getpeereid()' diff --git a/package/deps.mak b/package/deps.mak index fda93e6..bec13ce 100644 --- a/package/deps.mak +++ b/package/deps.mak @@ -337,7 +337,7 @@ src/libstddjb/fd_readv.o src/libstddjb/fd_readv.lo: src/libstddjb/fd_readv.c src src/libstddjb/fd_recv.o src/libstddjb/fd_recv.lo: src/libstddjb/fd_recv.c src/include/skalibs/allreadwrite.h src/libstddjb/fd_send.o src/libstddjb/fd_send.lo: src/libstddjb/fd_send.c src/include/skalibs/allreadwrite.h src/libstddjb/fd_shutdown.o src/libstddjb/fd_shutdown.lo: src/libstddjb/fd_shutdown.c src/include/skalibs/djbunix.h src/include/skalibs/nonposix.h -src/libstddjb/fd_sync.o src/libstddjb/fd_sync.lo: src/libstddjb/fd_sync.c src/include/skalibs/djbunix.h src/include/skalibs/nonposix.h +src/libstddjb/fd_sync.o src/libstddjb/fd_sync.lo: src/libstddjb/fd_sync.c src/include/skalibs/djbunix.h src/libstddjb/fd_unlock.o src/libstddjb/fd_unlock.lo: src/libstddjb/fd_unlock.c src/include/skalibs/djbunix.h src/include/skalibs/fcntl.h src/libstddjb/fd_write.o src/libstddjb/fd_write.lo: src/libstddjb/fd_write.c src/include/skalibs/allreadwrite.h src/libstddjb/fd_writev.o src/libstddjb/fd_writev.lo: src/libstddjb/fd_writev.c src/include/skalibs/allreadwrite.h @@ -756,7 +756,7 @@ src/libunixonacid/openc_truncat.o src/libunixonacid/openc_truncat.lo: src/libuni src/libunixonacid/openc_truncatb.o src/libunixonacid/openc_truncatb.lo: src/libunixonacid/openc_truncatb.c src/include/skalibs/djbunix.h src/include/skalibs/unix-transactional.h src/libunixonacid/openc_writeat.o src/libunixonacid/openc_writeat.lo: src/libunixonacid/openc_writeat.c src/include/skalibs/fcntl.h src/include/skalibs/unix-transactional.h src/libunixonacid/openc_writeatb.o src/libunixonacid/openc_writeatb.lo: src/libunixonacid/openc_writeatb.c src/include/skalibs/djbunix.h src/include/skalibs/unix-transactional.h -src/libunixonacid/opendir_at.o src/libunixonacid/opendir_at.lo: src/libunixonacid/opendir_at.c src/include/skalibs/direntry.h src/include/skalibs/djbunix.h src/include/skalibs/nonposix.h src/include/skalibs/unix-transactional.h +src/libunixonacid/opendir_at.o src/libunixonacid/opendir_at.lo: src/libunixonacid/opendir_at.c src/include/skalibs/direntry.h src/include/skalibs/djbunix.h src/include/skalibs/nonposix.h src/include/skalibs/sysdeps.h src/include/skalibs/unix-transactional.h src/libunixonacid/opengetlnclose.o src/libunixonacid/opengetlnclose.lo: src/libunixonacid/opengetlnclose.c src/include/skalibs/allreadwrite.h src/include/skalibs/buffer.h src/include/skalibs/djbunix.h src/include/skalibs/skamisc.h src/include/skalibs/unix-transactional.h src/libunixonacid/opengetlnclose_at.o src/libunixonacid/opengetlnclose_at.lo: src/libunixonacid/opengetlnclose_at.c src/include/skalibs/allreadwrite.h src/include/skalibs/buffer.h src/include/skalibs/djbunix.h src/include/skalibs/skamisc.h src/include/skalibs/unix-transactional.h src/libunixonacid/openreadnclose_at.o src/libunixonacid/openreadnclose_at.lo: src/libunixonacid/openreadnclose_at.c src/include/skalibs/djbunix.h src/include/skalibs/unix-transactional.h diff --git a/src/libstddjb/fd_sync.c b/src/libstddjb/fd_sync.c index c4d359b..4506523 100644 --- a/src/libstddjb/fd_sync.c +++ b/src/libstddjb/fd_sync.c @@ -1,7 +1,5 @@ /* ISC license. */ -#include <skalibs/nonposix.h> /* lol MacOS */ - #include <unistd.h> #include <errno.h> diff --git a/src/libunixonacid/opendir_at.c b/src/libunixonacid/opendir_at.c index c1de4f1..d5a3221 100644 --- a/src/libunixonacid/opendir_at.c +++ b/src/libunixonacid/opendir_at.c @@ -1,19 +1,42 @@ /* ISC license. */ -/* Should not be necessary but old NetBSD/OpenBSD fail to - properly expose fdopendir() otherwise */ +#include <skalibs/sysdeps.h> #include <skalibs/nonposix.h> - #include <skalibs/direntry.h> #include <skalibs/djbunix.h> #include <skalibs/unix-transactional.h> +#ifdef SKALIBS_HASFDOPENDIR + DIR *opendir_at (int dfd, char const *name) { DIR *dir ; int fd = openc_readatb(dfd, name) ; - if (fd < 0) return 0 ; + if (fd == -1) return 0 ; dir = fdopendir(fd) ; if (!dir) fd_close(fd) ; return dir ; } + +#else + +#include <unistd.h> +#include <stdlib.h> + +DIR *opendir_at (int dfd, char const *name) +{ + DIR *dir ; + int here = open_read(".") ; + if (here == -1) return 0 ; + if (fchdir(dfd) == -1) + { + fd_close(here) ; + return 0 ; + } + dir = opendir(name) ; + if (fchdir(here) == -1) abort() ; + fd_close(here) ; + return dir ; +} + +#endif diff --git a/src/sysdeps/tryfdopendir.c b/src/sysdeps/tryfdopendir.c new file mode 100644 index 0000000..d9a8f01 --- /dev/null +++ b/src/sysdeps/tryfdopendir.c @@ -0,0 +1,22 @@ +/* ISC license. */ + +#undef _POSIX_C_SOURCE +#undef _XOPEN_SOURCE + +#ifndef _GNU_SOURCE +#define _GNU_SOURCE +#endif +#ifndef _NETBSD_SOURCE +#define _NETBSD_SOURCE +#endif +#ifndef __EXTENSIONS__ +#define __EXTENSIONS__ +#endif + +#include <dirent.h> + +int main (void) +{ + DIR *dir = fdopendir(0) ; + return !dir ; +} |