From 0c10a1e984bc2bed1fe3a7dadbd94a9c24139a91 Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Tue, 11 Apr 2023 22:06:42 -0400 Subject: dir: Add a flag to bfs_freedir() to force the fd to stay the same --- src/bftw.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/bftw.c') diff --git a/src/bftw.c b/src/bftw.c index 916a56b..a3e8d9b 100644 --- a/src/bftw.c +++ b/src/bftw.c @@ -853,13 +853,13 @@ static int bftw_gc(struct bftw_state *state, enum bftw_gc_flags flags) { if (file->refcount > 1) { // Keep the fd around if any subdirectories exist - file->fd = bfs_freedir(state->dir); + file->fd = bfs_freedir(state->dir, false); } else { - bfs_closedir(state->dir); file->fd = -1; } if (file->fd < 0) { + bfs_closedir(state->dir); bftw_cache_remove(&state->cache, file); } } -- cgit v1.2.3