summaryrefslogtreecommitdiffstats
path: root/toolbox
diff options
context:
space:
mode:
authorBrad Fitzpatrick <bradfitz@android.com>2010-10-25 13:29:53 -0700
committerBrad Fitzpatrick <bradfitz@android.com>2010-10-25 13:30:41 -0700
commite7fe5bf3ac2c0218bda75da78975d6a18fe7c167 (patch)
tree222c1cf06b5f8337837d7190a8208ffe29bc701f /toolbox
parent98b1378606780c28501708ca02560c82bb1fda53 (diff)
downloadsystem_core-e7fe5bf3ac2c0218bda75da78975d6a18fe7c167.zip
system_core-e7fe5bf3ac2c0218bda75da78975d6a18fe7c167.tar.gz
system_core-e7fe5bf3ac2c0218bda75da78975d6a18fe7c167.tar.bz2
Add ls -n to toolbox.
Change-Id: I641f9504554d14fb1289ac470e6e61c5bc12e9c7
Diffstat (limited to 'toolbox')
-rw-r--r--toolbox/ls.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/toolbox/ls.c b/toolbox/ls.c
index 962bf47..daa8095 100644
--- a/toolbox/ls.c
+++ b/toolbox/ls.c
@@ -144,6 +144,7 @@ static void strlist_sort( strlist_t *list )
#define LIST_RECURSIVE (1 << 2)
#define LIST_DIRECTORIES (1 << 3)
#define LIST_SIZE (1 << 4)
+#define LIST_LONG_NUMERIC (1 << 5)
// fwd
static int listpath(const char *name, int flags);
@@ -279,8 +280,13 @@ static int listfile_long(const char *path, int flags)
}
mode2str(s.st_mode, mode);
- user2str(s.st_uid, user);
- group2str(s.st_gid, group);
+ if (flags & LIST_LONG_NUMERIC) {
+ sprintf(user, "%ld", s.st_uid);
+ sprintf(group, "%ld", s.st_gid);
+ } else {
+ user2str(s.st_uid, user);
+ group2str(s.st_gid, group);
+ }
strftime(date, 32, "%Y-%m-%d %H:%M", localtime((const time_t*)&s.st_mtime));
date[31] = 0;
@@ -476,6 +482,7 @@ int ls_main(int argc, char **argv)
while (arg[0]) {
switch (arg[0]) {
case 'l': flags |= LIST_LONG; break;
+ case 'n': flags |= LIST_LONG | LIST_LONG_NUMERIC; break;
case 's': flags |= LIST_SIZE; break;
case 'R': flags |= LIST_RECURSIVE; break;
case 'd': flags |= LIST_DIRECTORIES; break;