Module Name: src
Committed By: bouyer
Date: Sat Mar 5 19:05:29 UTC 2011
Modified Files:
src/usr.sbin/repquota [bouyer-quota2]: repquota.c
Log Message:
Report user or group name again instead of uid/gid.
To generate a diff of this commit:
cvs rdiff -u -r1.25.2.10 -r1.25.2.11 src/usr.sbin/repquota/repquota.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/usr.sbin/repquota/repquota.c
diff -u src/usr.sbin/repquota/repquota.c:1.25.2.10 src/usr.sbin/repquota/repquota.c:1.25.2.11
--- src/usr.sbin/repquota/repquota.c:1.25.2.10 Sat Mar 5 18:53:00 2011
+++ src/usr.sbin/repquota/repquota.c Sat Mar 5 19:05:29 2011
@@ -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