]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
Minor optimization:
authorJim Meyering <jim@meyering.net>
Sun, 28 Mar 2004 21:43:50 +0000 (21:43 +0000)
committerJim Meyering <jim@meyering.net>
Sun, 28 Mar 2004 21:43:50 +0000 (21:43 +0000)
(process_file): Don't record dev/inode for directories.

Under some circumstances, without -c, du would mistakenly count the
space of hard-linked files, not just the first one it encountered.
Reported by Anthony Thyssen.
(du_files): Don't ever clear the set of `seen' dev/inodes.

src/du.c

index eb021224963ab7b1d77dbf58a77670a973aa70af..bd1d7c5c730f398133738ed19ee337301413d7e3 100644 (file)
--- a/src/du.c
+++ b/src/du.c
@@ -377,6 +377,7 @@ process_file (FTS *fts, FTSENT *ent)
      via a hard link, then don't let it contribute to the sums.  */
   if (skip
       || (!opt_count_all
+         && ! S_ISDIR (sb->st_mode)
          && 1 < sb->st_nlink
          && hash_ins (sb->st_ino, sb->st_dev)))
     {
@@ -518,12 +519,6 @@ du_files (char **files, int bit_flags)
            }
          FTS_CROSS_CHECK (fts);
 
-         /* This is a space optimization.  If we aren't printing totals,
-            then it's ok to clear the duplicate-detection tables after
-            each command line hierarchy has been processed.  */
-         if (ent->fts_level == 0 && ent->fts_info == FTS_D && !print_grand_total)
-           hash_clear (htab);
-
          process_file (fts, ent);
        }