[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#10293: [PATCH] du -x should not count files in other file systems
From: |
Jim Meyering |
Subject: |
bug#10293: [PATCH] du -x should not count files in other file systems |
Date: |
Wed, 14 Dec 2011 11:48:26 +0100 |
Paul Eggert wrote:
> While looking into Bug#10282 I noticed that 'du' is mishandling
> the -x option. It relies on FTS_XDEV to not cross file system boundaries,
> but FTS_XDEV visits the root of the other file system, causing
> 'du' to output a line "0 X" where X is the mount point of the
> other file system. This doesn't sound right, since X is in a
> different file system and du -x is supposed to ignore files in
> other file systems. Also, it disagrees with Solaris 10 du
> (at least).
>
> Here's a proposed patch. The bug is absent from coreutils 5.0
> and present in 5.2.0. I'm guessing from the NEWS files that
> it was introduced in 5.1.0 but 5.1.0 is no longer available
> at ftp.gnu.org so this isn't trivial for me to check.
>
> du: -x should not count files in other file systems
> * NEWS: Document fix.
> * src/du.c (process_file): Don't count files in different file
> systems if -x is given.
> * tests/du/one-file-system: Test for this bug.
Thanks for noticing/fixing that. The fix looks fine.
Please include in the commit log the SHA1 that probably induced the bug.
Also, a small improvement to the test script below:
> diff --git a/NEWS b/NEWS
...
> diff --git a/tests/du/one-file-system b/tests/du/one-file-system
...
> +# "du -xL" reported a zero count for a file in a different file system,
> +# instead of ignoring it.
> +du -xL d > u || fail=1
> +sed 's/^[0-9][0-9]* //' u > out1
> +cat <<\EOF > exp1 || fail=1
> +d
> +EOF
The three lines above can be replaced by this one:
echo d > exp1 || fail=1
> +compare exp1 out1 || fail=1
> +
> Exit $fail