Fix a few compiler warnings, sort options and make the usage()

output match the synopsis.
This commit is contained in:
Ian Dowse 2002-08-09 00:43:36 +00:00
parent 06ec58b740
commit e608ec61bd
2 changed files with 29 additions and 27 deletions

View File

@ -43,17 +43,16 @@
.Nd display disk usage and limits .Nd display disk usage and limits
.Sh SYNOPSIS .Sh SYNOPSIS
.Nm .Nm
.Op Fl g .Op Fl gu
.Op Fl u
.Op Fl v | Fl q .Op Fl v | Fl q
.Nm .Nm
.Op Fl u .Op Fl u
.Op Fl v | Fl q .Op Fl v | Fl q
.Ar user .Ar user ...
.Nm .Nm
.Op Fl g .Fl g
.Op Fl v | Fl q .Op Fl v | Fl q
.Ar group .Ar group ...
.Sh DESCRIPTION .Sh DESCRIPTION
The The
.Nm .Nm
@ -65,16 +64,18 @@ The following options are available:
.It Fl g .It Fl g
Print group quotas for the group Print group quotas for the group
of which the user is a member. of which the user is a member.
The optional
.Fl u
flag is equivalent to the default.
.It Fl v
Display quotas on filesystems
where no storage is allocated.
.It Fl q .It Fl q
Print a more terse message, Print a more terse message,
containing only information containing only information
on filesystems where usage is over quota. on filesystems where usage is over quota.
.It Fl u
Print the user quotas.
This is the default unless
.Fl g
is specified.
.It Fl v
Display quotas on filesystems
where no storage is allocated.
.El .El
.Pp .Pp
Specifying both Specifying both

View File

@ -116,20 +116,20 @@ main(int argc, char *argv[])
int i, gflag = 0, uflag = 0; int i, gflag = 0, uflag = 0;
char ch; char ch;
while ((ch = getopt(argc, argv, "ugvq")) != -1) { while ((ch = getopt(argc, argv, "gquv")) != -1) {
switch(ch) { switch(ch) {
case 'g': case 'g':
gflag++; gflag++;
break; break;
case 'q':
qflag++;
break;
case 'u': case 'u':
uflag++; uflag++;
break; break;
case 'v': case 'v':
vflag++; vflag++;
break; break;
case 'q':
qflag++;
break;
default: default:
usage(); usage();
} }
@ -180,9 +180,9 @@ usage(void)
{ {
fprintf(stderr, "%s\n%s\n%s\n", fprintf(stderr, "%s\n%s\n%s\n",
"usage: quota [-guqv]", "usage: quota [-gu] [-v | -q]",
" quota [-qv] -u username ...", " quota [-u] [-v | -q] user ...",
" quota [-qv] -g groupname ..."); " quota -g [-v | -q] group ...");
exit(1); exit(1);
} }
@ -371,10 +371,10 @@ showquotas(int type, u_long id, const char *name)
, (msgb == (char *)0) ? "" , (msgb == (char *)0) ? ""
:timeprt(qup->dqblk.dqb_btime)); :timeprt(qup->dqblk.dqb_btime));
printf("%8lu%c%7lu%8lu%8s\n" printf("%8lu%c%7lu%8lu%8s\n"
, qup->dqblk.dqb_curinodes , (u_long)qup->dqblk.dqb_curinodes
, (msgi == (char *)0) ? ' ' : '*' , (msgi == (char *)0) ? ' ' : '*'
, qup->dqblk.dqb_isoftlimit , (u_long)qup->dqblk.dqb_isoftlimit
, qup->dqblk.dqb_ihardlimit , (u_long)qup->dqblk.dqb_ihardlimit
, (msgi == (char *)0) ? "" , (msgi == (char *)0) ? ""
: timeprt(qup->dqblk.dqb_itime) : timeprt(qup->dqblk.dqb_itime)
); );
@ -424,14 +424,15 @@ timeprt(time_t seconds)
minutes = (seconds + 30) / 60; minutes = (seconds + 30) / 60;
hours = (minutes + 30) / 60; hours = (minutes + 30) / 60;
if (hours >= 36) { if (hours >= 36) {
sprintf(buf, "%lddays", (hours + 12) / 24); sprintf(buf, "%lddays", ((long)hours + 12) / 24);
return (buf); return (buf);
} }
if (minutes >= 60) { if (minutes >= 60) {
sprintf(buf, "%2ld:%ld", minutes / 60, minutes % 60); sprintf(buf, "%2ld:%ld", (long)minutes / 60,
(long)minutes % 60);
return (buf); return (buf);
} }
sprintf(buf, "%2ld", minutes); sprintf(buf, "%2ld", (long)minutes);
return (buf); return (buf);
} }
@ -441,7 +442,7 @@ timeprt(time_t seconds)
static struct quotause * static struct quotause *
getprivs(long id, int quotatype) getprivs(long id, int quotatype)
{ {
struct quotause *qup, *quptail; struct quotause *qup, *quptail = NULL;
struct fstab *fs; struct fstab *fs;
struct quotause *quphead; struct quotause *quphead;
struct statfs *fst; struct statfs *fst;
@ -607,8 +608,8 @@ getnfsquota(struct statfs *fst, struct quotause *qup, long id, int quotatype)
gq_args.gqa_pathp = cp + 1; gq_args.gqa_pathp = cp + 1;
gq_args.gqa_uid = id; gq_args.gqa_uid = id;
if (callaurpc(fst->f_mntfromname, RQUOTAPROG, RQUOTAVERS, if (callaurpc(fst->f_mntfromname, RQUOTAPROG, RQUOTAVERS,
RQUOTAPROC_GETQUOTA, xdr_getquota_args, (char *)&gq_args, RQUOTAPROC_GETQUOTA, (xdrproc_t)xdr_getquota_args, (char *)&gq_args,
xdr_getquota_rslt, (char *)&gq_rslt) != 0) { (xdrproc_t)xdr_getquota_rslt, (char *)&gq_rslt) != 0) {
*cp = ':'; *cp = ':';
return (0); return (0);
} }