Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/bouyer-quota2]: src/usr.sbin/repquota Report user or group name again in...
details: https://anonhg.NetBSD.org/src/rev/cba65110f838
branches: bouyer-quota2
changeset: 761195:cba65110f838
user: bouyer <bouyer%NetBSD.org@localhost>
date: Sat Mar 05 19:05:29 2011 +0000
description:
Report user or group name again instead of uid/gid.
diffstat:
usr.sbin/repquota/repquota.c | 38 +++++++++++++++++++++++++++++++++-----
1 files changed, 33 insertions(+), 5 deletions(-)
diffs (75 lines):
diff -r 451f35b5653a -r cba65110f838 usr.sbin/repquota/repquota.c
--- a/usr.sbin/repquota/repquota.c Sat Mar 05 18:54:47 2011 +0000
+++ b/usr.sbin/repquota/repquota.c Sat Mar 05 19:05:29 2011 +0000
@@ -40,7 +40,7 @@
#if 0
static char sccsid[] = "@(#)repquota.c 8.2 (Berkeley) 11/22/94";
#else
-__RCSID("$NetBSD: repquota.c,v 1.25.2.10 2011/03/05 18:53:00 bouyer Exp $");
+__RCSID("$NetBSD: repquota.c,v 1.25.2.11 2011/03/05 19:05:29 bouyer Exp $");
#endif
#endif /* not lint */
@@ -397,19 +397,26 @@
char overchar[N_QL];
static time_t now;
- if (type == GRPQUOTA) {
+ switch(type) {
+ case GRPQUOTA:
+ {
struct group *gr;
setgrent();
while ((gr = getgrent()) != 0)
(void) addid((u_long)gr->gr_gid, GRPQUOTA, gr->gr_name);
endgrent();
- } else if (type == USRQUOTA) {
+ break;
+ }
+ case USRQUOTA:
+ {
struct passwd *pw;
setpwent();
while ((pw = getpwent()) != 0)
(void) addid((u_long)pw->pw_uid, USRQUOTA, pw->pw_name);
endpwent();
- } else {
+ break;
+ }
+ default:
errx(1, "unknown quota type %d\n", type);
}
@@ -637,10 +644,31 @@
const char *name;
{
struct fileusage *fup, **fhp;
+ struct group *gr = NULL;
+ struct passwd *pw = NULL;
int len;
- if ((fup = lookup(id, type)) != NULL)
+ if ((fup = lookup(id, type)) != NULL) {
return (fup);
+ }
+ if (name == NULL) {
+ switch(type) {
+ case GRPQUOTA:
+ gr = getgrgid(id);
+
+ if (gr != NULL)
+ name = gr->gr_name;
+ break;
+ case USRQUOTA:
+ pw = getpwuid(id);
+ if (pw)
+ name = pw->pw_name;
+ break;
+ default:
+ errx(1, "unknown quota type %d\n", type);
+ }
+ }
+
if (name)
len = strlen(name);
else
Home |
Main Index |
Thread Index |
Old Index