aboutsummaryrefslogtreecommitdiff
path: root/toys
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
parent9cfdb48722cba8bfaafee9de61411618d66365f3 (diff)
downloadtoybox-b602f1c1513328fe91f70233c78d11d9e638982d.tar.gz
Add bufgetgrgid()
Diffstat (limited to 'toys')
-rw-r--r--toys/posix/find.c4
-rw-r--r--toys/posix/ls.c12
-rw-r--r--toys/posix/ps.c2
3 files changed, 8 insertions, 10 deletions
diff --git a/toys/posix/find.c b/toys/posix/find.c
index 3b27225d..189773c3 100644
--- a/toys/posix/find.c
+++ b/toys/posix/find.c
@@ -303,9 +303,9 @@ static int do_find(struct dirtree *new)
if (check) do_print(new, s[5] ? 0 : '\n');
} else if (!strcmp(s, "nouser")) {
- if (check) if (getpwuid(new->st.st_uid)) test = 0;
+ if (check) if (bufgetpwuid(new->st.st_uid)) test = 0;
} else if (!strcmp(s, "nogroup")) {
- if (check) if (getgrgid(new->st.st_gid)) test = 0;
+ if (check) if (bufgetgrgid(new->st.st_gid)) test = 0;
} else if (!strcmp(s, "prune")) {
if (check && S_ISDIR(new->st.st_mode) && !TT.depth) recurse = 0;
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
diff --git a/toys/posix/ps.c b/toys/posix/ps.c
index 445228fd..301c1f36 100644
--- a/toys/posix/ps.c
+++ b/toys/posix/ps.c
@@ -449,7 +449,7 @@ static char *string_field(struct carveup *tb, struct strawberry *field)
sprintf(out, "%lld", ll);
if (sl&64) {
if (which > PS_RUSER) {
- struct group *gr = getgrgid(ll);
+ struct group *gr = bufgetgrgid(ll);
if (gr) out = gr->gr_name;
} else {