Bug 35354

Summary: ENV{UDISKS_ATA_PORT_CONNECTOR_TYPE}="ata_sata_external" not working for eSATA drives
Product: udisks Reporter: freedesktopbugs.tbart
Component: generalAssignee: David Zeuthen (not reading bugmail) <zeuthen>
Status: RESOLVED INVALID QA Contact:
Severity: normal    
Priority: medium    
Version: unspecified   
Hardware: x86 (IA32)   
OS: Linux (All)   
Whiteboard:
i915 platform: i915 features:

Description freedesktopbugs.tbart 2011-03-16 06:06:36 UTC
As outlined in 80-udisks.rules:

# Set eSATA port type for known eSATA CardBus adapters - first we want to ensure
# the device is on a cardbus controller (upper PCI device) - then we check
# vid/pid (lower PCI device)
#
SUBSYSTEM=="scsi_host", ATTRS{class}=="0x060700", GOTO="ata_port_cardbus"
GOTO="ata_port_cardbus_end"
LABEL="ata_port_cardbus"
# Mass storage controller: Silicon Image, Inc. SiI 3512 [SATALink/SATARaid] Serial ATA Controller (rev 01) 
#
SUBSYSTEMS=="pci", ATTRS{vendor}=="0x1095", ATTRS{device}=="0x3512", ENV{UDISKS_ATA_PORT_CONNECTOR_TYPE}="ata_sata_external"
LABEL="ata_port_cardbus_end"


I try to do the same for a 0x1095 0x3132 SiI ExpressCard 2-Port eSATA card, but it does not work.
This wouldn't work anyhow as my card is no Cardbus card but an ExpressCard, which means the ATTRS{class}=="0x060700" must be set to ATTRS{class}=="0x060400".

This should be fixed as ExpressCard will be more common than Cardbus I guess. Both should therefor be supported.

The problem however remains.
This bug is very similar to https://bugs.freedesktop.org/show_bug.cgi?id=22879 as I am also unable to make e17/udisks see my eSATA disks as they're marked as system internal. The patch mentioned in bug #22879 does work for me.
I just wanted to report the above issue and also that (seemingly correctly) filling in my PCI ids does not change udisks behavior.

In udisks-1.0.2, I took a look into the sources and found src/port.c:

654   /* Third, guess the connector type.
655    *
656    * This can be overriden via the udev property UDISKS_ATA_PORT_CONNECTOR_TYPE -
657    * see the data/80-udisks.rules for an example.
658    */
659   connector_type = g_udev_device_get_property (port->priv->d, "UDISKS_ATA_PORT_CONNECTOR_TYPE");
660   if (connector_type == NULL)
661     {
662       connector_type = "ata";
663       adapter_fabric = adapter_local_get_fabric (adapter);
664       if (g_strcmp0 (adapter_fabric, "ata_pata") == 0)
665         {
666           connector_type = "ata_pata";
667         }
668       else if (g_strcmp0 (adapter_fabric, "ata_sata") == 0)
669         {
670           connector_type = "ata_sata";
671         }
672     }

but it seems to me this "connector_type" never gets used for determining whether a device should be system internal or not.

Therefor, I tried to do the following in src/device.c:

3952   /* devices on certain buses are never system internal */
 3953 //if (device->priv->device_is_drive && device->priv->drive_connection_interface != NULL)
 3954 if (device->priv->device_is_drive)
 3955   {
 3956     if (device->priv->drive_connection_interface != NULL)
 3957     {
 3958       if (strcmp (device->priv->drive_connection_interface, "ata_serial_esata") == 0
 3959           || strcmp (device->priv->drive_connection_interface, "sdio") == 0
 3960           || strcmp (device->priv->drive_connection_interface, "usb") == 0
 3961           || strcmp (device->priv->drive_connection_interface, "firewire") == 0)
 3962         {
 3963           is_system_internal = FALSE;
 3964         }
 3965       else
 3966         {
 3967           is_system_internal = TRUE;
 3968         }
 3969     }
 3970     if (port->priv->d->connector_type != NULL)
 3971     {
 3972       /* this can be set like in 80-udisks.rules: ENV{UDISKS_ATA_PORT_CONNECTOR_TYPE}="ata_sata_external" */
 3973       if (strcmp (port->priv->d->connector_type, "ata_sata_external") == 0)
 3974         {
 3975           is_system_internal = FALSE;
 3976         }
 3977     }
 3978       goto determined;
 3979   }

but the port object is not accessible from within device.c and
a) my C skills somewhat end here (what a shame...) and
b) I don't know if you wanted me to pull in a reference to port at all as I don't know anything about the design philosophy behind udisks.

It however seems to me that connector_type should somewhere be used to set system internal to 0 if it is set to ata_sata_external via udev's UDISKS_ATA_PORT_CONNECTOR_TYPE variable. Currently, only device properties and no _port_ properties are used to determine that.

I hope this was precise enough and I am very sorry my C isn't any better.
I'd really like to fix this myself...

PS: Ah.. If that matters: the disk connected is a naked SATA disk plugged into the eSATA controller. So the kernel and/or udisks can't be put to blame if they do not detect the disk as being external, and I totally understand that I have to customize my setup a little if I want this to work. However, I still think drives connected to a controller with eSATA ports have to be system internal = 0. I can't determine whether my controller advertises having _e_SATA ports and willing to test this if you give me a clue. Still, this should be overridable on a controller or better yet port basis. I have another PC that has eSATA ports connected to 2 of its 6 internal SATA ports - also non-standard, I know, but that's how a lot of people do it - the bracket has already been in the original mobo package after all!
Comment 1 David Zeuthen (not reading bugmail) 2012-09-28 15:54:12 UTC
In udisks 2.0, we no longer attempt to make a distinction between SATA and eSATA (or attempt to deal with ports or HBAs) so this bug is no longer relevant.

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.