coreutils icon indicating copy to clipboard operation
coreutils copied to clipboard

fix: df: filter filesystem types after mount point resolution

Open SergeiPatiakin opened this issue 8 months ago • 4 comments

This PR fixes #6194 .

When df receives both a -t type filter and file paths, the mount point for each path must be determined before the filesystem type filter is applied.

The cause of this bug was that the filtering was applied at https://github.com/uutils/coreutils/blob/e147063e26c42647f9b3b6cf018ac5dfe11183da/src/uu/df/src/df.rs#L387 before the mount point was determined at https://github.com/uutils/coreutils/blob/e147063e26c42647f9b3b6cf018ac5dfe11183da/src/uu/df/src/df.rs#L403

This led to mount points being incorrectly determined for paths in some cases. For instance, on MacOS cargo run df -a -t apfs /dev would print the mount point at /. More examples are given in #6194

The fix was to re-order filtering and mount point resolution.

SergeiPatiakin avatar Mar 14 '25 21:03 SergeiPatiakin

Could you please add a test to make sure we don't regress? See https://github.com/uutils/coreutils/blob/main/tests/by-util/test_df.rs for example

sylvestre avatar Mar 14 '25 21:03 sylvestre

@sylvestre I have now added coverage by expanding an existing test, let me know what you think. I assumed that /dev has its own mount point with a different filesystem type to / - should be a safe assumption on Linux, macOS and I think Android.

SergeiPatiakin avatar Mar 14 '25 21:03 SergeiPatiakin

GNU testsuite comparison:

Skip an intermittent issue tests/timeout/timeout (fails in this run but passes in the 'main' branch)

github-actions[bot] avatar Mar 14 '25 22:03 github-actions[bot]

This may also fix issue #6073 which relates to nested mounts having different filesystem types

SergeiPatiakin avatar Mar 14 '25 23:03 SergeiPatiakin

sorry but could you please rebase the patch ? sorry again

sylvestre avatar Mar 26 '25 16:03 sylvestre

GNU testsuite comparison:

Skipping an intermittent issue tests/misc/stdbuf (passes in this run but fails in the 'main' branch)

github-actions[bot] avatar Mar 27 '25 10:03 github-actions[bot]

GNU testsuite comparison:

Skip an intermittent issue tests/misc/stdbuf (fails in this run but passes in the 'main' branch)
Skip an intermittent issue tests/timeout/timeout (fails in this run but passes in the 'main' branch)

github-actions[bot] avatar Mar 27 '25 15:03 github-actions[bot]

@sylvestre done

SergeiPatiakin avatar Mar 27 '25 15:03 SergeiPatiakin

thanks and sorry for the latency!

sylvestre avatar Apr 17 '25 20:04 sylvestre