summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/include/skalibs/unix-transactional.h2
-rw-r--r--src/libstddjb/fd_close.c4
-rw-r--r--src/libunixonacid/opendir_at.c15
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 ;
+}