From nobody@FreeBSD.org  Mon Aug  3 17:57:49 2009
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 6CA6B1065687
	for <freebsd-gnats-submit@FreeBSD.org>; Mon,  3 Aug 2009 17:57:49 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21])
	by mx1.freebsd.org (Postfix) with ESMTP id 5B6468FC1D
	for <freebsd-gnats-submit@FreeBSD.org>; Mon,  3 Aug 2009 17:57:49 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.14.3/8.14.3) with ESMTP id n73HvnIH098760
	for <freebsd-gnats-submit@FreeBSD.org>; Mon, 3 Aug 2009 17:57:49 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.14.3/8.14.3/Submit) id n73HvmxU098759;
	Mon, 3 Aug 2009 17:57:48 GMT
	(envelope-from nobody)
Message-Id: <200908031757.n73HvmxU098759@www.freebsd.org>
Date: Mon, 3 Aug 2009 17:57:48 GMT
From: Craig R <c4@backfire.ca>
To: freebsd-gnats-submit@FreeBSD.org
Subject: du with gigabyte units
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         137399
>Category:       bin
>Synopsis:       [patchc] add gigabyte units to du(1)
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    vwe
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          update
>Submitter-Id:   current-users
>Arrival-Date:   Mon Aug 03 18:00:12 UTC 2009
>Closed-Date:    Thu Aug 20 19:51:13 UTC 2009
>Last-Modified:  Thu Aug 20 19:51:13 UTC 2009
>Originator:     Craig R
>Release:        7.0
>Organization:
Backfire.ca
>Environment:
>Description:
df supports the -g option, which uses gigs for units. This patch blesses du with the same functionality.


>How-To-Repeat:
Run du with -g, watch it complain.
>Fix:
Apply attached patch liberally. Repeat if desired.

Patch attached with submission follows:

--- du.c.old	2009-08-03 13:46:33.000000000 -0400
+++ du.c	2009-08-03 13:51:36.000000000 -0400
@@ -103,7 +103,7 @@
 	depth = INT_MAX;
 	SLIST_INIT(&ignores);
 
-	while ((ch = getopt(argc, argv, "HI:LPasd:chkmnrx")) != -1)
+	while ((ch = getopt(argc, argv, "HI:LPasd:cghkmnrx")) != -1)
 		switch (ch) {
 			case 'H':
 				Hflag = 1;
@@ -139,6 +139,10 @@
 			case 'c':
 				cflag = 1;
 				break;
+			case 'g':
+				hflag = 0;
+				setenv("BLOCKSIZE", "1073741824", 1);
+				break;
 			case 'h':
 				setenv("BLOCKSIZE", "512", 1);
 				hflag = 1;
@@ -443,7 +447,7 @@
 usage(void)
 {
 	(void)fprintf(stderr,
-		"usage: du [-H | -L | -P] [-a | -s | -d depth] [-c] [-h | -k | -m] [-n] [-x] [-I mask] [file ...]\n");
+		"usage: du [-H | -L | -P] [-a | -s | -d depth] [-c] [-g | -h | -k | -m] [-n] [-x] [-I mask] [file ...]\n");
 	exit(EX_USAGE);
 }
 


>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: vwe 
State-Changed-When: Thu Aug 20 19:48:03 UTC 2009 
State-Changed-Why:  
DUP of bin/123418 
closing this in favour of 123418 as it code changes are looking more like style(9) conformant and also contain man page changes. 
Craig, thank you for filing this PR but may we ask you to query GNATS first before sending in duplicate reports? Thank you for your understanding. 


Responsible-Changed-From-To: freebsd-bugs->vwe 
Responsible-Changed-By: vwe 
Responsible-Changed-When: Thu Aug 20 19:48:03 UTC 2009 
Responsible-Changed-Why:  
track 

http://www.freebsd.org/cgi/query-pr.cgi?pr=137399 
>Unformatted:
