diff --git a/src/du.c b/src/du.c index e4e36df..41c9535 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; } diff --git a/tests/du/one-file-system b/tests/du/one-file-system index f0d264a..110080f 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 v0.9.0.2