Repository navigation
Fix -x / --limit-filesystem on Windows - #653
Merged
bootandy merged 1 commit intoNov 19, 2026
Merged
Conversation
The cheap Windows metadata path never returns a volume serial, so the allowed filesystem set was always empty and -x did nothing. With -L, dust followed junctions and symlinks onto other volumes. Read the volume serial with a handle for the target dirs and for followed links, the only entries that can lead to another volume.
Owner
|
thanks, I dont have a windows system, so i cant check. But it seems to make sense |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
On Windows
-x/--limit-filesystemdoes nothing.get_filesystem_devicestakes the device fromget_metadata, but the cheap Windows path returnsNonefor the inode/device of plain files and directories. Soallowed_filesystemsends up empty and the check inignore_filenever runs. Entries inside the walk have no device either, so the check could not fire even with a non-empty set.You notice this with
-L. A junction onC:that points intoT:is still followed with-L -x:Fix:
platform::get_volume_serialon Windows. It opens a handle with onlyFILE_READ_ATTRIBUTES(plusFILE_FLAG_BACKUP_SEMANTICSso directories open) and reads the volume serial.get_filesystem_devicesuses it for the target dirs.ignore_fileit is used only for followed links (symlink, junction, mounted folder), since those are the only entries that can lead to another volume. Plain files and dirs keep the cheap path, so there is no extra cost unless-L -xis used.Tested on Windows 10:
cargo test: all pass.cargo clippy -- -D warningsis clean for the crate.--all-targetsreportsempty_line_after_doc_commentsintests/test_flags.rsandtests/test_exact_output.rs, which is already on master.C:holding one junction intoT:and one junction into the same dir:-L -xnow drops theT:junction and keeps the same-volume one.-Lalone lists both, as before.-xon a plain dir gives the same output as before.Not tested: symlinks (creating them needs admin here), mounted-folder volumes, and Linux/macOS. The non-Windows code path is unchanged apart from a moved
use.