Skip to content

solid-automounter: check partition attachment time matches drive

David Edmundson requested to merge work/d_ed/careful_auotmount into master

Currently unmounting certain SD cards can trigger an immediate remount when using "automount on attach" setting.

SD card readers have the "MediaRemovable" flag set in UDisks: https://github.com/storaged-project/udisks/blob/2.9.x-branch/src/udiskslinuxdrive.c#L368

This, according to the UDisks documentation, seems to only mean that "the media can be removed from the drive".

However, Solid uses that information to decide whether to eject the volume when the user tries to "Safely remove" the volume from the desktop. The "Ejectable" flag from UDisks was previously used for this purpose but it was discarded because it was considered broken (6d260195cf75604d835235d2a1b02166ee8b514a)

The UDisks Eject command runs /usr/bin/eject under the hood, but this won't actually eject the card from the reader. This causes udev to trigger remove and add events for the partitions.

Because of these remove+add events, if "Automount all known devices on attach" is set under the removable devices settings and you try to safely remove an SD card then the volume is immediately re-mounted again.

Solution is lifted from logic in Gnome which has a fix for a different use case - handling repartitioning, which sounds like logic we would want too.

BUG: 467751

Testing done:

  • set automount all to true
  • inserted SD card
  • unmounted all partitions with UI
  • checked via mount

Cherry-picking is potentially sane, but it would require ifdef guards on the newly exposed solid line.

As an aside I wish all bug reports were that good. It had a complete explanation and basically a link to the fix.

Edited by David Edmundson

Merge request reports