From 66bada849bc2adced718371645e2ae5989c1c740 Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Sat, 8 Mar 2003 10:21:19 +0000 Subject: (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. --- src/du.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src') 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)) -- cgit v1.2.3-70-g09d2