Enumerate fixed/removable drives on Linux and order the drive list#990
Merged
Conversation
Surface /dev block devices (sda, nvme0n1, ...) on Linux when IgnoreFixedDrives is off, mirroring the existing optical enumeration. Reads world-readable /sys/block (no elevated privileges); the removable flag selects HardDisk vs Removable, size comes from sysfs, and virtual devices (loop/ram/zram/dm-/md/sr/fd/nbd/zd) are skipped. Fixed disks are always active; removable drives are active only when media is present. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Replace the plain alphabetical sort with a display order that puts Linux optical block nodes (/dev/sr*) before their generic SCSI counterparts (/dev/sg*), and compares trailing indices numerically so sr2 sorts before sr10. Windows drive letters and fixed/removable device nodes keep a natural, digit-aware order. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
mnadareski
reviewed
Jun 23, 2026
mnadareski
left a comment
Member
There was a problem hiding this comment.
Some general comments before I can check into the logic.
- Sort the drive list with SabreTools.Text.Compare.NaturalComparer instead of a hand-rolled comparer. This drops the previous optical-first ranking, so the list is now plain natural order (e.g. /dev/sg* before /dev/sr*). - Guard the Unix append entry points with a PlatformID.Unix check. - Move the Linux enumeration helpers and the excluded-prefix field into a new partial class file, Drive.Linux.cs. - Extract UnixBlockDevice into its own file. - Add braces to the Win32NT branch and order the excluded-prefix list alphabetically with a comment per entry. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
mnadareski
approved these changes
Jun 24, 2026
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.
Two related improvements to the Linux drive list, building on #980 (sr/sg enumeration) and #981 (optical drives active).
What this PR does
1. Enumerate fixed and removable drives on Linux (gated)
On Windows the drive list includes fixed and removable drives when
IgnoreFixedDrivesis off; the Linux branch only added optical nodes, so it was more restrictive. This addsAppendUnixFixedDrives, which enumerates whole block devices from/sys/block(mirroring the optical enumerator) and honors the same existingOptions.GUI.IgnoreFixedDrivestoggle — no new option or UI.removableflag selectsHardDiskvsRemovable, size comes from sysfs.dm-,loop,md,nbd,ram,zd,zram), floppies (fd), and optical drives (sr, which are real targets but surfaced separately by the optical enumerator).DriveInfo.IsReadyon Windows).DriveInfo(which only exposes mount points like/, not dumpable device nodes). The Windows path is unchanged.2. Order the drive list
Sorts the list with
SabreTools.Text.Compare.NaturalComparerso device indices order numerically (e.g.sr2beforesr10) instead of lexically; Windows drive letters keep a natural, digit-aware order too.The Linux enumeration helpers live in a separate partial class (
Drive.Linux.cs), following the existingThemeService.Linux.cspattern, so a future macOS implementation can add its own counterpart.What this PR does not do
IgnoreFixedDrives).Tests
MPF.Frontend.Test/DriveTests.cs: hermetic tests (temp fake-sysfs trees, injected roots) for the optical and fixed/removable enumerators (sr/sg matching, excluded-prefix coverage, removable/size classification, missing-metadata fallback). No real devices touched. Built net20 through net10.0, all green.Prepared with AI assistance (Claude Opus 4.8) and reviewed before submission.