Date: Sun, 27 May 2007 07:09:55 GMT From: Ighighi<ighighi@gmail.com> To: freebsd-gnats-submit@FreeBSD.org Subject: bin/113049: [PATCH]: make quot(8) use getopt(3) and show usage() if no arguments Message-ID: <200705270709.l4R79tli065635@www.freebsd.org> Resent-Message-ID: <200705270710.l4R7A26s052996@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 113049 >Category: bin >Synopsis: [PATCH]: make quot(8) use getopt(3) and show usage() if no arguments >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Sun May 27 07:10:02 GMT 2007 >Closed-Date: >Last-Modified: >Originator: Ighighi >Release: 6.2-STABLE >Organization: >Environment: FreeBSD orion 6.2-STABLE FreeBSD 6.2-STABLE #0: Thu May 24 09:18:16 VET 2007 root@orion:/usr/obj/usr/src/sys/CUSTOM i386 >Description: This patch adds getopt(3) support for quot(8) and to display usage with no arguments present. >How-To-Repeat: >Fix: Patch attached with submission follows: --- src/usr.sbin/quot/quot.c.orig Sat Oct 14 23:28:54 2006 +++ src/usr.sbin/quot/quot.c Sun May 27 02:48:20 2007 @@ -616,42 +616,48 @@ char dev[MNAMELEN + 1]; char *nm; int cnt; + int ch; + + if (argc == 1) + usage(); 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 (all) { cnt = getmntinfo(&mp,MNT_NOWAIT); for (; --cnt >= 0; mp++) { >Release-Note: >Audit-Trail: >Unformatted:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200705270709.l4R79tli065635>