Skip to content

Detect Linux volumes from the mount table - #19

Open
owenpkent wants to merge 1 commit into
mainfrom
linux-drive-detection
Open

owenpkent wants to merge 1 commit into
mainfrom
linux-drive-detection

Conversation

@owenpkent

Copy link
Copy Markdown
Owner

Fixes drive detection on Linux, tested on this machine while getting offloader running here.

Problem

The Linux volume scan listed the children of /media. Ubuntu (and most distros using udisks) mounts removable media one level deeper, at /media/<user>/<LABEL>, so:

  • the real card never showed up in the drive panel
  • the empty /media/<user> directory itself was listed and badged as a removable drive
  • another user's leftover mount at /media/root showed up too, unreadable

Fix

_linux_volumes() now reads /proc/self/mountinfo directly: real mount points, actual filesystem type, and enough to filter out pseudo filesystems (tmpfs, overlay, gvfs, squashfs, ...), classify network and optical filesystems by type, and tell a removable device from a fixed one via sysfs rather than guessing from the path. The drive panel also now shows the filesystem type on Linux, matching what it already showed via GetVolumeInformationW on Windows.

Falls back to the previous /Volumes, /media, /mnt scan if /proc isn't available (some containers).

Windows and macOS paths are untouched.

Testing

  • Full suite passes: 406 passed, 8 skipped (skips are Windows-only long-path tests plus two needing external fixtures, unrelated to this change).
  • ruff check clean.
  • Added 5 tests against a sample mountinfo table covering: cards under /media/<user> and /run/media/<user>, octal-escaped mount points (spaces in labels), pseudo/system mounts excluded, and drive-type classification (fixed/removable/network/optical).
  • Ran an actual two-destination offload + verify end to end against synthetic card data on this machine; unaffected by this change but confirms the box is otherwise working.
  • No card or external drive was plugged in on this machine, so the new mountinfo path itself is covered by the mocked-table tests, not by real hardware.

Cards mount at /media/<user>/<LABEL> (or /run/media/<user>/<LABEL>) on
Linux, one level below where the drive scan looked. It listed the empty
/media/<user> directory itself instead, and an unreadable /media/root
where another user's session had left a mount, both badged as fake
removable drives, while the actual card never showed up.

Read /proc/self/mountinfo instead: it names real mount points, gives
the filesystem type (surfaced in the drive panel), and lets pseudo,
network and system filesystems be filtered by type rather than by
guessing from the path. Falls back to the old /Volumes,/media,/mnt
scan if /proc is unavailable (some containers).
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.

1 participant