aboutsummaryrefslogtreecommitdiff
path: root/toys/posix/ls.c
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2016-05-20 14:28:13 -0500
committerRob Landley <rob@landley.net>2016-05-20 14:28:13 -0500
commitb602f1c1513328fe91f70233c78d11d9e638982d (patch)
treedd0b209caa1d5027f56bccf2b8364cabbfa20570 /toys/posix/ls.c
parent9cfdb48722cba8bfaafee9de61411618d66365f3 (diff)
downloadtoybox-b602f1c1513328fe91f70233c78d11d9e638982d.tar.gz
Add bufgetgrgid()
Diffstat (limited to 'toys/posix/ls.c')
-rw-r--r--toys/posix/ls.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/toys/posix/ls.c b/toys/posix/ls.c
index 2ebc062a..3ad28da4 100644
--- a/toys/posix/ls.c
+++ b/toys/posix/ls.c
@@ -123,7 +123,7 @@ static char endtype(struct stat *st)
static char *getusername(uid_t uid)
{
- struct passwd *pw = getpwuid(uid);
+ struct passwd *pw = bufgetpwuid(uid);
sprintf(TT.uid_buf, "%u", (unsigned)uid);
return pw ? pw->pw_name : TT.uid_buf;
@@ -131,7 +131,7 @@ static char *getusername(uid_t uid)
static char *getgroupname(gid_t gid)
{
- struct group *gr = getgrgid(gid);
+ struct group *gr = bufgetgrgid(gid);
sprintf(TT.gid_buf, "%u", (unsigned)gid);
return gr ? gr->gr_name : TT.gid_buf;
@@ -334,12 +334,10 @@ static void listfiles(int dirfd, struct dirtree *indir)
// Do preprocessing (Dirtree didn't populate, so callback wasn't called.)
for (;dt; dt = dt->next) filter(dt);
if (flags == (FLAG_1|FLAG_f)) return;
- } else {
- // Read directory contents. We dup() the fd because this will close it.
- // This reads/saves contents to display later, except for in "ls -1f" mode.
- dirtree_recurse(indir, filter, dup(dirfd),
+ // Read directory contents. We dup() the fd because this will close it.
+ // This reads/saves contents to display later, except for in "ls -1f" mode.
+ } else dirtree_recurse(indir, filter, dup(dirfd),
DIRTREE_SYMFOLLOW*!!(flags&FLAG_L));
- }
// Copy linked list to array and sort it. Directories go in array because
// we visit them in sorted order too. (The nested loops let us measure and