[PATCH 2/5] ls: don't print . and .. on recursive ls
Ahmad Fatoum
a.fatoum at pengutronix.de
Mon Sep 14 09:37:45 EDT 2020
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 at pengutronix.de>
---
commands/ls.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/commands/ls.c b/commands/ls.c
index 6a5475d094e5..59163f678d51 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);
--
2.28.0
More information about the barebox
mailing list