Mercurial > hg > toybox
changeset 1424:c95588a2b7a2 draft
find.c: Posix wants loop detection.
author | Rob Landley <rob@landley.net> |
---|---|
date | Tue, 05 Aug 2014 19:41:36 -0500 |
parents | 8059cfd67acd |
children | 2cf6ce96d442 |
files | toys/posix/find.c |
diffstat | 1 files changed, 10 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/toys/posix/find.c Tue Aug 05 19:32:44 2014 -0500 +++ b/toys/posix/find.c Tue Aug 05 19:41:36 2014 -0500 @@ -189,7 +189,17 @@ } 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;