summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>2003-03-08 10:21:19 +0000
committerJim Meyering <jim@meyering.net>2003-03-08 10:21:19 +0000
commit66bada849bc2adced718371645e2ae5989c1c740 (patch)
treee0a99a9bf301e3cb36d5bfe164834acef25b8666 /src
parent07f4993bfbdb122b74080514b8df98b43e99cf01 (diff)
downloadcoreutils-66bada849bc2adced718371645e2ae5989c1c740.tar.xz
(process_file): If a file's size is not being counted
e.g., because it's a hard link to a file we've already counted, then don't print a line for it.
Diffstat (limited to 'src')
-rw-r--r--src/du.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/du.c b/src/du.c
index 8a98aba84..6445f8e8a 100644
--- a/src/du.c
+++ b/src/du.c
@@ -321,6 +321,7 @@ process_file (const char *file, const struct stat *sb, int file_type,
static size_t n_alloc;
static uintmax_t *sum_ent;
static uintmax_t *sum_subdir;
+ int print = 1;
/* Always define info->skip before returning. */
info->skip = excluded_filename (exclude, file + info->base);
@@ -372,6 +373,7 @@ process_file (const char *file, const struct stat *sb, int file_type,
We still have to update prev_level and maybe propagate
some sums up the hierarchy. */
size = 0;
+ print = 0;
}
else
{
@@ -453,6 +455,12 @@ process_file (const char *file, const struct stat *sb, int file_type,
if (file_type == FTW_DNR || file_type == FTW_DCH)
return 0;
+ /* If we're not counting an entry, e.g., because it's a hard link
+ to a file we've already counted (and --count-links), then don't
+ print a line for it. */
+ if (!print)
+ return 0;
+
/* FIXME: This looks suspiciously like it could be simplified. */
if ((IS_FTW_DIR_TYPE (file_type) &&
(info->level <= max_depth || info->level == 0))