From owner-freebsd-bugs@FreeBSD.ORG Mon May 5 14:20:02 2008 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5F00E1065670 for ; Mon, 5 May 2008 14:20:02 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 36FE88FC15 for ; Mon, 5 May 2008 14:20:02 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.14.2/8.14.2) with ESMTP id m45EK23c088734 for ; Mon, 5 May 2008 14:20:02 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.2/8.14.1/Submit) id m45EK2Hk088733; Mon, 5 May 2008 14:20:02 GMT (envelope-from gnats) Resent-Date: Mon, 5 May 2008 14:20:02 GMT Resent-Message-Id: <200805051420.m45EK2Hk088733@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Robert Woolley Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C76B3106566C for ; Mon, 5 May 2008 14:17:40 +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 B132F8FC1C for ; Mon, 5 May 2008 14:17:40 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (localhost [127.0.0.1]) by www.freebsd.org (8.14.2/8.14.2) with ESMTP id m45EGo9j068571 for ; Mon, 5 May 2008 14:16:50 GMT (envelope-from nobody@www.freebsd.org) Received: (from nobody@localhost) by www.freebsd.org (8.14.2/8.14.1/Submit) id m45EGofJ068570; Mon, 5 May 2008 14:16:50 GMT (envelope-from nobody) Message-Id: <200805051416.m45EGofJ068570@www.freebsd.org> Date: Mon, 5 May 2008 14:16:50 GMT From: Robert Woolley To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.1 Cc: Subject: bin/123418: [patch] Add -g (Gbyte) option to du(1) + manpage cleanup X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 05 May 2008 14:20:02 -0000 >Number: 123418 >Category: bin >Synopsis: [patch] Add -g (Gbyte) option to du(1) + manpage cleanup >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: update >Submitter-Id: current-users >Arrival-Date: Mon May 05 14:20:01 UTC 2008 >Closed-Date: >Last-Modified: >Originator: Robert Woolley >Release: 7.0 with du.1 and du.c from CURRENT >Organization: >Environment: FreeBSD gumby.homeunix.com 7.0-RELEASE-p1 FreeBSD 7.0-RELEASE-p1 #0: Mon May 5 14:19:07 BST 2008 root@gumby.homeunix.com:/usr/obj/usr/src/sys/MUSTARD i386 >Description: Patch adds a GByte blocksize option to du(1), bringing it into line with df(1). I find GB units to be preferable for seeing at-a-glance which directories are using significant space. In adding the -g option to the manpage, I also reordered the options into alphabetical order, since they were in a bit of a mess. >How-To-Repeat: >Fix: Note that the patch is against CURRENT. The changes to du.c from 7.0 to current are self-contained, so I copied du.c and du.1 from CVS into 7.0. Patch attached with submission follows: --- usr.bin/du/du.c.orig 2008-04-29 21:38:35.000000000 +0100 +++ usr.bin/du/du.c 2008-04-29 21:42:54.000000000 +0100 @@ -105,7 +105,7 @@ depth = INT_MAX; SLIST_INIT(&ignores); - while ((ch = getopt(argc, argv, "HI:LPasd:chklmnrx")) != -1) + while ((ch = getopt(argc, argv, "HI:LPasd:cghklmnrx")) != -1) switch (ch) { case 'H': Hflag = 1; @@ -141,6 +141,11 @@ case 'c': cflag = 1; break; + case 'g': + hflag = 0; + if (setenv("BLOCKSIZE", "1073741824", 1) == -1) + warn("setenv: cannot set BLOCKSIZE=1073741824"); + break; case 'h': if (setenv("BLOCKSIZE", "512", 1) == -1) warn( @@ -454,7 +459,7 @@ { (void)fprintf(stderr, "usage: du [-H | -L | -P] [-a | -s | -d depth] [-c] " - "[-l] [-h | -k | -m] [-n] [-x] [-I mask] [file ...]\n"); + "[-l] [-h | -k | -m | -g] [-n] [-x] [-I mask] [file ...]\n"); exit(EX_USAGE); } --- usr.bin/du/du.1.orig 2008-04-29 21:38:22.000000000 +0100 +++ usr.bin/du/du.1 2008-05-05 12:57:47.000000000 +0100 @@ -60,41 +60,30 @@ .Pp The options are as follows: .Bl -tag -width indent +.It Fl a +Display an entry for each file in a file hierarchy. +.It Fl c +Display a grand total. +.It Fl d Ar depth +Display an entry for all files and directories +.Ar depth +directories deep. +.It Fl g +Display block counts in 1073741824-byte (1-Gbyte) blocks. .It Fl H Symbolic links on the command line are followed, symbolic links in file hierarchies are not followed. -.It Fl L -Symbolic links on the command line and in file hierarchies are followed. -.It Fl I Ar mask -Ignore files and directories matching the specified -.Ar mask . -.It Fl P -No symbolic links are followed. -This is the default. -.It Fl a -Display an entry for each file in a file hierarchy. .It Fl h "Human-readable" output. Use unit suffixes: Byte, Kilobyte, Megabyte, Gigabyte, Terabyte and Petabyte. -.It Fl r -Generate messages about directories that cannot be read, files -that cannot be opened, and so on. -This is the default case. -This option exists solely for conformance with -.St -xpg4 . -.It Fl s -Display an entry for each specified file. -(Equivalent to -.Fl d Li 0 ) -.It Fl d Ar depth -Display an entry for all files and directories -.Ar depth -directories deep. -.It Fl c -Display a grand total. +.It Fl I Ar mask +Ignore files and directories matching the specified +.Ar mask . .It Fl k Display block counts in 1024-byte (1-Kbyte) blocks. +.It Fl L +Symbolic links on the command line and in file hierarchies are followed. .It Fl l If a file has multiple hard links, count its size many times. The default behavior of @@ -112,6 +101,19 @@ flag .Pq Dv UF_NODUMP set. +.It Fl P +No symbolic links are followed. +This is the default. +.It Fl r +Generate messages about directories that cannot be read, files +that cannot be opened, and so on. +This is the default case. +This option exists solely for conformance with +.St -xpg4 . +.It Fl s +Display an entry for each specified file. +(Equivalent to +.Fl d Li 0 ) .It Fl x File system mount points are not traversed. .El >Release-Note: >Audit-Trail: >Unformatted: