summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2020-09-20 17:09:15 -0400
committerTavian Barnes <tavianator@tavianator.com>2020-09-20 17:09:15 -0400
commit99a49c0add96bfb75a65ccebb922378f3975f7d9 (patch)
treef53f7d818fdb11a4cab0811077b77417c6b6c4a9
parent2eb92b83a3b914f518f463f9330e185b43595450 (diff)
downloadbfs-99a49c0add96bfb75a65ccebb922378f3975f7d9.tar.xz
bftw: Fix bftw_cached_stat() with BFS_STAT_TRYFOLLOW
-rw-r--r--bftw.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/bftw.c b/bftw.c
index af9b400..dc04ce0 100644
--- a/bftw.c
+++ b/bftw.c
@@ -889,8 +889,12 @@ const struct bfs_stat *bftw_stat(const struct BFTW *ftwbuf, enum bfs_stat_flags
const struct bfs_stat *bftw_cached_stat(const struct BFTW *ftwbuf, enum bfs_stat_flags flags) {
if (flags & BFS_STAT_NOFOLLOW) {
return ftwbuf->lstat_cache.buf;
- } else {
+ } else if (ftwbuf->stat_cache.buf) {
return ftwbuf->stat_cache.buf;
+ } else if ((flags & BFS_STAT_TRYFOLLOW) && is_nonexistence_error(ftwbuf->stat_cache.error)) {
+ return ftwbuf->lstat_cache.buf;
+ } else {
+ return NULL;
}
}