summaryrefslogtreecommitdiffstats
path: root/bftw.c
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2017-07-09 16:35:38 -0400
committerTavian Barnes <tavianator@tavianator.com>2017-07-09 16:35:38 -0400
commit2328d8dbb5a8c774afb99d363b6e98cd25ee304d (patch)
tree53822ecfebc872335e9b13f2fb255f0b2aa808d6 /bftw.c
parentf4eed3b771a987ef441fea49ababc356a2933086 (diff)
downloadbfs-2328d8dbb5a8c774afb99d363b6e98cd25ee304d.tar.xz
Handle ENOTDIR the same as ENOENT
For a/b/c, ENOTDIR is returned instead of ENOENT if a or b are not directories. Handle this uniformly when detecting broken symlinks, readdir races, etc.
Diffstat (limited to 'bftw.c')
-rw-r--r--bftw.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/bftw.c b/bftw.c
index 991176a..baf7e65 100644
--- a/bftw.c
+++ b/bftw.c
@@ -836,7 +836,7 @@ static void bftw_init_buffers(struct bftw_state *state, const struct dirent *de)
|| (ftwbuf->typeflag == BFTW_LNK && follow)
|| (ftwbuf->typeflag == BFTW_DIR && (detect_cycles || xdev))) {
int ret = ftwbuf_stat(ftwbuf, &state->statbuf);
- if (ret != 0 && follow && errno == ENOENT) {
+ if (ret != 0 && follow && (errno == ENOENT || errno == ENOTDIR)) {
// Could be a broken symlink, retry without following
ftwbuf->at_flags = AT_SYMLINK_NOFOLLOW;
ret = ftwbuf_stat(ftwbuf, &state->statbuf);