Find microSD cards on Linux, through the mount table (#106) - #112
Merged
Conversation
`mounted_roots()` handled Windows and macOS and let Linux fall through to
the macOS branch, where `read_dir("/Volumes")` returns an error that
`unwrap_or_default()` threw away. On Linux the list was therefore always
empty: no card was ever detected, FT5D / ID-52 / TH-D75 were unusable, and
nothing said why. Reproduced on a real Linux box — the operator has to
navigate to the card by hand.
Linux has no `/Volumes` equivalent to guess at. udisks2 mounts under
`/media/<user>/<label>` on Debian and Ubuntu, `/run/media/<user>/<label>`
on Fedora and Arch, and a hand-mounted card is wherever the operator put
it — so read `/proc/mounts` and filter by filesystem instead. Every radio
here writes its card as FAT or exFAT and no Linux system volume is either;
the EFI system partition is the one vfat volume every UEFI machine has, so
/boot is dropped rather than offered as a card.
Mount points are octal-escaped by the kernel, so `MY CARD` arrives as
`MY\040CARD` and a path built from it verbatim would not exist. Unescaped
here, bytes-first so an accented label survives.
The three-way split is now explicit `#[cfg]` arms: a fourth platform fails
to build instead of silently inheriting whichever branch it lands in, which
is the whole mechanism of this bug.
The parser is compiled into the tests on every OS, so `cargo test` checks it
on the machines that do not have the bug.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013cZgbB4FwqZ3Z4cdHt6vMH
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.
Closes #106 — and it is no longer read-from-source: Tim reproduced it on a real Linux box, where the app detects no card and he has to navigate to it by hand.
The bug
mounted_roots()split two ways — Windows, or else — and Linux landed in theelse:/Volumesdoes not exist on Linux, so the list was always empty. It is the only source of card locations, so no microSD card was ever detected: FT5D, ID-52 and TH-D75 all unusable on a platform with published installers, with nothing indicating why. Cable radios were unaffected.The fix
Linux has no single directory to point at — udisks2 uses
/media/<user>/<label>on Debian/Ubuntu and/run/media/<user>/<label>on Fedora/Arch, and a hand-mounted card is wherever the operator put it. So instead of guessing at conventions, read/proc/mountsand filter by filesystem type: every radio here writes its card as FAT or exFAT, and no Linux system volume is either (fuseblkincluded, because exfat-fuse reports itself that way)./boot/efias a card on every Linux install.MY CARDarrives asMY\040CARDand a path built from it verbatim would not exist. Unescaped bytes-first so an accented label survives; a backslash that is not a valid escape is left alone rather than guessed at.#[cfg]arms, withcompile_error!for anything else. A fourth platform now fails to build rather than silently inheriting another OS's convention — that inheritance is this bug.Verification
npm run cigreen on macOS: 433 tests, clippy-D warningsclean./media/<user>,/run/media/<user>and a hand mount under/mnt;/,/proc,/sys, a tmpfs and/boot/efiare all rejected; malformed lines are skipped rather than half-parsed. The parser is compiled into the tests on every OS, so this is checked on the machines that do not have the bug.🤖 Generated with Claude Code
https://claude.ai/code/session_013cZgbB4FwqZ3Z4cdHt6vMH