bin/144192: commit references a PR

dfilter service dfilter at FreeBSD.ORG
Sun Jun 20 08:30:05 UTC 2010


The following reply was made to PR bin/144192; it has been noted by GNATS.

From: dfilter at FreeBSD.ORG (dfilter service)
To: bug-followup at FreeBSD.org
Cc:  
Subject: Re: bin/144192: commit references a PR
Date: Sun, 20 Jun 2010 08:27:13 +0000 (UTC)

 Author: brian
 Date: Sun Jun 20 08:27:03 2010
 New Revision: 209362
 URL: http://svn.freebsd.org/changeset/base/209362
 
 Log:
   Add a -t switch for masking output that's above or below certain thresholds.
   This switch makes it a lot easier to locate problem areas when a process
   is threatening to consume all of your disk space.
   
   PR:		144192
   Submitted by:	gk
   MFC after:	3 weeks
 
 Modified:
   head/usr.bin/du/du.1
   head/usr.bin/du/du.c
 
 Modified: head/usr.bin/du/du.1
 ==============================================================================
 --- head/usr.bin/du/du.1	Sun Jun 20 08:03:06 2010	(r209361)
 +++ head/usr.bin/du/du.1	Sun Jun 20 08:27:03 2010	(r209362)
 @@ -42,7 +42,7 @@
  .Nm
  .Op Fl A
  .Op Fl H | L | P
 -.Op Fl a | s | d Ar depth
 +.Op Fl a | s | d Ar depth | Fl t Ar threshold
  .Op Fl c
  .Op Fl l
  .Op Fl h | k | m | B Ar blocksize
 @@ -107,6 +107,14 @@ This option exists solely for conformanc
  Display an entry for each specified file.
  (Equivalent to
  .Fl d Li 0 )
 +.It Fl t Ar threshold
 +Display only entries for which size exceeds
 +.Ar threshold .
 +If
 +.Ar threshold
 +is negative, display only entries for which size is less than the absolute
 +value of
 +.Ar threshold .
  .It Fl d Ar depth
  Display an entry for all files and directories
  .Ar depth
 
 Modified: head/usr.bin/du/du.c
 ==============================================================================
 --- head/usr.bin/du/du.c	Sun Jun 20 08:03:06 2010	(r209361)
 +++ head/usr.bin/du/du.c	Sun Jun 20 08:27:03 2010	(r209362)
 @@ -90,6 +90,7 @@ main(int argc, char *argv[])
  	FTS		*fts;
  	FTSENT		*p;
  	off_t		savednumber, curblocks;
 +	off_t		threshold, threshold_sign;
  	int		ftsoptions;
  	int		listall;
  	int		depth;
 @@ -106,12 +107,14 @@ main(int argc, char *argv[])
  	save = argv;
  	ftsoptions = 0;
  	savednumber = 0;
 +	threshold = 0;
 +	threshold_sign = 1;
  	cblocksize = DEV_BSIZE;
  	blocksize = 0;
  	depth = INT_MAX;
  	SLIST_INIT(&ignores);
  
 -	while ((ch = getopt(argc, argv, "AB:HI:LPasd:chklmnrx")) != -1)
 +	while ((ch = getopt(argc, argv, "AB:HI:LPasd:chklmnrt:x")) != -1)
  		switch (ch) {
  		case 'A':
  			Aflag = 1;
 @@ -179,6 +182,14 @@ main(int argc, char *argv[])
  			break;
  		case 'r':		 /* Compatibility. */
  			break;
 +		case 't' :
 +			if (expand_number(optarg, &threshold) != 0 ||
 +			    threshold == 0) {
 +				warnx("invalid threshold: %s", optarg);
 +				usage();
 +			} else if (threshold < 0)
 +				threshold_sign = -1;
 +			break;
  		case 'x':
  			ftsoptions |= FTS_XDEV;
  			break;
 @@ -248,6 +259,10 @@ main(int argc, char *argv[])
  		blocksize /= DEV_BSIZE;
  	}
  
 +	if (threshold != 0)
 +		threshold = howmany(threshold / DEV_BSIZE * cblocksize,
 +		    blocksize);
 +
  	rval = 0;
  
  	(void)signal(SIGINFO, siginfo);
 @@ -271,7 +286,9 @@ main(int argc, char *argv[])
  			p->fts_parent->fts_bignum += p->fts_bignum +=
  			    curblocks;
  
 -			if (p->fts_level <= depth) {
 +			if (p->fts_level <= depth && threshold <=
 +			    threshold_sign * howmany(p->fts_bignum *
 +			    cblocksize, blocksize)) {
  				if (hflag) {
  					prthumanval(p->fts_bignum);
  					(void)printf("\t%s\n", p->fts_path);
 _______________________________________________
 svn-src-all at freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe at freebsd.org"
 


More information about the freebsd-bugs mailing list