aboutsummaryrefslogtreecommitdiff
path: root/toys/posix/ls.c
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2015-05-18 13:33:36 -0500
committerRob Landley <rob@landley.net>2015-05-18 13:33:36 -0500
commita8ee470ae3361bb8e6e364f0e8adf61259371e95 (patch)
tree07c7a1de0d5c1382362cae92f5c120311eeee411 /toys/posix/ls.c
parentc565b06325960a16ebf44afd8ae73f363775e58d (diff)
downloadtoybox-a8ee470ae3361bb8e6e364f0e8adf61259371e95.tar.gz
Recent commit broke ls -R (test reversed), and "ls -R singledir" should
show label: at the start (yes, even "ls -R" in an empty dir).
Diffstat (limited to 'toys/posix/ls.c')
-rw-r--r--toys/posix/ls.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/toys/posix/ls.c b/toys/posix/ls.c
index ae0466bf..c140d979 100644
--- a/toys/posix/ls.c
+++ b/toys/posix/ls.c
@@ -289,7 +289,7 @@ static void listfiles(int dirfd, struct dirtree *indir)
// Silently descend into single directory listed by itself on command line.
// In this case only show dirname/total header when given -R.
dt = indir->child;
- if (S_ISDIR(dt->st.st_mode) && !dt->next && !(flags & FLAG_d)) {
+ if (S_ISDIR(dt->st.st_mode) && !dt->next && !(flags&(FLAG_d|FLAG_R))) {
listfiles(open(dt->name, 0), TT.singledir = dt);
return;
@@ -480,8 +480,9 @@ static void listfiles(int dirfd, struct dirtree *indir)
if ((flags & FLAG_d) || !S_ISDIR(sort[ul]->st.st_mode)) continue;
// Recurse into dirs if at top of the tree or given -R
- if (!indir->parent || ((flags&FLAG_R) && !dirtree_notdotdot(sort[ul])))
+ if (!indir->parent || ((flags&FLAG_R) && dirtree_notdotdot(sort[ul])))
listfiles(openat(dirfd, sort[ul]->name, 0), sort[ul]);
+ free((void *)sort[ul]->extra);
}
free(sort);
if (dirfd != AT_FDCWD) close(dirfd);