Getting UDI information after a device has been removed

Marko Anastasov marko at
Thu Mar 2 14:21:12 PST 2006

When a device is removed, you can read its' udi, but obviously
you can't use that udi to query hal about the device which was
behind it:

static void
on_hal_device_removed(LibHalContext* ctx, const char* udi)
{ ... }

Besides using LibHalPropertySet, you can create a struct (I assume
you're writing this in C) holding the device information you're
interested in, which you can retrieve in on_hal_device_added().
You would probably first store the device's LibHalvolume* and
LibHalDrive*, then eg call libhal_drive_get_vendor/model(),
libhal_volume_get_label() etc. So when a device is removed, you
look up in a list by udi if it's a device you're watching.


У среду, 01. 03 2006. 19:53 -0500, Danny Budik пише:
> Hi all again,
> I am wondering if it's possible to obtain UDI information about a device 
> that I just removed. For example, I have an Ipod plugged in. When I 
> remove it, I want to verify that it's an Ipod by reading the 
> vendor/product IDs.
> I can get this information when I plug in a device, using 
> libhal_device_get_property_xxx(). When I tried to use that function 
> inside the hal_device_removed callback the error is:
> No device with id 
> /org/freedesktop/Hal/devices/usb_device_547_1002_noserial_if0: Resource 
> temporarily unavailable
> which makes sense. I removed the device, so why should it have a UDI 
> entry. But I still want to figure out that info.
> Thanks.

More information about the hal mailing list