aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2014-08-05 19:41:36 -0500
committerRob Landley <rob@landley.net>2014-08-05 19:41:36 -0500
commit6804d2324ff2524cdf9ac013cb2b6b72c2295117 (patch)
tree19796a6891655f8893f3c3d5a24e8b95bf5ccdab
parent2c2eaba63fd42442453b1ad87fadc7d02532ea28 (diff)
downloadtoybox-6804d2324ff2524cdf9ac013cb2b6b72c2295117.tar.gz
find.c: Posix wants loop detection.
-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;