summaryrefslogtreecommitdiffstats
path: root/src/eval.c
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2024-05-27 13:37:49 -0400
committerTavian Barnes <tavianator@tavianator.com>2024-05-27 14:04:39 -0400
commitf095481862ccd175d297da67d0e313d135bd75c3 (patch)
treea98a6c1bce4e0eed3c844794b882707b5bc7396d /src/eval.c
parent92a4f07352c6afd7b02785f94249daa2ad693bdd (diff)
downloadbfs-f095481862ccd175d297da67d0e313d135bd75c3.tar.xz
eval: Print more information on filesystem loops
Diffstat (limited to 'src/eval.c')
-rw-r--r--src/eval.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/src/eval.c b/src/eval.c
index 8490bd4..36b2f11 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -1433,10 +1433,20 @@ static enum bftw_action eval_callback(const struct BFTW *ftwbuf, void *ptr) {
}
if (ftwbuf->type == BFS_ERROR) {
- if (!eval_should_ignore(&state, ftwbuf->error)) {
- eval_error(&state, "%s.\n", xstrerror(ftwbuf->error));
- }
state.action = BFTW_PRUNE;
+
+ if (ftwbuf->error == ELOOP && ftwbuf->loopoff > 0) {
+ char *loop = strndup(ftwbuf->path, ftwbuf->loopoff);
+ if (loop) {
+ eval_error(&state, "Filesystem loop back to ${di}%pq${rs}\n", loop);
+ free(loop);
+ goto done;
+ }
+ } else if (eval_should_ignore(&state, ftwbuf->error)) {
+ goto done;
+ }
+
+ eval_error(&state, "%s.\n", xstrerror(ftwbuf->error));
goto done;
}