summaryrefslogtreecommitdiffstats
path: root/src/dir.h
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2023-07-04 15:37:54 -0400
committerTavian Barnes <tavianator@tavianator.com>2023-07-10 17:29:12 -0400
commit739317470873422c1023eab22c570c374a10f498 (patch)
treed695086d44f34a0bf121613b0176216c17e9160c /src/dir.h
parent222ac5ba4fbab0ab880e36423d0f1338e39b02c7 (diff)
downloadbfs-739317470873422c1023eab22c570c374a10f498.tar.xz
bftw: Try to close files asynchronously
Diffstat (limited to 'src/dir.h')
-rw-r--r--src/dir.h30
1 files changed, 21 insertions, 9 deletions
diff --git a/src/dir.h b/src/dir.h
index 16f592e..1137ff5 100644
--- a/src/dir.h
+++ b/src/dir.h
@@ -13,6 +13,14 @@
#include <sys/types.h>
/**
+ * Whether the implementation uses the getdents() syscall directly, rather than
+ * libc's readdir().
+ */
+#ifndef BFS_USE_GETDENTS
+# define BFS_USE_GETDENTS (__linux__ || __FreeBSD__)
+#endif
+
+/**
* A directory.
*/
struct bfs_dir;
@@ -129,18 +137,22 @@ int bfs_readdir(struct bfs_dir *dir, struct bfs_dirent *de);
int bfs_closedir(struct bfs_dir *dir);
/**
- * Extract the file descriptor from an open directory.
+ * Whether the bfs_unwrapdir() function is supported.
+ */
+#ifndef BFS_USE_UNWRAPDIR
+# define BFS_USE_UNWRAPDIR (BFS_USE_GETDENTS || __FreeBSD__)
+#endif
+
+#if BFS_USE_UNWRAPDIR
+/**
+ * Detach the file descriptor from an open directory.
*
* @param dir
- * The directory to free.
- * @param same_fd
- * If true, require that the returned file descriptor is the same one
- * that bfs_dirfd() would have returned. Otherwise, it may be a new
- * file descriptor for the same directory.
+ * The directory to detach.
* @return
- * On success, a file descriptor for the directory is returned. On
- * failure, -1 is returned, and the directory remains open.
+ * The file descriptor of the directory.
*/
-int bfs_fdclosedir(struct bfs_dir *dir, bool same_fd);
+int bfs_unwrapdir(struct bfs_dir *dir);
+#endif
#endif // BFS_DIR_H