GNU bug report logs -
#10293
[PATCH] du -x should not count files in other file systems
Previous Next
Reported by: Paul Eggert <eggert <at> cs.ucla.edu>
Date: Tue, 13 Dec 2011 19:23:01 UTC
Severity: normal
Tags: patch
Done: Paul Eggert <eggert <at> cs.ucla.edu>
Bug is archived. No further changes may be made.
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 10293 in the body.
You can then email your comments to 10293 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-coreutils <at> gnu.org
:
bug#10293
; Package
coreutils
.
(Tue, 13 Dec 2011 19:23:01 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Paul Eggert <eggert <at> cs.ucla.edu>
:
New bug report received and forwarded. Copy sent to
bug-coreutils <at> gnu.org
.
(Tue, 13 Dec 2011 19:23:01 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
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.
diff --git a/NEWS b/NEWS
index 0d4c83b..51c44c7 100644
--- a/NEWS
+++ b/NEWS
@@ -4,6 +4,9 @@ GNU coreutils NEWS -*- outline -*-
** Bug fixes
+ du -x no longer counts root directories of other file systems.
+ [bug introduced in coreutils-5.1.0]
+
ls --color many-entry-directory was uninterruptible for too long
[bug introduced in coreutils-5.2.1]
diff --git a/src/du.c b/src/du.c
index fba7f7d..a8dfd28 100644
--- a/src/du.c
+++ b/src/du.c
@@ -443,6 +443,9 @@ process_file (FTS *fts, FTSENT *ent)
error (0, ent->fts_errno, _("cannot access %s"), quote (file));
return false;
}
+
+ if (fts->fts_options & FTS_XDEV && fts->fts_dev != sb->st_dev)
+ excluded = true;
}
if (excluded
diff --git a/tests/du/one-file-system b/tests/du/one-file-system
index 7195838..2ec9865 100755
--- a/tests/du/one-file-system
+++ b/tests/du/one-file-system
@@ -1,6 +1,5 @@
#!/bin/sh
-# Test for a bug in fts's handling of FTS_XDEV, the flag behind
-# du's --one-file-system (-x) option.
+# Test for bugs in du's --one-file-system (-x) option.
# Copyright (C) 2006-2011 Free Software Foundation, Inc.
@@ -19,9 +18,11 @@
. "${srcdir=.}/init.sh"; path_prepend_ ../src
print_ver_ du
+cleanup_() { rm -rf "$other_partition_tmpdir"; }
+. "$abs_srcdir/other-fs-tmpdir"
-mkdir -p b/c y/z || framework_failure_
-
+mkdir -p b/c y/z d "$other_partition_tmpdir/x" || framework_failure_
+ln -s "$other_partition_tmpdir/x" d || framework_failure_
# Due to a used-uninitialized variable, the "du -x" from coreutils-6.6
# would not traverse into second and subsequent directories listed
@@ -37,4 +38,14 @@ EOF
compare exp out || fail=1
+# "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
+
+compare exp1 out1 || fail=1
+
Exit $fail
Information forwarded
to
bug-coreutils <at> gnu.org
:
bug#10293
; Package
coreutils
.
(Tue, 13 Dec 2011 20:00:02 GMT)
Full text and
rfc822 format available.
Message #8 received at 10293 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
On 12/13/2011 12:19 PM, Paul Eggert wrote:
> 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.
$ git log --pretty=oneline COREUTILS-5_0..COREUTILS-5_2_0 \
src/du.c | wc -l
29
only 29 commits to search from. You can also git bisect on a particular
file, if needed. But my guess is commit 95c948b06a, given the changelog
line:
(process_file, du_files): Rewrite to use fts.
which 'git describe' puts after 5.0.91 but before 5.1.0. I think your
guess was right. (And I spent more time on this email than I did on
searching git - such a change from the CVS days, where I have no idea
how long it would have taken to do the same sort of search for a culprit).
--
Eric Blake eblake <at> redhat.com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
[signature.asc (application/pgp-signature, attachment)]
Information forwarded
to
bug-coreutils <at> gnu.org
:
bug#10293
; Package
coreutils
.
(Wed, 14 Dec 2011 10:50:01 GMT)
Full text and
rfc822 format available.
Message #11 received at 10293 <at> debbugs.gnu.org (full text, mbox):
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
Reply sent
to
Paul Eggert <eggert <at> cs.ucla.edu>
:
You have taken responsibility.
(Thu, 15 Dec 2011 02:07:01 GMT)
Full text and
rfc822 format available.
Notification sent
to
Paul Eggert <eggert <at> cs.ucla.edu>
:
bug acknowledged by developer.
(Thu, 15 Dec 2011 02:07:01 GMT)
Full text and
rfc822 format available.
Message #16 received at 10293-done <at> debbugs.gnu.org (full text, mbox):
Thanks for the review; I pushed the patch with your suggestions.
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Thu, 12 Jan 2012 12:24:04 GMT)
Full text and
rfc822 format available.
This bug report was last modified 13 years and 214 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.