https://bugs.kde.org/show_bug.cgi?id=467751

            Bug ID: 467751
           Summary: Unmounting an SD card triggers a remount
    Classification: Frameworks and Libraries
           Product: frameworks-solid
           Version: 5.103.0
          Platform: Other
                OS: Linux
            Status: REPORTED
          Severity: normal
          Priority: NOR
         Component: general
          Assignee: unassigned-b...@kde.org
          Reporter: be...@igalia.com
                CC: kdelibs-b...@kde.org, lu...@kde.org
  Target Milestone: ---

SUMMARY
Unmounting an SD card results in it being re-mounted again if "automount on
attach is enabled".


STEPS TO REPRODUCE
1. Enable "Automount all known devices on attach" on the desktop settings.
2. Insert an SD card in the reader (can be reproduced on a VM). The volume
should be mounted automatically.
3. Click on "Safely remove" to unmount the volume.


OBSERVED RESULT
The volume is re-mounted again immediately.


EXPECTED RESULT
The volume remains unmounted.


SOFTWARE/OS VERSIONS
KDE Plasma Version: 5.27.2
KDE Frameworks Version: 5.103.0
Qt Version: 5.15.8


ADDITIONAL INFORMATION
Hi,

I'm unsure about whether this is an actual bug in KDE, UDisks, or not a bug at
all, so let me explain the situation.

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 (bug #402096, commit
https://github.com/KDE/solid/commit/6d260195cf75604d835235d2a1b02166ee8b514a).

The UDisks Eject command runs /usr/bin/eject under the hood, but this won't
actually eject the card from the reader, so it fails (I'm using a VM in this
example but the same happens with real hardware):

   $ busctl call org.freedesktop.UDisks2
/org/freedesktop/UDisks2/drives/QEMU__0xdeadbeef org.freedesktop.UDisks2.Drive
Eject 'a{sv}' 0
   Call failed: Error ejecting /dev/mmcblk0: Command-line `eject
'/dev/mmcblk0'' exited with non-zero exit status 1: eject: unable to eject

This results in the following udev events:

   UDEV  [9144.057110] remove  
/devices/pci0000:00/0000:00:04.0/mmc_host/mmc0/mmc0:4567/block/mmcblk0/mmcblk0p1
(block)
   UDEV  [9144.105960] change  
/devices/pci0000:00/0000:00:04.0/mmc_host/mmc0/mmc0:4567/block/mmcblk0 (block)
   UDEV  [9144.193215] add     
/devices/pci0000:00/0000:00:04.0/mmc_host/mmc0/mmc0:4567/block/mmcblk0/mmcblk0p1
(block)

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.

I also noticed that this does not happen in GNOME and this is due to a
workaround there: if a volume appears much later than the drive (as in this
case) then it is not mounted automatically:
https://gitlab.gnome.org/GNOME/gvfs/-/commit/b4800b987b4a8423a52306c9aef35b3777464cc5

So while doing something like this would be a possibility, is it maybe possible
to find a way to know whether the media in a certain drive is actually
ejectable, and not simply removable? Otherwise it seems that Solid should not
try to use eject based only on the "MediaRemovable" flag.

Opinions?

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to