bin/136857: "du" command: patch commited to permit per directory
only sum (no heritage).
P.Moulin (spamtrap)
robert13223 at caliopea.com
Fri Jul 17 08:10:06 UTC 2009
>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 at 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:
More information about the freebsd-bugs
mailing list