aboutsummaryrefslogtreecommitdiffstats
path: root/toolbox/ls.c
diff options
context:
space:
mode:
authorAndy McFadden <>2009-04-08 19:25:35 -0700
committerThe Android Open Source Project <initial-contribution@android.com>2009-04-08 19:25:35 -0700
commitb33d3415b6c63f7b22e0863a2ac594feab9171cf (patch)
treec37e6229cd401d30d1ef14e7470c85af69183aba /toolbox/ls.c
parent89efdc9c7f4005032dad86dd6dd220c23a7ff4d7 (diff)
downloadsystem_core-b33d3415b6c63f7b22e0863a2ac594feab9171cf.tar.gz
system_core-b33d3415b6c63f7b22e0863a2ac594feab9171cf.tar.bz2
system_core-b33d3415b6c63f7b22e0863a2ac594feab9171cf.zip
AI 145220: Added "-d" flag to ls.
Now you can "ls -l -d <directory>" to see directory perms. Automated import of CL 145220
Diffstat (limited to 'toolbox/ls.c')
-rw-r--r--toolbox/ls.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/toolbox/ls.c b/toolbox/ls.c
index f609df21..087e4d5e 100644
--- a/toolbox/ls.c
+++ b/toolbox/ls.c
@@ -15,9 +15,10 @@
#include <linux/kdev_t.h>
// bits for flags argument
-#define LIST_LONG (1 << 0)
-#define LIST_ALL (1 << 1)
-#define LIST_RECURSIVE (1 << 2)
+#define LIST_LONG (1 << 0)
+#define LIST_ALL (1 << 1)
+#define LIST_RECURSIVE (1 << 2)
+#define LIST_DIRECTORIES (1 << 3)
// fwd
static int listpath(const char *name, int flags);
@@ -238,7 +239,7 @@ static int listpath(const char *name, int flags)
return -1;
}
- if (S_ISDIR(s.st_mode)) {
+ if ((flags & LIST_DIRECTORIES) == 0 && S_ISDIR(s.st_mode)) {
if (flags & LIST_RECURSIVE)
printf("\n%s:\n", name);
return listdir(name, flags);
@@ -269,6 +270,8 @@ int ls_main(int argc, char **argv)
flags |= LIST_ALL;
} else if (!strcmp(argv[i], "-R")) {
flags |= LIST_RECURSIVE;
+ } else if (!strcmp(argv[i], "-d")) {
+ flags |= LIST_DIRECTORIES;
} else {
listed++;
if(listpath(argv[i], flags) != 0) {