How to find out that several devices belong to each other?

Fabian Steiner lists at fabis-site.net
Sat Jul 22 09:57:05 PDT 2006


Hi!

David Zeuthen wrote:
> Hi,
>
> Sorry for the lag,
>
>   
No problem, I was busy, too ;-)
> On Wed, 2006-07-12 at 20:29 +0200, Fabian Steiner wrote:
>   
>> Hello!
>>
>> First of all, I would like to point that I does not have many experience 
>> in using HAL/DBus so far. So please forgive me if this question sounds 
>> stupid:
>>
>> When I plug in a USB-Stick, `lshal --monitor` gives me the follwing output:
>>
>> usb_device_781_5150_SNDK13DDF52557207702 added
>> usb_device_781_5150_SNDK13DDF52557207702_if0 added
>> usb_device_781_5150_SNDK13DDF52557207702_usbraw added
>> usb_device_781_5150_SNDK13DDF52557207702_if0_scsi_host added
>> usb_device_781_5150_SNDK13DDF52557207702_if0_scsi_host_scsi_device_lun0 
>> added
>> usb_device_781_5150_SNDK13DDF52557207702_if0_scsi_host_scsi_device_lun0_scsi_generic 
>> added
>> storage_serial_SanDisk_Cruzer_Mini_SNDK13DDF52557207702 added
>> volume_uuid_3B69_1AFD added
>>
>> Obviously, more than device is created, but how can I find out that they 
>> all belong to the same physical device in fact. I need this information 
>> since I am currently working on a python application which depends on 
>> this thing.
>>     
>
> So, that sure is a lot of devices but I'm not really sure they're all
> interesting. For example, the SCSI host and SCSI device are
> implementation details of the usb-storage driver on Linux 2.6 and just
> provide glue. Oh, and if you use the 'ub' driver on Linux instead then
> there is no SCSI glue. Or if you run on Solaris or FreeBSD it may look
> different
>
> The interesting objects, however, are
>
>  usb_device_781_5150_SNDK13DDF52557207702
>  usb_device_781_5150_SNDK13DDF52557207702_if0 added
>  storage_serial_SanDisk_Cruzer_Mini_SNDK13DDF52557207702
>  volume_uuid_3B69_1AFD
>
> and the HAL spec guarantees you can get the relationship of these via
> the following properties:
>
>  block.storage_device
>  storage.physical_device
>
> and the fact that every USB interface is a child of the USB device (via
> info.parent; maybe we should have a usb.enclosing_device property).
>
> I don't really think the other objects are interesting at all? Maybe you
> can shed some light on what application you're building?
>
>   
In fact I am only interested in "volume_uuid_3B69_1AFD" since this a 
mountable device.  I take care of the other devices so that I can find 
out that "volume_uuid_3B69_1AFD" is some kind of grand-children of 
"usb_device_781_5150_SNDK13DDF52557207702" which is plugged into the usb 
hub (my program checks whether the parent.udi string of the latter 
device can be found in an internal list) of the keyboard which belongs 
to a certain display. Can I achieve the same result more easily? If yes, 
I wouldn't have to build an internal device tree.

As I have already described in another mail I am writing a programm that 
is able to mount usb sticks in an intelligent way: We have got a 
multiseat system here where several users a working on the same machine. 
Now we would like to get the usb sticks mounted automatically for the 
user who plugged in the stick. In order to achieve this aim we need to 
do serveral things:

- Whenever the signal "DeviceAdded" is received we check whether we are 
interested in that device (is it connected to a certain usb hub or is 
the child of a device that is connected to that hub), if not we don't 
care about it any longer.
- If it is a device we are interested in, we ensure that it is mountable 
volume and pass its udi as a parameter to pmount-hal.

I have been working on this project for two weeks now and it's even 
working as expected but far away from being complete.

Any advices and hints appreciated!

Cheers,
Fabian

P.S. If you or somebody else is interested in my current implementation 
have a look at http://fabis-site.net/tmp/DeviceManager.tar.gz (the main 
file is HALInterfaceDaemon.py in the DeviceManager directory)




More information about the hal mailing list