summaryrefslogtreecommitdiff
path: root/src/du.c
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>2000-11-18 20:01:02 +0000
committerJim Meyering <jim@meyering.net>2000-11-18 20:01:02 +0000
commit6447e5b99745bd0c40a81cfcd5e6f1a3e6e3202f (patch)
tree45115854ec963459677ce2725a236a43e7018102 /src/du.c
parent49d5578b0bc37234ac58ea97b553296a39a03d05 (diff)
downloadcoreutils-6447e5b99745bd0c40a81cfcd5e6f1a3e6e3202f.tar.xz
(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.
Diffstat (limited to 'src/du.c')
-rw-r--r--src/du.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/du.c b/src/du.c
index 63b5d6194..ab47a620f 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. */