From owner-freebsd-bugs@FreeBSD.ORG Fri Jul 17 08:10:06 2009 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 3765E1065674 for ; Fri, 17 Jul 2009 08:10:06 +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 113338FC17 for ; Fri, 17 Jul 2009 08:10:06 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.14.3/8.14.3) with ESMTP id n6H8A5AS015513 for ; Fri, 17 Jul 2009 08:10:05 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.3/8.14.3/Submit) id n6H8A5aU015512; Fri, 17 Jul 2009 08:10:05 GMT (envelope-from gnats) Resent-Date: Fri, 17 Jul 2009 08:10:05 GMT Resent-Message-Id: <200907170810.n6H8A5aU015512@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, "P.Moulin" Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E211D106564A for ; Fri, 17 Jul 2009 08:04:01 +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 CF9BE8FC0A for ; Fri, 17 Jul 2009 08:04:01 +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 n6H841dx036847 for ; Fri, 17 Jul 2009 08:04:01 GMT (envelope-from nobody@www.freebsd.org) Received: (from nobody@localhost) by www.freebsd.org (8.14.3/8.14.3/Submit) id n6H841mH036843; Fri, 17 Jul 2009 08:04:01 GMT (envelope-from nobody) Message-Id: <200907170804.n6H841mH036843@www.freebsd.org> Date: Fri, 17 Jul 2009 08:04:01 GMT From: "P.Moulin" To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.1 Cc: Subject: bin/136857: "du" command: patch commited to permit per directory only sum (no heritage). 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: Fri, 17 Jul 2009 08:10:06 -0000 >Number: 136857 >Category: bin >Synopsis: "du" command: patch commited to permit per directory only sum (no heritage). >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: update >Submitter-Id: current-users >Arrival-Date: Fri Jul 17 08:10:05 UTC 2009 >Closed-Date: >Last-Modified: >Originator: P.Moulin >Release: 8.0b1 >Organization: Calyopea >Environment: FreeBSD nc4000 8.0-BETA1 FreeBSD 8.0-BETA1 #0: Sat Jul 4 03:55:14 UTC 2009 root@almeida.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC i386 >Description: When using "du", no option permit only per directories files sum. here is a patch (option -N (No heritage)) to solve this. Warning, the mail address given below is a spamtrap. Good email is : p.moulin (at) calyopea_donotfeedanimals (dot) com (remove _donotfeedanimals) >How-To-Repeat: >Fix: Patch attached with submission follows: diff -C 5 du_ORIG/du.1 du/du.1 *** du_ORIG/du.1 Sun Mar 15 05:04:51 2009 --- du/du.1 Fri Jul 17 09:05:12 2009 *************** *** 39,50 **** .Nm du .Nd display disk usage statistics .Sh SYNOPSIS .Nm .Op Fl A ! .Op Fl H | L | P ! .Op Fl a | s | d Ar depth .Op Fl c .Op Fl l .Op Fl h | k | m | B Ar blocksize .Op Fl n .Op Fl x --- 39,50 ---- .Nm du .Nd display disk usage statistics .Sh SYNOPSIS .Nm .Op Fl A ! .Op Fl H | L | P ! .Op Fl a | s | N | d Ar depth .Op Fl c .Op Fl l .Op Fl h | k | m | B Ar blocksize .Op Fl n .Op Fl x *************** *** 89,98 **** --- 89,101 ---- Ignore files and directories matching the specified .Ar mask . .It Fl P No symbolic links are followed. This is the default. + .It Fl N + Print sum of files within directories only: do not heritate of children's + directory size. .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, Only in du: du.1.gz diff -C 5 du_ORIG/du.c du/du.c *** du_ORIG/du.c Sun Mar 15 05:04:51 2009 --- du/du.c Fri Jul 17 08:58:47 2009 *************** *** 89,117 **** FTSENT *p; off_t savednumber, curblocks; int ftsoptions; int listall; int depth; ! int Hflag, Lflag, Pflag, aflag, sflag, dflag, cflag; int hflag, lflag, ch, notused, rval; char **save; static char dot[] = "."; setlocale(LC_ALL, ""); Hflag = Lflag = Pflag = aflag = sflag = dflag = cflag = hflag = ! lflag = Aflag = 0; save = argv; ftsoptions = 0; savednumber = 0; cblocksize = DEV_BSIZE; blocksize = 0; depth = INT_MAX; SLIST_INIT(&ignores); ! while ((ch = getopt(argc, argv, "AB:HI:LPasd:chklmnrx")) != -1) switch (ch) { case 'A': Aflag = 1; break; case 'B': --- 89,117 ---- FTSENT *p; off_t savednumber, curblocks; int ftsoptions; int listall; int depth; ! int Hflag, Lflag, Pflag, Nflag, aflag, sflag, dflag, cflag; int hflag, lflag, ch, notused, rval; char **save; static char dot[] = "."; setlocale(LC_ALL, ""); Hflag = Lflag = Pflag = aflag = sflag = dflag = cflag = hflag = ! lflag = Aflag = Nflag = 0; save = argv; ftsoptions = 0; savednumber = 0; cblocksize = DEV_BSIZE; blocksize = 0; depth = INT_MAX; SLIST_INIT(&ignores); ! while ((ch = getopt(argc, argv, "AB:HI:LPNasd:chklmnrx")) != -1) switch (ch) { case 'A': Aflag = 1; break; case 'B': *************** *** 137,146 **** --- 137,149 ---- case 'P': if (Lflag) usage(); Pflag = 1; break; + case 'N': + Nflag = 1; + break; case 'a': aflag = 1; break; case 's': sflag = 1; *************** *** 203,212 **** --- 206,218 ---- */ if (Hflag + Lflag + Pflag > 1) usage(); + if (sflag + Nflag > 1) /* meaningless */ + usage(); + if (Hflag + Lflag + Pflag == 0) Pflag = 1; /* -P (physical) is default */ if (Hflag) ftsoptions |= FTS_COMFOLLOW; *************** *** 262,274 **** break; curblocks = Aflag ? howmany(p->fts_statp->st_size, cblocksize) : howmany(p->fts_statp->st_blocks, cblocksize); ! p->fts_parent->fts_bignum += p->fts_bignum += ! curblocks; ! if (p->fts_level <= depth) { if (hflag) { prthumanval(p->fts_bignum); (void)printf("\t%s\n", p->fts_path); } else { --- 268,281 ---- break; curblocks = Aflag ? howmany(p->fts_statp->st_size, cblocksize) : howmany(p->fts_statp->st_blocks, cblocksize); ! if (!Nflag) { ! p->fts_parent->fts_bignum += p->fts_bignum += ! curblocks; ! } if (p->fts_level <= depth) { if (hflag) { prthumanval(p->fts_bignum); (void)printf("\t%s\n", p->fts_path); } else { >Release-Note: >Audit-Trail: >Unformatted: