diff options
author | Tavian Barnes <tavianator@tavianator.com> | 2023-07-04 15:37:54 -0400 |
---|---|---|
committer | Tavian Barnes <tavianator@tavianator.com> | 2023-07-10 17:29:12 -0400 |
commit | 739317470873422c1023eab22c570c374a10f498 (patch) | |
tree | d695086d44f34a0bf121613b0176216c17e9160c /src/dir.h | |
parent | 222ac5ba4fbab0ab880e36423d0f1338e39b02c7 (diff) | |
download | bfs-739317470873422c1023eab22c570c374a10f498.tar.xz |
bftw: Try to close files asynchronously
Diffstat (limited to 'src/dir.h')
-rw-r--r-- | src/dir.h | 30 |
1 files changed, 21 insertions, 9 deletions
@@ -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 |