Skip to content

Detect USB floppy drives on Linux and fix media type handling#1005

Merged
mnadareski merged 7 commits into
SabreTools:masterfrom
gmipf:pr/7-linux-floppy-drives
Jul 2, 2026
Merged

Detect USB floppy drives on Linux and fix media type handling#1005
mnadareski merged 7 commits into
SabreTools:masterfrom
gmipf:pr/7-linux-floppy-drives

Conversation

@gmipf

@gmipf gmipf commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Summary

Reworks this PR into full USB floppy support for the Linux GUI, plus two related media-type fixes that the first change surfaced.

Changes

1. Detect USB floppy drives and always list floppies (d3e61e7d)
USB floppy drives enumerate as removable SCSI disks (/dev/sd*), not /dev/fd* nodes, so a removable block device whose media matches a standard floppy geometry (360 KB to 2.88 MB) is now classified as InternalDriveType.Floppy. Floppy drives are listed regardless of the fixed-drive toggle, alongside optical drives, so a USB floppy appears without also surfacing fixed disks. Classifying the drive as Floppy makes GetPhysicalMediaType return FloppyDisk, which satisfies the removable/floppy check in DumpEnvironment.ParametersValid. This mirrors how Windows tags floppy media via Win32_LogicalDisk.MediaType.

2. Fix media type dropdown not updating dumping parameters (08bec53b)
The media type ComboBox in both the Avalonia and WPF frontends bound SelectedItem to a CurrentMediaType property that was renamed to CurrentPhysicalMediaType in the RedumpLib 1.11 migration (a4c9ee6d), which updated the code-behind but not the XAML markup. The stale binding failed silently, so changing the media type never wrote back to the view model and the generated DiscImageCreator command was never refreshed (it stayed cd even when Floppy Disk was selected). Both bindings now point at CurrentPhysicalMediaType.

3. Reset detected media type when switching drives (f2dcebf1)
CacheCurrentMediaType only set _detectedPhysicalMediaType on a successful detection and never cleared it, so a type detected for one drive (e.g. FloppyDisk) carried over when switching to a drive whose media could not be read — an empty optical drive kept showing Floppy Disk instead of the system default. The remembered type is now cleared at the start of each drive's caching, so only a fresh detection sets it.

Testing

Tested end-to-end on Fedora with a NEC USB floppy drive (enumerated as /dev/sdh):

  • The USB floppy is detected and listed alongside optical drives, with fixed disks hidden.
  • The media type dropdown now switches the DiscImageCreator command live (fd and cd).
  • Selecting an optical or other drive no longer sticks on Floppy Disk.
  • An actual floppy dump was verified with Aaru (full read, 0 unreadable sectors, FAT12 detected).
  • For what it's worth: DiscImageCreator's fd command segfaults on Linux for this drive (it reads the SCSI inquiry, then crashes before dumping), so the dump was done with Aaru. That crash is a DiscImageCreator issue, separate from this PR — noting it since the media type dropdown targets DIC.

MPF.Frontend.Test: 558/558 pass, clean build (merged current master).

Note for packagers

Raw access to a USB floppy (a root:disk /dev/sd* block device) requires a udev rule granting the desktop user access, e.g.:

SUBSYSTEM=="block", ENV{ID_DRIVE_FLOPPY}=="1", GROUP="plugdev", MODE="0660"

This is a system-configuration matter outside MPF, but relevant if MPF is packaged for Linux.

Prepared with AI assistance (Claude Opus 4.8) and reviewed before submission.

gmipf and others added 6 commits July 1, 2026 22:16
Linux only surfaced optical and fixed/removable block devices, so floppy
drives were never offered as dump targets even though Aaru and
DiscImageCreator can dump them and Windows already tags floppies via WMI.

Add a dedicated floppy enumerator that scans /dev for "fd" followed by
digits (fd0, fd1, ...), tags each as InternalDriveType.Floppy, and lists it
like an optical drive with media presence left to the dumping program. It is
gated behind the fixed-drive toggle to match how Windows surfaces floppies.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
USB floppy drives enumerate as removable SCSI disks (/dev/sd*), not /dev/fd* nodes, so a removable block device whose media matches a standard floppy geometry (360 KB to 2.88 MB) is now classified as InternalDriveType.Floppy. Floppy drives are listed regardless of the fixed-drive toggle, alongside optical drives, so USB floppies appear without also surfacing fixed disks.

Classifying the drive as Floppy makes GetPhysicalMediaType return FloppyDisk, satisfying the removable/floppy check in DumpEnvironment.ParametersValid so DiscImageCreator dumps with fd. This mirrors how Windows tags floppy media via Win32_LogicalDisk.MediaType.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The media type ComboBox in both the Avalonia and WPF frontends bound SelectedItem to a CurrentMediaType property that was renamed to CurrentPhysicalMediaType in the RedumpLib 1.11 migration (a4c9ee6), which updated the code-behind but not the XAML markup. The stale binding failed silently, so changing the media type never wrote back to the view model and the generated DiscImageCreator command was never refreshed (it stayed cd even when Floppy Disk was selected). Point both bindings at CurrentPhysicalMediaType.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…rives

# Conflicts:
#	CHANGELIST.md
#	MPF.Avalonia/Windows/MainWindow.axaml
CacheCurrentMediaType only set _detectedPhysicalMediaType on a successful detection and never cleared it, so a type detected for one drive (e.g. FloppyDisk) carried over when switching to a drive whose media could not be read -- an empty optical drive would keep showing Floppy Disk instead of the system default (CD-ROM). Clear the remembered type at the start of each drive's caching so only a fresh detection sets it.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@gmipf gmipf changed the title Enumerate Linux floppy drives for dumping Detect USB floppy drives on Linux and fix media type handling Jul 2, 2026
if (CurrentDrive is null)
return;

// Forget the type detected for any previously selected drive; only a fresh

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, that actually makes a lot of sense. That probably explains a lot of weird interactions.

Comment thread MPF.Frontend/Drive.cs Outdated
</ComboBox>
<ComboBox x:Name="MediaTypeComboBox" Grid.Row="0" Grid.Column="1" Height="22" Width="140" HorizontalAlignment="Right"
ItemsSource="{Binding MediaTypes}" SelectedItem="{Binding Path=CurrentMediaType, Converter={StaticResource ElementConverter}, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
ItemsSource="{Binding MediaTypes}" SelectedItem="{Binding Path=CurrentPhysicalMediaType, Converter={StaticResource ElementConverter}, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, thank you!

Match Windows, where floppy drives enumerate as removable media that is
only queried when fixed drives are shown. The default program, Redumper,
does not support floppy dumping, so hiding floppies by default avoids
listing an unusable target for most users. Requested in review.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@mnadareski mnadareski merged commit f59e73c into SabreTools:master Jul 2, 2026
1 check passed
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.

2 participants