From f7f398a1d91ca6b09e5282423711a7c785be2789 Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Thu, 8 Mar 2012 10:33:50 +0100 Subject: du: fix -x: don't ignore non-directory arguments Surprise! "du -x non-DIR" would print nothing. Note that the problem arises only when processing a non-directory specified on the command line. Not surprisingly, "du -x" still works as expected for any directory argument. When performing its same-file-system check, du may skip an entry only if it is at fts_level 1 or greater. Command-line arguments are at fts_level == 0 (FTS_ROOTLEVEL). * src/du.c (process_file): Don't use the top-level FTS->fts_dev when testing for --one-file-system (-x). It happens to be valid for directories, but it is always 0 for a non-directory. * tests/du/one-file-system: Add tests for this. * NEWS (Bug fixes): Mention it. Reported by Daniel Stavrovski in http://bugs.gnu.org/10967. Introduced by commit v8.14-95-gcfe1040. --- tests/du/one-file-system | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/du/one-file-system b/tests/du/one-file-system index f0d264ae2..110080f02 100755 --- a/tests/du/one-file-system +++ b/tests/du/one-file-system @@ -43,7 +43,15 @@ compare exp out || fail=1 du -xL d > u || fail=1 sed 's/^[0-9][0-9]* //' u > out1 echo d > exp1 || fail=1 - compare exp1 out1 || fail=1 +# With coreutils-8.15, "du -xs FILE" would print no output. +touch f +for opt in -x -xs; do + du $opt f > u || fail=1 + sed 's/^[0-9][0-9]* //' u > out2 + echo f > exp2 || fail=1 + compare exp2 out2 || fail=1 +done + Exit $fail -- cgit v1.2.3-54-g00ecf