diff options
| author | dsl <dsl@NetBSD.org> | 2008-07-30 22:03:40 +0000 |
|---|---|---|
| committer | dsl <dsl@NetBSD.org> | 2008-07-30 22:03:40 +0000 |
| commit | 0109c05abd3c7f3bbd3ee5eb0e76bfd776516687 (patch) | |
| tree | 41c5e58e131ceb40f87a0ba7abcc5cb15bec895f | |
| parent | 6fe369e77268bfee35522c276b92260cb4e86249 (diff) | |
Fix 'total' output from 'du -sc'.
Simplify the change (adding -d<depth>) that broke it by noting that
-d0 is supposed to be the same as -s.
Calling fts_set(fts,p,FTS_SKIP) here is also pointless.
| -rw-r--r-- | usr.bin/du/du.c | 23 |
1 files changed, 8 insertions, 15 deletions
diff --git a/usr.bin/du/du.c b/usr.bin/du/du.c index f2f23f2c486..4ff28dbfd0a 100644 --- a/usr.bin/du/du.c +++ b/usr.bin/du/du.c @@ -1,4 +1,4 @@ -/* $NetBSD: du.c,v 1.32 2008/07/21 14:19:22 lukem Exp $ */ +/* $NetBSD: du.c,v 1.33 2008/07/30 22:03:40 dsl Exp $ */ /* * Copyright (c) 1989, 1993, 1994 @@ -42,7 +42,7 @@ __COPYRIGHT("@(#) Copyright (c) 1989, 1993, 1994\ #if 0 static char sccsid[] = "@(#)du.c 8.5 (Berkeley) 5/4/95"; #else -__RCSID("$NetBSD: du.c,v 1.32 2008/07/21 14:19:22 lukem Exp $"); +__RCSID("$NetBSD: du.c,v 1.33 2008/07/30 22:03:40 dsl Exp $"); #endif #endif /* not lint */ @@ -73,7 +73,7 @@ main(int argc, char *argv[]) FTS *fts; FTSENT *p; int64_t totalblocks; - int ftsoptions, listdirs, listfiles; + int ftsoptions, listfiles; int depth; int Hflag, Lflag, aflag, ch, cflag, dflag, gkmflag, nflag, rval, sflag; const char *noargv[2]; @@ -162,17 +162,15 @@ main(int argc, char *argv[]) ftsoptions |= FTS_LOGICAL; } + listfiles = 0; if (aflag) { if (sflag || dflag) usage(); - listdirs = listfiles = 1; + listfiles = 1; } else if (sflag) { if (dflag) usage(); - listdirs = listfiles = depth = 0; - } else { - listfiles = 0; - listdirs = 1; + depth = 0; } if (!*argv) { @@ -208,12 +206,6 @@ main(int argc, char *argv[]) case FTS_DP: p->fts_parent->fts_number += p->fts_number += p->fts_statp->st_blocks; - - if (p->fts_level > depth) { - fts_set(fts, p, FTS_SKIP); - continue; - } - if (cflag) totalblocks += p->fts_statp->st_blocks; /* @@ -221,7 +213,8 @@ main(int argc, char *argv[]) * or directories and this is post-order of the * root of a traversal, display the total. */ - if (listdirs || (!listfiles && !p->fts_level)) + if (p->fts_level <= depth + || (!listfiles && !p->fts_level)) prstat(p->fts_path, p->fts_number); break; case FTS_DC: /* Ignore. */ |
