summaryrefslogtreecommitdiff
path: root/src/du.c
diff options
context:
space:
mode:
authorJim Meyering <meyering@redhat.com>2012-03-08 10:33:50 +0100
committerJim Meyering <meyering@redhat.com>2012-03-08 13:04:09 +0100
commitf7f398a1d91ca6b09e5282423711a7c785be2789 (patch)
tree0057a3c52fb5cf4369e861b0d6aa1238aecf3b5d /src/du.c
parentc1d07237a82a9eeebb6911c1ebb63957dac0c148 (diff)
downloadcoreutils-f7f398a1d91ca6b09e5282423711a7c785be2789.tar.gz
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.
Diffstat (limited to 'src/du.c')
-rw-r--r--src/du.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/du.c b/src/du.c
index e4e36dfea..41c953541 100644
--- a/src/du.c
+++ b/src/du.c
@@ -443,7 +443,14 @@ process_file (FTS *fts, FTSENT *ent)
return false;
}
- if (fts->fts_options & FTS_XDEV && fts->fts_dev != sb->st_dev)
+ /* The --one-file-system (-x) option cannot exclude anything
+ specified on the command-line. By definition, it can exclude
+ a file or directory only when its device number is different
+ from that of its just-processed parent directory, and du does
+ not process the parent of a command-line argument. */
+ if (fts->fts_options & FTS_XDEV
+ && FTS_ROOTLEVEL < ent->fts_level
+ && fts->fts_dev != sb->st_dev)
excluded = true;
}