summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>2003-02-20 15:03:22 +0000
committerJim Meyering <jim@meyering.net>2003-02-20 15:03:22 +0000
commit5c629d9ef4b2f834996850c4cc50fda7bd58646e (patch)
treeb5525be963edd75c0b2e8daf8a069a4044f72ae9 /src
parentc023e74aac87a2c6f39b59a5b5313efef0b9de88 (diff)
downloadcoreutils-5c629d9ef4b2f834996850c4cc50fda7bd58646e.tar.xz
(process_file): Set info->skip before any possible return.
Report correct usage for directories, not 0. (process_file): Return for `file_type == FTW_DPRE' _before_ recording the dev/ino of a directory.
Diffstat (limited to 'src')
-rw-r--r--src/du.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/du.c b/src/du.c
index 95aa4d98c..dac67e5f9 100644
--- a/src/du.c
+++ b/src/du.c
@@ -329,6 +329,9 @@ process_file (const char *file, const struct stat *sb, int file_type,
directory at the specified level. */
static uintmax_t *sum_subdir;
+ /* Always define info->skip before returning. */
+ info->skip = excluded_filename (exclude, file + info->base);
+
switch (file_type)
{
case FTW_NS:
@@ -360,9 +363,14 @@ process_file (const char *file, const struct stat *sb, int file_type,
break;
}
+ /* If this is the first (pre-order) encounter with a directory,
+ return right away. */
+ if (file_type == FTW_DPRE)
+ return 0;
+
/* If the file is being excluded or if it has already been counted
via a hard link, then don't let it contribute to the sums. */
- if ((info->skip = excluded_filename (exclude, file + info->base))
+ if (info->skip
|| (!opt_count_all
&& 1 < sb->st_nlink
&& hash_ins (sb->st_ino, sb->st_dev)))
@@ -377,11 +385,6 @@ process_file (const char *file, const struct stat *sb, int file_type,
s = size = ST_NBLOCKS (*sb);
}
- /* If this is the first (pre-order) encounter with a directory,
- return right away. */
- if (file_type == FTW_DPRE)
- return 0;
-
if (first_call)
{
n_alloc = info->level + 10;