From: Jim Meyering Date: Sat, 18 Nov 2000 20:01:02 +0000 (+0000) Subject: (count_entry): Don't omit the size of a directory entry X-Git-Tag: FILEUTILS-4_0_33~69 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=6447e5b99745bd0c40a81cfcd5e6f1a3e6e3202f;p=platform%2Fupstream%2Fcoreutils.git (count_entry): Don't omit the size of a directory entry merely because we couldn't `chdir' into it. That would give subtly different results in some cases. Reported by Mattias Wadenstein via Michael Stone. --- diff --git a/src/du.c b/src/du.c index 63b5d61..ab47a62 100644 --- a/src/du.c +++ b/src/du.c @@ -520,6 +520,8 @@ count_entry (const char *ent, int top, dev_t last_dev, int depth) dir_dev = stat_buf.st_dev; + /* Return `0' here, not SIZE, since the SIZE bytes + would reside in the new filesystem. */ if (opt_one_file_system && !top && last_dev != dir_dev) return 0; /* Don't enter a new file system. */ @@ -553,7 +555,9 @@ count_entry (const char *ent, int top, dev_t last_dev, int depth) if (cwd) free_cwd (cwd); exit_status = 1; - return 0; + /* Do return SIZE, here, since even though we can't chdir into ENT, + we *can* count the blocks used by its directory entry. */ + return opt_separate_dirs ? 0 : size; } name_space = savedir (".", stat_buf.st_size); @@ -562,7 +566,8 @@ count_entry (const char *ent, int top, dev_t last_dev, int depth) error (0, errno, "%s", quote (path->text)); pop_dir (cwd, path->text); exit_status = 1; - return 0; + /* Do count the SIZE bytes. */ + return opt_separate_dirs ? 0 : size; } /* Remember the current path. */