Skip to content

fix: df: filter filesystem types after mount point resolution #7452

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 17, 2025

Conversation

SergeiPatiakin
Copy link
Contributor

@SergeiPatiakin SergeiPatiakin commented Mar 14, 2025

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

let mounts: Vec<MountInfo> = filter_mount_list(read_fs_list()?, opt)
before the mount point was determined at
match Filesystem::from_path(&mounts, path) {

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.

@sylvestre
Copy link
Contributor

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

@SergeiPatiakin
Copy link
Contributor Author

SergeiPatiakin commented Mar 14, 2025

@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.

Copy link

GNU testsuite comparison:

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

@SergeiPatiakin
Copy link
Contributor Author

SergeiPatiakin commented Mar 14, 2025

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

@sylvestre
Copy link
Contributor

sorry but could you please rebase the patch ? sorry again

@SergeiPatiakin SergeiPatiakin force-pushed the fix/issue-6194 branch 3 times, most recently from ba03926 to 8f22549 Compare March 27, 2025 10:05
Copy link

GNU testsuite comparison:

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

Copy link

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)

@SergeiPatiakin
Copy link
Contributor Author

@sylvestre done

@sylvestre sylvestre merged commit 4190fe2 into uutils:main Apr 17, 2025
68 checks passed
@sylvestre
Copy link
Contributor

thanks and sorry for the latency!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

df: test_type_option_with_file is failing on linux
2 participants