Date: Wed, 16 Oct 1996 03:11:23 -0700 (PDT) From: John-Mark Gurney <jmg@nike.efn.org> To: FreeBSD-gnats-submit@freebsd.org Subject: bin/1824: Message-ID: <199610161011.DAA21593@nike.efn.org> Resent-Message-ID: <199610161020.DAA06547@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 1824
>Category: bin
>Synopsis:
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: freebsd-bugs
>State: open
>Class: sw-bug
>Submitter-Id: current-users
>Arrival-Date: Wed Oct 16 03:20:02 PDT 1996
>Last-Modified:
>Originator: John-Mark Gurney
>Organization:
Cu Networking
>Release: FreeBSD 2.2-960801-SNAP i386
>Environment:
nothing special.. changes relative to -current
>Description:
got anoyed with not being able to get some depth out of du like two or three
directories with out getting those really long anoying 10 deep dirs also...
added a -d option to du to provide a limit on depth, very easy fix as fts
provides depth in the structure...
>How-To-Repeat:
run: du -d 2
and see that it is an invalid option :)
>Fix:
apply this patch (includes documentation patches) i have been running this
patch for a while now, no wierd things have happened over here, both using -s
and -d...:
Index: du.1
===================================================================
RCS file: /usr/cvs/src/usr.bin/du/du.1,v
retrieving revision 1.5
diff -c -r1.5 du.1
*** du.1 1996/08/29 18:05:49 1.5
--- du.1 1996/09/15 05:50:11
***************
*** 41,47 ****
.Sh SYNOPSIS
.Nm du
.Op Fl H | Fl L | Fl P
! .Op Fl a | Fl s
.Op Fl x
.Op Ar file ...
.Sh DESCRIPTION
--- 41,47 ----
.Sh SYNOPSIS
.Nm du
.Op Fl H | Fl L | Fl P
! .Op Fl a | s | d Ar depth
.Op Fl x
.Op Ar file ...
.Sh DESCRIPTION
***************
*** 68,73 ****
--- 68,77 ----
No symbolic links are followed.
.It Fl a
Display an entry for each file in the file hierarchy.
+ .It Fl d Ar depth
+ Displays all directories only
+ .Ar depth
+ directories deep.
.It Fl k
Report in 1024-byte (1-Kbyte) blocks rather than the default. Note that
this overrides the
Index: du.c
===================================================================
RCS file: /usr/cvs/src/usr.bin/du/du.c,v
retrieving revision 1.5
diff -c -r1.5 du.c
*** du.c 1995/05/30 06:29:49 1.5
--- du.c 1996/10/16 09:40:46
***************
*** 66,79 ****
FTS *fts;
FTSENT *p;
long blocksize;
! int ftsoptions, listdirs, listfiles;
! int Hflag, Lflag, Pflag, aflag, ch, notused, rval, sflag;
char **save;
save = argv;
! Hflag = Lflag = Pflag = aflag = sflag = 0;
ftsoptions = FTS_PHYSICAL;
! while ((ch = getopt(argc, argv, "HLPaksx")) != EOF)
switch (ch) {
case 'H':
Hflag = 1;
--- 66,80 ----
FTS *fts;
FTSENT *p;
long blocksize;
! int ftsoptions, listdirs, listfiles, depth;
! int Hflag, Lflag, Pflag, aflag, ch, notused, rval, sflag, dflag;
char **save;
save = argv;
! Hflag = Lflag = Pflag = aflag = sflag = dflag = 0;
! depth = INT_MAX;
ftsoptions = FTS_PHYSICAL;
! while ((ch = getopt(argc, argv, "HLPad:ksx")) != EOF)
switch (ch) {
case 'H':
Hflag = 1;
***************
*** 99,104 ****
--- 100,113 ----
case 'x':
ftsoptions |= FTS_XDEV;
break;
+ case 'd':
+ dflag = 1;
+ depth=atoi(optarg);
+ if(errno == ERANGE) {
+ (void)fprintf(stderr, "Invalid argument to option d: %s", optarg);
+ usage();
+ }
+ break;
case '?':
default:
usage();
***************
*** 126,137 ****
}
if (aflag) {
! if (sflag)
usage();
listdirs = listfiles = 1;
! } else if (sflag)
listdirs = listfiles = 0;
! else {
listfiles = 0;
listdirs = 1;
}
--- 135,151 ----
}
if (aflag) {
! if (sflag || dflag)
usage();
listdirs = listfiles = 1;
! } else if (sflag) {
! if (dflag)
! usage();
listdirs = listfiles = 0;
! } else if (dflag) {
! listfiles = 0;
! listdirs = 1;
! } else {
listfiles = 0;
listdirs = 1;
}
***************
*** 160,166 ****
* or directories and this is post-order of the
* root of a traversal, display the total.
*/
! if (listdirs || !listfiles && !p->fts_level)
(void)printf("%ld\t%s\n",
howmany(p->fts_number, blocksize),
p->fts_path);
--- 174,180 ----
* or directories and this is post-order of the
* root of a traversal, display the total.
*/
! if (p->fts_level <= depth && listdirs || !listfiles && !p->fts_level)
(void)printf("%ld\t%s\n",
howmany(p->fts_number, blocksize),
p->fts_path);
***************
*** 227,232 ****
{
(void)fprintf(stderr,
! "usage: du [-H | -L | -P] [-a | -s] [-k] [-x] [file ...]\n");
exit(1);
}
--- 241,246 ----
{
(void)fprintf(stderr,
! "usage: du [-H | -L | -P] [-a | -s | -d depth] [-k] [-x] [file ...]\n");
exit(1);
}
>Audit-Trail:
>Unformatted:
du doesn't have a depth limit factor
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199610161011.DAA21593>
