Bug 277392 - eSATA drives not recognized as removable
Summary: eSATA drives not recognized as removable
Status: RESOLVED UPSTREAM
Alias: None
Product: solid
Classification: Frameworks and Libraries
Component: libsolid-udisks (show other bugs)
Version: unspecified
Platform: Debian testing Linux
: NOR normal
Target Milestone: ---
Assignee: Lukáš Tinkl
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-07-09 00:58 UTC by Ansgar
Modified: 2011-07-10 21:17 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ansgar 2011-07-09 00:58:19 UTC
Version:           unspecified (using KDE 4.6.3) 
OS:                Linux

The plasma Device Notifier does not show my eSATA drive as a removable device.

This is because the udisks backend for solid assumes only disks with "DriveCanDetach" are removed/added by the user[1].  The udisks reference manual seems to say that "DriveCanDetach" means something else, that is "TRUE only if the drive is capable of being detached by e.g. powering down the port it is connected to"[2].  This value is FALSE for my eSATA drive.

The correct value seems to be "DeviceIsSystemInternal"[3] which is already used by isRemovable as well, but it might be best to ask someone who knows more about udisks than me :)

[1] kdelibs/solid/solid/backends/udisks/udisksstoragedrive.cpp (isHotpluggable())
[2] http://hal.freedesktop.org/docs/udisks/Device.html#Device:DriveCanDetach
[3] http://hal.freedesktop.org/docs/udisks/Device.html#Device:DeviceIsSystemInternal

Reproducible: Always

Steps to Reproduce:
1. Make sure udisks 1.0.3 or newer is installed (for UDISKS_SYSTEM_INTERNAL).

2. Add udev rule to mark eSATA drive as not system-internal:
SUBSYSTEM=="block", SUBSYSTEMS=="pci", ATTRS{vendor}=="0x11ab", ATTRS{device}=="0x6121", \
  GROUP="floppy", ENV{UDISKS_SYSTEM_INTERNAL}="0"

3. Test that disk is really not marked system internal:
  $ udisks --show-info /dev/sdf | grep "system internal"

4. Notice that the Device Notifier does not show the disk.

Actual Results:  
Output from udisks:
  system internal:             0

Disk does not show up in Device Notifier (configured to show only removable disks).

Expected Results:  
Disk should show up in Device Notifier.

Workaround: Mark device as detachable in udev rule as well:

SUBSYSTEM=="block", SUBSYSTEMS=="pci", ATTRS{vendor}=="0x11ab", ATTRS{device}=="0x6121", \
  GROUP="floppy", ENV{UDISKS_SYSTEM_INTERNAL}="0", ENV{ID_DRIVE_DETACHABLE}="1"
Comment 1 Lamarque V. Souza 2011-07-10 15:07:26 UTC

*** This bug has been marked as a duplicate of bug 231312 ***
Comment 2 Ansgar 2011-07-10 18:01:49 UTC
This does not seem to be a duplicate. Bug 231312 was using HAL, this bug report is about the udisks backend.
Comment 3 Lamarque V. Souza 2011-07-10 18:05:36 UTC
Ok, but the solution is the same: it is not a KDE problem, it is udisks' problem.
Comment 4 Ansgar 2011-07-10 18:13:22 UTC
Having to set UDISKS_SYSTEM_INTERNAL is a bug (or missing feature) in udisks, but the solid backend has a bug as well:

"DriveIsDetachable" (from udisks) does not indicate a drive intended to be removed by the users (such as USB sticks or eSATA drives).  It only indicates that the bus can be powered down by the host (at least this is the only thing udisks does with this field, it can do this for USB ports so it is true for these media).

It is however a bug in KDE that it does not use DriveIsSystemInternal to display drives as user-removable (or hotpluggable is solid).
Comment 5 Lamarque V. Souza 2011-07-10 19:05:11 UTC
(In reply to comment #4)
> Having to set UDISKS_SYSTEM_INTERNAL is a bug (or missing feature) in udisks,
> but the solid backend has a bug as well:

Having to manually mark UDISKS_SYSTEM_INTERNAL to 0 for e-sata drives is the way udisks works because most e-sata controllers does not advertise the disks attached to them as removable. This is a upstream bug:

https://bugs.freedesktop.org/show_bug.cgi?id=22879
 
> "DriveIsDetachable" (from udisks) does not indicate a drive intended to be
> removed by the users (such as USB sticks or eSATA drives).  It only indicates
> that the bus can be powered down by the host (at least this is the only thing
> udisks does with this field, it can do this for USB ports so it is true for
> these media).

Solid already uses "DriveCanDetach" in UDisksStorageDrive::isHotpluggable() and "DeviceIsSystemInternal" in UDisksStorageDrive::isRemovable(). I do not see what is wrong with that, hotpluggable does not necessary means removable.
 
> It is however a bug in KDE that it does not use DriveIsSystemInternal to
> display drives as user-removable (or hotpluggable is solid).

Solid does use "DeviceIsSystemInternal". The problem is that udisks does not know when to set "DeviceIsSystemInternal" to 0 to indicate the drive is removable, so for safety it always set it to 1 for all e-sata drives. There is nothing Solid can do about this problem.
Comment 6 Lamarque V. Souza 2011-07-10 21:17:02 UTC
I did a test here. With udisks-1.0.3 and with this udev rule:

DEVPATH=="/devices/pci0000:00/0000:00:1f.2/host4/*",\
ENV{UDISKS_SYSTEM_INTERNAL}="0"

my e-sata HD is recognised as removable by Solid:

[lamarque@evolucao ~]$ solid-hardware details /org/freedesktop/UDisks/devices/sdb
udi = '/org/freedesktop/UDisks/devices/sdb'
  parent = '/org/freedesktop/UDisks'  (string)
  vendor = 'ATA'  (string)
  product = 'ST31500341AS'  (string)
  description = 'ATA ST31500341AS'  (string)
  Block.major = 8  (0x8)  (int)
  Block.minor = 16  (0x10)  (int)
  Block.device = '/dev/sdb'  (string)
  StorageDrive.bus = 'Ide'  (0x0)  (enum)
  StorageDrive.driveType = 'HardDisk'  (0x0)  (enum)
  StorageDrive.removable = true  (bool)
  StorageDrive.hotpluggable = false  (bool)
  StorageDrive.inUse = true  (bool)
  StorageDrive.size = 1500301910016  (0x15d50f66000)  (qulonglong)

The only thing wrong here is that it should have also been marked as hotpluggable... BY UDISKS. There is no sense in Solid marking it as hotpluggable  because that would only work for KDE programs. That must be done in udisks, so please fill a bug in bugs.freedesktop.org.

I will close this bug as upstream.