summaryrefslogtreecommitdiffstats
path: root/eval.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 /eval.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 'eval.c')
-rw-r--r--eval.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/eval.c b/eval.c
index 90b854e..daee9d6 100644
--- a/eval.c
+++ b/eval.c
@@ -51,7 +51,7 @@ struct eval_state {
*/
static bool eval_should_ignore(const struct eval_state *state, int error) {
return state->cmdline->ignore_races
- && error == ENOENT
+ && (error == ENOENT || errno == ENOTDIR)
&& state->ftwbuf->depth > 0;
}
@@ -788,7 +788,7 @@ bool eval_xtype(const struct expr *expr, struct eval_state *state) {
struct stat sb;
if (fstatat(ftwbuf->at_fd, ftwbuf->at_path, &sb, at_flags) != 0) {
- if (!follow && errno == ENOENT) {
+ if (!follow && (errno == ENOENT || errno == ENOTDIR)) {
// Broken symlink
return eval_type(expr, state);
} else {