summaryrefslogtreecommitdiffstats
path: root/commands
diff options
context:
space:
mode:
authorAhmad Fatoum <a.fatoum@pengutronix.de>2020-09-14 15:37:45 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2020-09-14 16:11:36 +0200
commitb81ff979a72b427ce4fc4c00c8aab2a302af41a8 (patch)
tree45c3557c2b0bdd283c8f1aff3d099ddebf500f4b /commands
parent74d78a1e4a47c322d348823b2836614b531cda8b (diff)
downloadbarebox-b81ff979a72b427ce4fc4c00c8aab2a302af41a8.tar.gz
barebox-b81ff979a72b427ce4fc4c00c8aab2a302af41a8.tar.xz
ls: don't print . and .. on recursive ls
They are already omitted on normal ls and they don't really add a new information, so drop them for the recursive case as well. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'commands')
-rw-r--r--commands/ls.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/commands/ls.c b/commands/ls.c
index 6a5475d094..59163f678d 100644
--- a/commands/ls.c
+++ b/commands/ls.c
@@ -75,8 +75,13 @@ int ls(const char *path, ulong flags)
if (!dir)
return -errno;
- while ((d = readdir(dir)))
+ while ((d = readdir(dir))) {
+ if (!strcmp(d->d_name, "."))
+ continue;
+ if (!strcmp(d->d_name, ".."))
+ continue;
string_list_add_sorted(&sl, d->d_name);
+ }
closedir(dir);
@@ -99,10 +104,6 @@ int ls(const char *path, ulong flags)
goto out;
string_list_for_each_entry(entry, &sl) {
- if (!strcmp(entry->str, "."))
- continue;
- if (!strcmp(entry->str, ".."))
- continue;
sprintf(tmp, "%s/%s", path, entry->str);
ret = lstat(tmp, &s);