Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 20 Apr 2001 18:37:49 +0200
From:      Joachim =?iso-8859-1?Q?Str=F6mbergson?= <watchman@ludd.luth.se>
To:        FreeBSD-Audit <audit@FreeBSD.ORG>
Subject:   New du functionality by newbie - audit and comments?
Message-ID:  <3AE065DD.D8FEF0B@ludd.luth.se>

next in thread | raw e-mail | index | archive | help
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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3AE065DD.D8FEF0B>