NetBSD Problem Report #2805
Received: (qmail-queue invoked from smtpd); 4 Oct 1996 08:46:57 -0000
Message-Id: <199610040845.SAA13378@melanoma.bf.rmit.edu.au>
Date: Fri, 4 Oct 1996 18:45:24 +1000
From: lukem@telstra.com.au
Reply-To: lukem@telstra.com.au
To: gnats-bugs@gnats.netbsd.org
Subject: add '-c' (show grand total) to du
X-Send-Pr-Version: 3.95
>Number: 2805
>Category: bin
>Synopsis: du needs a '-c' (grand total) option
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: bin-bug-people
>State: closed
>Class: change-request
>Submitter-Id: lm
>Arrival-Date: Fri Oct 04 01:50:01 +0000 1996
>Closed-Date: Fri Oct 18 07:21:33 +0000 1996
>Last-Modified: Fri Oct 18 07:22:41 +0000 1996
>Originator: Luke Mewburn
>Release: 1.2
>Organization:
werj
>Environment:
System: NetBSD melanoma 1.1 NetBSD 1.1 (MELANOMA) #1: Thu Dec 7 12:45:12 EST 1995 root@melanoma:/usr/src/sys/arch/i386/compile/MELANOMA i386
>Description:
GNU du supports '-c', which shows a grand total at the end. This is
very useful when you do 'gdu -c -s *', amongst other things.
This patch gives netbsd the same functionality.
>How-To-Repeat:
run du. notice lack of grand total option.
>Fix:
apply this simple yet effective patch.
diff -c /ftp/pub/NetBSD/NetBSD-current/src/usr.bin/du/du.1 ./du.1
*** /ftp/pub/NetBSD/NetBSD-current/src/usr.bin/du/du.1 Fri Jan 5 23:27:54 1996
--- ./du.1 Fri Oct 4 18:32:35 1996
***************
*** 33,39 ****
.\"
.\" @(#)du.1 8.2 (Berkeley) 4/1/94
.\"
! .Dd April 1, 1994
.Dt DU 1
.Os
.Sh NAME
--- 33,39 ----
.\"
.\" @(#)du.1 8.2 (Berkeley) 4/1/94
.\"
! .Dd October 4, 1996
.Dt DU 1
.Os
.Sh NAME
***************
*** 43,49 ****
.Nm du
.Op Fl H | Fl L | Fl P
.Op Fl a | Fl s
! .Op Fl kx
.Op Ar file ...
.Sh DESCRIPTION
The
--- 43,49 ----
.Nm du
.Op Fl H | Fl L | Fl P
.Op Fl a | Fl s
! .Op Fl ckx
.Op Ar file ...
.Sh DESCRIPTION
The
***************
*** 76,81 ****
--- 76,83 ----
flag is specified, the number displayed is the number of 1024-byte
blocks.
Partial numbers of blocks are rounded up.
+ .It Fl c
+ Display the grand total after all the arguments have been processed.
.It Fl s
Display only the grand total for the specified files.
.It Fl x
diff -c /ftp/pub/NetBSD/NetBSD-current/src/usr.bin/du/du.c ./du.c
*** /ftp/pub/NetBSD/NetBSD-current/src/usr.bin/du/du.c Sat Oct 14 13:05:22 1995
--- ./du.c Fri Oct 4 18:37:48 1996
***************
*** 72,86 ****
{
FTS *fts;
FTSENT *p;
! long blocksize;
int ftsoptions, listdirs, listfiles;
! int Hflag, Lflag, Pflag, aflag, ch, kflag, notused, rval, sflag;
char **save;
save = argv;
! Hflag = Lflag = Pflag = aflag = kflag = sflag = 0;
ftsoptions = FTS_PHYSICAL;
! while ((ch = getopt(argc, argv, "HLPaksx")) != EOF)
switch (ch) {
case 'H':
Hflag = 1;
--- 72,87 ----
{
FTS *fts;
FTSENT *p;
! long blocksize, totalblocks;
int ftsoptions, listdirs, listfiles;
! int Hflag, Lflag, Pflag, aflag, ch, cflag, kflag, notused, rval, sflag;
char **save;
save = argv;
! Hflag = Lflag = Pflag = aflag = cflag = kflag = sflag = 0;
! totalblocks = 0;
ftsoptions = FTS_PHYSICAL;
! while ((ch = getopt(argc, argv, "HLPacksx")) != EOF)
switch (ch) {
case 'H':
Hflag = 1;
***************
*** 97,102 ****
--- 98,106 ----
case 'a':
aflag = 1;
break;
+ case 'c':
+ cflag = 1;
+ break;
case 'k':
blocksize = 1024;
kflag = 1;
***************
*** 164,169 ****
--- 168,175 ----
case FTS_DP:
p->fts_parent->fts_number +=
p->fts_number += p->fts_statp->st_blocks;
+ if (cflag)
+ totalblocks += p->fts_statp->st_blocks;
/*
* If listing each directory, or not listing files
* or directories and this is post-order of the
***************
*** 194,202 ****
--- 200,213 ----
howmany(p->fts_statp->st_blocks, blocksize),
p->fts_path);
p->fts_parent->fts_number += p->fts_statp->st_blocks;
+ if (cflag)
+ totalblocks += p->fts_statp->st_blocks;
}
if (errno)
err(1, "fts_read");
+ if (cflag)
+ (void)printf("%ld\ttotal\n",
+ howmany(totalblocks, blocksize));
exit(0);
}
***************
*** 236,241 ****
{
(void)fprintf(stderr,
! "usage: du [-H | -L | -P] [-a | -s] [-kx] [file ...]\n");
exit(1);
}
--- 247,252 ----
{
(void)fprintf(stderr,
! "usage: du [-H | -L | -P] [-a | -s] [-ckx] [file ...]\n");
exit(1);
}
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed
State-Changed-By: thorpej
State-Changed-When: Fri Oct 18 00:21:33 PDT 1996
State-Changed-Why:
Patch applied. Thanks!
>Unformatted:
(Contact us)
$NetBSD: query-full-pr,v 1.49 2026/05/14 01:52:41 riastradh Exp $
$NetBSD: gnats_config.sh,v 1.10 2026/05/13 22:00:09 riastradh Exp $
Copyright © 1994-2026
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.