Add support for a -n argument which displays user and group IDs

numerically rather than converting to a user or group name.

MFC After: 1 week
This commit is contained in:
Brooks Davis 2003-07-07 21:41:23 +00:00
parent e14eb5a118
commit 974ac91938
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=117318
2 changed files with 14 additions and 5 deletions

View File

@ -44,11 +44,13 @@
.Sh SYNOPSIS
.Nm
.Op Fl g
.Op Fl n
.Op Fl u
.Op Fl v
.Ar filesystem Ar ...
.Nm
.Op Fl g
.Op Fl n
.Op Fl u
.Op Fl v
.Fl a
@ -66,6 +68,9 @@ Print the quotas of all the file systems listed in
.It Fl g
Print only group quotas (the default is to print both
group and user quotas if they exist).
.It Fl n
Display user and group IDs numerically rather than converting to
a user or group name.
.It Fl u
Print only user quotas (the default is to print both
group and user quotas if they exist).

View File

@ -96,6 +96,7 @@ u_long highid[MAXQUOTAS]; /* highest addid()'ed identifier per type */
int vflag; /* verbose */
int aflag; /* all filesystems */
int nflag; /* display user/group by id */
int hasquota(struct fstab *, int, char **);
int oneof(char *, char *[], int);
@ -113,7 +114,7 @@ main(int argc, char **argv)
long i, argnum, done = 0;
char ch, *qfnp;
while ((ch = getopt(argc, argv, "aguv")) != -1) {
while ((ch = getopt(argc, argv, "agnuv")) != -1) {
switch(ch) {
case 'a':
aflag++;
@ -121,6 +122,9 @@ main(int argc, char **argv)
case 'g':
gflag++;
break;
case 'n':
nflag++;
break;
case 'u':
uflag++;
break;
@ -140,13 +144,13 @@ main(int argc, char **argv)
gflag++;
uflag++;
}
if (gflag) {
if (gflag && !nflag) {
setgrent();
while ((gr = getgrent()) != 0)
(void) addid((u_long)gr->gr_gid, GRPQUOTA, gr->gr_name);
endgrent();
}
if (uflag) {
if (uflag && !nflag) {
setpwent();
while ((pw = getpwent()) != 0)
(void) addid((u_long)pw->pw_uid, USRQUOTA, pw->pw_name);
@ -183,8 +187,8 @@ static void
usage()
{
fprintf(stderr, "%s\n%s\n",
"usage: repquota [-v] [-g] [-u] -a",
" repquota [-v] [-g] [-u] filesystem ...");
"usage: repquota [-v] [-g] [-n] [-u] -a",
" repquota [-v] [-g] [-n] [-u] filesystem ...");
exit(1);
}