mirror of
https://git.FreeBSD.org/src.git
synced 2024-10-18 02:19:39 +00:00
quot: Use getopt(3) and show usage() if no arguments
Also update the man page and usage to be a little more accurate with the -a flag. Reviewed by: imp Pull Request: https://github.com/freebsd/freebsd-src/pull/983
This commit is contained in:
parent
8e05c2373e
commit
752a340419
@ -35,8 +35,8 @@
|
||||
.Nd display disk space occupied by each user
|
||||
.Sh SYNOPSIS
|
||||
.Nm
|
||||
.Op Fl acfhknv
|
||||
.Op Ar filesystem ...
|
||||
.Op Fl cfhknv
|
||||
.Op Fl a | Ar filesystem ...
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
.Nm
|
||||
|
@ -526,9 +526,9 @@ static void
|
||||
usage(void)
|
||||
{
|
||||
#ifdef COMPAT
|
||||
fprintf(stderr,"usage: quot [-nfcvha] [filesystem ...]\n");
|
||||
fprintf(stderr, "usage: quot [-cfhnv] [-a | filesystem ...]\n");
|
||||
#else /* COMPAT */
|
||||
fprintf(stderr,"usage: quot [-acfhknv] [filesystem ...]\n");
|
||||
fprintf(stderr, "usage: quot [-cfhknv] [-a | filesystem ...]\n");
|
||||
#endif /* COMPAT */
|
||||
exit(1);
|
||||
}
|
||||
@ -575,42 +575,47 @@ main(int argc, char *argv[])
|
||||
struct statfs *mp;
|
||||
struct fstab *fs;
|
||||
int cnt;
|
||||
int ch;
|
||||
|
||||
func = douser;
|
||||
#ifndef COMPAT
|
||||
header = getbsize(&headerlen,&blocksize);
|
||||
#endif
|
||||
while (--argc > 0 && **++argv == '-') {
|
||||
while (*++*argv) {
|
||||
switch (**argv) {
|
||||
case 'n':
|
||||
func = donames;
|
||||
break;
|
||||
case 'c':
|
||||
func = dofsizes;
|
||||
break;
|
||||
case 'a':
|
||||
all = 1;
|
||||
break;
|
||||
case 'f':
|
||||
count = 1;
|
||||
break;
|
||||
case 'h':
|
||||
estimate = 1;
|
||||
break;
|
||||
while ((ch = getopt(argc, argv, "acfhknv")) != -1) {
|
||||
switch (ch) {
|
||||
case 'a':
|
||||
all = 1;
|
||||
break;
|
||||
case 'c':
|
||||
func = dofsizes;
|
||||
break;
|
||||
case 'f':
|
||||
count = 1;
|
||||
break;
|
||||
case 'h':
|
||||
estimate = 1;
|
||||
break;
|
||||
#ifndef COMPAT
|
||||
case 'k':
|
||||
blocksize = 1024;
|
||||
break;
|
||||
case 'k':
|
||||
blocksize = 1024;
|
||||
break;
|
||||
#endif /* COMPAT */
|
||||
case 'v':
|
||||
unused = 1;
|
||||
break;
|
||||
default:
|
||||
usage();
|
||||
}
|
||||
case 'n':
|
||||
func = donames;
|
||||
break;
|
||||
case 'v':
|
||||
unused = 1;
|
||||
break;
|
||||
default:
|
||||
usage();
|
||||
}
|
||||
}
|
||||
argc -= optind;
|
||||
argv += optind;
|
||||
|
||||
if ((argc == 0 && !all) || (all && argc))
|
||||
usage();
|
||||
|
||||
if (all) {
|
||||
cnt = getmntinfo(&mp,MNT_NOWAIT);
|
||||
for (; --cnt >= 0; mp++) {
|
||||
|
Loading…
Reference in New Issue
Block a user