diff options
author | Laurent Bercot <ska-skaware@skarnet.org> | 2021-12-04 08:48:45 +0000 |
---|---|---|
committer | Laurent Bercot <ska@appnovation.com> | 2021-12-04 08:48:45 +0000 |
commit | 032b853746aabb8c3b82af674fdc783b511569f2 (patch) | |
tree | 79edb0d7148cf2ef34874a20a3f760e464d50025 /src | |
parent | 450e114e1e1651c65dfcdbfa3c6f3967163976b3 (diff) | |
download | skalibs-032b853746aabb8c3b82af674fdc783b511569f2.tar.xz |
Add opendir_at, prepare for 2.11.1.0
Signed-off-by: Laurent Bercot <ska@appnovation.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/include/skalibs/unix-transactional.h | 2 | ||||
-rw-r--r-- | src/libstddjb/fd_close.c | 4 | ||||
-rw-r--r-- | src/libunixonacid/opendir_at.c | 15 |
3 files changed, 19 insertions, 2 deletions
diff --git a/src/include/skalibs/unix-transactional.h b/src/include/skalibs/unix-transactional.h index a5e14b3..88d1838 100644 --- a/src/include/skalibs/unix-transactional.h +++ b/src/include/skalibs/unix-transactional.h @@ -8,6 +8,7 @@ #include <sys/uio.h> #include <skalibs/uint64.h> +#include <skalibs/direntry.h> #include <skalibs/stralloc.h> /* Transactional/reliable filesystem operations */ @@ -26,6 +27,7 @@ extern int open_truncat (int, char const *) ; extern int open_truncatb (int, char const *) ; extern int open_appendat (int, char const *) ; extern int open_appendatb (int, char const *) ; +extern DIR *opendir_at (int, char const *) ; extern int stat_at (int, char const *, struct stat *) ; extern int lstat_at (int, char const *, struct stat *) ; diff --git a/src/libstddjb/fd_close.c b/src/libstddjb/fd_close.c index a3c7880..dad6518 100644 --- a/src/libstddjb/fd_close.c +++ b/src/libstddjb/fd_close.c @@ -1,12 +1,12 @@ /* ISC license. */ -#include <unistd.h> #include <errno.h> +#include <unistd.h> #include <skalibs/djbunix.h> void fd_close (int fd) { int e = errno ; - while (close(fd) < 0 && errno == EINTR) ; + close(fd) ; errno = e ; } diff --git a/src/libunixonacid/opendir_at.c b/src/libunixonacid/opendir_at.c new file mode 100644 index 0000000..bee971f --- /dev/null +++ b/src/libunixonacid/opendir_at.c @@ -0,0 +1,15 @@ +/* ISC license. */ + +#include <skalibs/direntry.h> +#include <skalibs/djbunix.h> +#include <skalibs/unix-transactional.h> + +DIR *opendir_at (int dfd, char const *name) +{ + DIR *dir ; + int fd = open_readatb(dfd, name) ; + if (fd < 0) return 0 ; + dir = fdopendir(fd) ; + if (!dir) fd_close(fd) ; + return dir ; +} |