From 2328d8dbb5a8c774afb99d363b6e98cd25ee304d Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Sun, 9 Jul 2017 16:35:38 -0400 Subject: 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. --- bftw.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'bftw.c') 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); -- cgit v1.2.3