From owner-freebsd-audit Fri Apr 20 9:38:30 2001 Delivered-To: freebsd-audit@freebsd.org Received: from mailf.telia.com (mailf.telia.com [194.22.194.25]) by hub.freebsd.org (Postfix) with ESMTP id C4C3737B621 for ; Fri, 20 Apr 2001 09:38:16 -0700 (PDT) (envelope-from watchman@ludd.luth.se) Received: from d1o907.telia.com (d1o907.telia.com [195.252.38.241]) by mailf.telia.com (8.11.2/8.11.0) with ESMTP id f3KGcEp17886 for ; Fri, 20 Apr 2001 18:38:14 +0200 (CEST) Received: from ludd.luth.se (h63n2fls21o907.telia.com [213.66.203.63]) by d1o907.telia.com (8.8.8/8.8.8) with ESMTP id SAA21471 for ; Fri, 20 Apr 2001 18:38:13 +0200 (CEST) Message-ID: <3AE065DD.D8FEF0B@ludd.luth.se> Date: Fri, 20 Apr 2001 18:37:49 +0200 From: Joachim =?iso-8859-1?Q?Str=F6mbergson?= Organization: Acne X-Mailer: Mozilla 4.76 [en] (X11; U; FreeBSD 4.3-RC i386) X-Accept-Language: en-US MIME-Version: 1.0 To: FreeBSD-Audit Subject: New du functionality by newbie - audit and comments? Content-Type: multipart/mixed; boundary="------------0FA2C1064A487E34BCE49AFC" Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG This is a multi-part message in MIME format. --------------0FA2C1064A487E34BCE49AFC Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Aloha! I'm slowly trying to learn the skills needed to start contributing back to the FreeBSD. And this I guess is my first real shot at it! .-) I have for some time missed the ability in the default du to turn off the interim output, and simply get a grand total at the end. Right or wrong I decided to add this to the du myself. I have done preliminary testing on the system, and AFAIK it works as intended. Also, some preliminary benchmarks (measuring run times repeated runs on fairly large parts of the file system) suggests that you do gain a bit performane by using my silent option (very unsurprising, since I'm turning off a lot of output) The option added is called Silent mode and the flag currently choosen is -S. A unified diff is included with this mail. Any comments, checks and or suggestions would be appreciated. Any possiblilty that a thing like this could/would be added to the system in due time? -- Cheers! Joachim - Alltid i harmonisk svängning --- FairLight ------ FairLight ------ FairLight ------ FairLight --- Joachim Strömbergson ASIC SoC designer, nice to CUTE animals Phone: +46(0)31 - 27 98 47 Web: http://www.ludd.luth.se/~watchman --------------- Spamfodder: regeringen@regeringen.se --------------- --------------0FA2C1064A487E34BCE49AFC Content-Type: text/plain; charset=us-ascii; name="du.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="du.diff" --- du.c Fri Apr 20 18:11:01 2001 +++ /usr/src/usr.bin/du/du.c Fri Apr 20 18:02:32 2001 @@ -105,19 +105,17 @@ int listall; int depth; int Hflag, Lflag, Pflag, aflag, sflag, dflag, cflag, hflag, ch, notused, rval; - int silentflag; char **save; Hflag = Lflag = Pflag = aflag = sflag = dflag = cflag = hflag = 0; - silentflag = 0; - + save = argv; ftsoptions = 0; depth = INT_MAX; - while ((ch = getopt(argc, argv, "HLPSasd:chkrx")) != -1) + while ((ch = getopt(argc, argv, "HLPasd:chkrx")) != -1) switch (ch) { - case 'H': + case 'H': Hflag = 1; break; case 'L': @@ -125,16 +123,12 @@ usage(); Lflag = 1; break; - case 'P': + case 'P': if (Lflag) usage(); Pflag = 1; break; - case 'S': - silentflag = 1; - cflag = 1; - break; - case 'a': + case 'a': aflag = 1; break; case 's': @@ -238,15 +232,11 @@ if (p->fts_level <= depth) { if (hflag) { (void) prthumanval(howmany(p->fts_number, blocksize)); - if (!silentflag) { - (void) printf("\t%s\n", p->fts_path); - } + (void) printf("\t%s\n", p->fts_path); } else { - if (!silentflag) { (void) printf("%ld\t%s\n", howmany(p->fts_number, blocksize), p->fts_path); - } } } break; @@ -266,17 +256,11 @@ if (hflag) { (void) prthumanval(howmany(p->fts_statp->st_blocks, blocksize)); - - if (!silentflag) { (void) printf("\t%s\n", p->fts_path); - } - } else { - if (!silentflag) { (void) printf("%qd\t%s\n", howmany(p->fts_statp->st_blocks, blocksize), p->fts_path); - } } } @@ -349,7 +333,6 @@ abval = fabs(*val); - unit_sz = abval ? ilogb(abval) / 10 : 0; if (unit_sz >= UNIT_MAX) { @@ -383,6 +366,6 @@ usage() { (void)fprintf(stderr, - "usage: du [-H | -L | -P | -S] [-a | -s | -d depth] [-c] [-h | -k] [-x] [file ...]\n"); + "usage: du [-H | -L | -P] [-a | -s | -d depth] [-c] [-h | -k] [-x] [file ...]\n"); exit(EX_USAGE); } --------------0FA2C1064A487E34BCE49AFC-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message