Repository navigation
Share the disk engines' common loops - #28
Merged
Merged
Conversation
The udisks2 and Windows engines each carried the same bad-block test, read-back hash verification, blocking-risk check, boot-record start arithmetic, and the platform-neutral steps of Windows installer media (pre-write checks and layout, file copy with customization, copied-file verification). They now live once in engine.rs and reach the device through closures and buffers the engine supplies, so Windows keeps its sector-aligned buffers and Linux its page-cache drop. Behavior is unchanged: same patterns, chunk sizes, flush-before-read order, cancellation points, progress stages, and error messages. The older polkit helper path keeps its own verification (1 MiB sequential reads, a distinct short-read error) and uses the external badblocks tool. Tests cover the shared loops on an in-memory device. Co-Authored-By: Claude <noreply@anthropic.com>
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.
The udisks2 (Linux) and Windows disk engines each had their own copy of the same logic, so a fix in one could be missed in the other.
Now shared in
engine.rs:badblocks -wpatterns, write, flush, read back, count bad sectors);The shared code reaches the device only through closures and buffers the engine supplies. Windows keeps its sector-aligned buffers and volume locks; Linux keeps
sync_allplus the page-cache drop before reading back.Behavior is unchanged: same patterns, chunk sizes, flush-before-read order, cancellation points, progress stages and error messages.
Left separate on purpose:
verify_device_hashreads sequentially in 1 MiB chunks and has its own short-read error, and its bad-block test runs the externalbadblockstool.Verification:
cargo fmt --check,cargo test --workspaceon Windows (including 7 new tests of the shared loops on an in-memory device), andcargo clippy -D warningsfor both the Windows and Linux targets pass locally. The Linux engines run only in CI, and the elevated VHD tests were not run locally (this shell is not elevated); CI runs both.🤖 Generated with Claude Code