Subject: Re: bug#10967: Weird 'du' behavior. Bug in coreutils-8.15 ?

From: Jim Meyering <[email-masked]>
Date: Thu, 08 Mar 2012 09:19:41 +0100

Daniel Stavrovski wrote:
> ┌─[01:17:15]-[root@stavrovski]-[~]
> └─› mkdir /tmp/another_test/ && for i in $(seq 1 20); do dd if=/dev/zero
> of=/tmp/another_test/file-$i  bs=1024  count=10240 ; done
>
> ┌─[01:17:17]-[root@stavrovski]-[~]
> └─› ls -1 /tmp/another_test/* | wc -l
> 20
>
> ┌─[01:17:36]-[root@stavrovski]-[~]
> └─› du -csxh /tmp/another_test/*
> 0       total
>
> ┌─[01:28:19]-[root@stavrovski]-[~]
> └─› du --version
> du (GNU coreutils) 8.15

Oh!  That's a regression.
Thank you for finding/reporting it!

Here's the fix I expect to use:

diff --git a/src/du.c b/src/du.c
index e4e36df..c1c0417 100644
--- a/src/du.c
+++ b/src/du.c
@@ -443,7 +443,9 @@ process_file (FTS *fts, FTSENT *ent)
               return false;
             }

-          if (fts->fts_options & FTS_XDEV && fts->fts_dev != sb->st_dev)
+          if (fts->fts_options & FTS_XDEV
+              && FTS_ROOTLEVEL < ent->fts_level
+              && fts->fts_dev != sb->st_dev)
             excluded = true;
         }