aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--toys/posix/find.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/toys/posix/find.c b/toys/posix/find.c
index b1aa6845..0ea5271e 100644
--- a/toys/posix/find.c
+++ b/toys/posix/find.c
@@ -189,7 +189,17 @@ static int do_find(struct dirtree *new)
}
if (S_ISDIR(new->st.st_mode)) {
if (!new->again) {
+ struct dirtree *n;
+
if (TT.depth) return recurse;
+ for (n = new->parent; n; n = n->parent) {
+ if (n->st.st_ino==new->st.st_ino && n->st.st_dev==new->st.st_dev) {
+ error_msg("'%s': loop detected", s = dirtree_path(new, 0));
+ free(s);
+
+ return 0;
+ }
+ }
} else {
struct double_list *dl;