diff options
Diffstat (limited to 'toys/posix')
-rw-r--r-- | toys/posix/ls.c | 23 |
1 files changed, 2 insertions, 21 deletions
diff --git a/toys/posix/ls.c b/toys/posix/ls.c index 5982adfe..76fb7947 100644 --- a/toys/posix/ls.c +++ b/toys/posix/ls.c @@ -335,28 +335,9 @@ static void listfiles(int dirfd, struct dirtree *indir) if (flags & (FLAG_l|FLAG_o|FLAG_n|FLAG_g)) { struct tm *tm; - char perm[11], thyme[64], c, d, *usr, *upad, *grp, *grpad; - int i, bit; - - perm[10]=0; - for (i=0; i<9; i++) { - bit = mode & (1<<i); - c = i%3; - if (!c && (mode & (1<<((d=i/3)+9)))) { - c = "tss"[d]; - if (!bit) c &= ~0x20; - } else c = bit ? "xwr"[c] : '-'; - perm[9-i] = c; - } + char perm[11], thyme[64], *usr, *upad, *grp, *grpad; - if (S_ISDIR(mode)) c = 'd'; - else if (S_ISBLK(mode)) c = 'b'; - else if (S_ISCHR(mode)) c = 'c'; - else if (S_ISLNK(mode)) c = 'l'; - else if (S_ISFIFO(mode)) c = 'p'; - else if (S_ISSOCK(mode)) c = 's'; - else c = '-'; - *perm = c; + format_mode(&perm, mode); tm = localtime(&(st->st_mtime)); strftime(thyme, sizeof(thyme), "%F %H:%M", tm); |