Hal feature request

David Zeuthen david at fubar.dk
Wed Mar 24 10:57:54 EET 2004


On Tue, Mar 23, 2004 at 06:43:59PM -0500, John McCutchan wrote:
> Hello,
> 
> I am wondering if Hal can provide a block device's (And USB block
> device's) serial# ? In order to make more intelligent decisions about
> removable media, I need to be able to get a unique identifier for a
> block device that will never change no matter where or when it is
> plugged in to the computer.
> 
> I tried emailing linux-kernel asking if sysfs exports this. The only
> response I got was that you can get an IDE drives serial number with
> hdparm -i /dev/hdX.
> 
> Is anyone working on this?
> 

I'm working on this :-). 

Basically, every block device in HAL got a property called 
block.storage_device which contains the UDI (unique device identifier) 
of the device that is the storage device (this is the device that
contains a lot of the interesting storage.* properties). 

Now, it is intended that the storage device for a set of related block
devices (e.g. /dev/sda, /dev/sda1, /dev/sda2) is the actual physical bus
device (marked with (*)) longer up in the device chain an

 USB device (*)
   USB interface  
     SCSI host device
       SCSI device
         Block device (/dev/sda) (#)
           Block device (/dev/sda1)
           Block device (/dev/sda2)

this device got a stable UDI using e.g. USB serial number if available 
and/or applicable. So, to conclude, you should be able to use the property
block.storage_device concatenated with block.major and block.minor numbers.
This will also be applicable for ieee1394, ide and other bus devices - USB
is just an example above.

The bad news is that this is not how it works today, I think the storage
device chosen today is the one marked with (#), but as I'm currently 
rewriting the linux backend it is easy to change. You might want to file a
bug in bugzilla.fd.o so this issue is not forgotten.

Another possibility, on Linux 2.6, is to use udev rules to make sure your
block device always got the same device file name.

Hope this helps.

David




More information about the xdg mailing list