Commit 6d260195 authored by Stefan Brüns's avatar Stefan Brüns

[UDisks2] Use MediaRemovable to determine if media can be ejected

Summary:
The Ejectable property is mostly useless for card readers and thumb drives.
It directly exposes a flag from the kernel, e.g. /sys/block/sdX/removable,
which is the "removable bit" value from the SCSI INQUIRY response.

Unfortunately, most vendors get this wrong, i.e. many thumb drives have
the removable bit set, while some card readers have it cleared.

The MediaRemovable bit defaults to the same value, but can be overridden
by setting the ID_DRIVE_THUMB respectively ID_DRIVE_FLASH_{SD,CF,MS}
properties. UDisks ships a rules file with a large number of devices
already.

Bug: 402096

Test Plan:
Thumb drive - powered down
Card reader - ejected, stays powered
External hard driver - powered down

Reviewers: #frameworks, ngraham

Reviewed By: ngraham

Subscribers: kde-frameworks-devel

Tags: #frameworks

Differential Revision: https://phabricator.kde.org/D17910
parent 3aae548c
......@@ -185,7 +185,7 @@ void StorageAccess::slotDBusReply(const QDBusMessage & /*reply*/)
Device drive(drivePath);
QDBusConnection c = QDBusConnection::systemBus();
if (drive.prop("Ejectable").toBool() &&
if (drive.prop("MediaRemovable").toBool() &&
drive.prop("MediaAvailable").toBool() &&
!m_device->isOpticalDisc()) { // optical drives have their Eject method
QDBusMessage msg = QDBusMessage::createMethodCall(UD2_DBUS_SERVICE, drivePath, UD2_DBUS_INTERFACE_DRIVE, "Eject");
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment