More on hotplug issue w/HAL

Matthew Mastracci matt at aclaro.com
Mon Jan 5 09:58:10 EET 2004


Okay, it looks like the reason for the block devices not appearing was
definitely the lack of a block.device entry in the HAL device (or, more
specifically, the "fixme-udev" entry).  I haven't tried the CVS version
but the quick hack seems to fix it.  I'm assuming both would have the
same result with different levels of code cleanliness.

With the day-old CVS version I have right now, the initial HAL
enumeration isn't picking up all of the sub-devices on the card reader. 
I have a feeling that this is the problem.  The block devices have the
SCSI interfaces as their parents.  In the initial scan, the "duplicate"
SCSI interfaces are eliminated.  I think this is because the bus
namespace specified in linux_class_scsi.c is "scsi_device" and no
scsi_device attributes exist.  

[I] linux/linux_class_scsi.c:267 visit_class_device_scsi_device() : For
path = /initrd/sys/class/scsi_device/24:0:0:2, looking for
parent_sysfs_path =
/initrd/sys/devices/pci0000:00/0000:00:02.0/usb2/2-1/2-1.4/2-1.4:1.0/host24
[I] linux/linux_class_scsi.c:293
visit_class_device_scsi_device_got_parent() : data2=0x00000000,
d=0x09a43f88, d->udi=/org/freedesktop/Hal/devices/temp/42,
parent->udi=/org/freedesktop/Hal/devices/scsi_host_usbif_usb_11b0_6787_5_-1_499234872420_0, parent->in_gdl=1, d->
[I] linux/linux_common.c:447 rename_and_merge() : Device
/org/freedesktop/Hal/devices/scsi_device_scsi_host_usbif_usb_11b0_6787_5_-1_499234872420_0 is plugged in again
[I] linux/linux_class_scsi.c:267 visit_class_device_scsi_device() : For
path = /initrd/sys/class/scsi_device/24:0:0:1, looking for
parent_sysfs_path =
/initrd/sys/devices/pci0000:00/0000:00:02.0/usb2/2-1/2-1.4/2-1.4:1.0/host24
[I] linux/linux_class_scsi.c:293
visit_class_device_scsi_device_got_parent() : data2=0x00000000,
d=0x09a451b8, d->udi=/org/freedesktop/Hal/devices/temp/43,
parent->udi=/org/freedesktop/Hal/devices/scsi_host_usbif_usb_11b0_6787_5_-1_499234872420_0, parent->in_gdl=1, d->
[I] linux/linux_common.c:447 rename_and_merge() : Device
/org/freedesktop/Hal/devices/scsi_device_scsi_host_usbif_usb_11b0_6787_5_-1_499234872420_0 is plugged in again
[I] linux/linux_class_scsi.c:267 visit_class_device_scsi_device() : For
path = /initrd/sys/class/scsi_device/24:0:0:0, looking for
parent_sysfs_path =
/initrd/sys/devices/pci0000:00/0000:00:02.0/usb2/2-1/2-1.4/2-1.4:1.0/host24
[I] linux/linux_class_scsi.c:293
visit_class_device_scsi_device_got_parent() : data2=0x00000000,
d=0x09a451b8, d->udi=/org/freedesktop/Hal/devices/temp/44,
parent->udi=/org/freedesktop/Hal/devices/scsi_host_usbif_usb_11b0_6787_5_-1_499234872420_0, parent->in_gdl=1, d->
[I] linux/linux_common.c:447 rename_and_merge() : Device
/org/freedesktop/Hal/devices/scsi_device_scsi_host_usbif_usb_11b0_6787_5_-1_499234872420_0 is plugged in again
[I] linux/linux_class_scsi.c:267 visit_class_device_scsi_device() : For
path = /initrd/sys/class/scsi_device/23:0:0:0, looking for
parent_sysfs_path =
/initrd/sys/devices/pci0000:00/0000:00:02.0/usb2/2-1/2-1.1/2-1.1:1.0/host23
[I] linux/linux_class_scsi.c:293
visit_class_device_scsi_device_got_parent() : data2=0x00000000,
d=0x09a451c8, d->udi=/org/freedesktop/Hal/devices/temp/45,
parent->udi=/org/freedesktop/Hal/devices/scsi_host_usbif_usb_5dc_80_1_-1_L331211418100315AA  0000000000000000000000000_0, parent->in_gdl=1, d->

The following changes to scsi_device_compute_udi and
visit_class_device_scsi_device fix this for me.  I've added the SCSI LUN
to the UDI and as a scsi_device bus property:

static char* scsi_device_compute_udi(HalDevice* d, int append_num)
{
    int i, len;
    const char* format;
    const char* pd;
    const char* name;
    static char buf[256];

    if( append_num==-1 )
!       format = "/org/freedesktop/Hal/devices/scsi_device_%s_%s";
    else
!       format = "/org/freedesktop/Hal/devices/scsi_device_%s_%s-%d";

    pd = ds_property_get_string(d, "info.parent");
    len = strlen(pd);
    for(i=len-1; pd[i]!='/' && i>=0; i--)
        ;
    name = pd+i+1;

    snprintf(buf, 256, format, 
+            ds_property_get_string(d, "scsi_device.lun"),
             name,
             append_num);
    
    return buf;
}

In visit_class_device_scsi_device:

---
    d = ds_device_new();
    ds_property_set_string(d, "info.bus", "scsi_device");
    ds_property_set_string(d, "linux.sysfs_path", path);
    ds_property_set_string(d, "linux.sysfs_path_device", 
                           class_device->sysdevice->path);
+   ds_property_set_string(d, "scsi_device.lun",
class_device->sysdevice->bus_id);
---

Some time tomorrow I'll do a clean CVS checkout and try things again
just to verify my hunch.  I'm pretty optimistic that it has fixed the
hotplug event problems I was having earlier.

Does CD-ROM media insertion notification work right now?  I'm itching to
get the card-reader notification to kick a new device node into the HAL
device list, but I need a place to start learning how that stuff works. 
:)

> You can actually see here that the devices are not added in order -
> that's why I need to have asynchronous find_parent functions which kind
> of complicates everything.

Once you've got an idea of what's going on, the code makes a lot of
sense in there.  :)

BTW, is the code for find_parent waiting for 30 seconds every time, or
is that just the maximum amount of time to wait if things are going
slowly?

> 
> Thanks for testing so far!

No prob!  This stuff will make my life *so* much easier.

-- 
Matthew Mastracci <matt at aclaro.com>




More information about the xdg mailing list