Hal feature request

Alexander Larsson alexl at redhat.com
Wed Mar 24 12:21:06 EET 2004


On Wed, 2004-03-24 at 09:57, David Zeuthen wrote:
> 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.

As posted by Linus on linux-kernel, major minor numbers are not
guaranteed to be stable over reboots:

http://seclists.org/lists/linux-kernel/2004/Jan/1000.html

Also, there are apparently some crappy usb devices with non-unique
serial numbers (although i think these are mostly mice and suchlike). At
least i've seen this being mentioned on linux-kernel.

Furthermore, since things like scsi ids, major minor, etc are not stable
over boots some filesystems have UUIDs stored on disk, so you always
have a unique identifier for them. I know ext2/3 has this, and
mount/mtab even allows mount-by-UUID. Using something like this it might
even be possible to have unique identifiers for the removable media in a
removable media device.


=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
 Alexander Larsson                                            Red Hat, Inc 
                   alexl at redhat.com    alla at lysator.liu.se 
He's a genetically engineered white trash astronaut gone bad. She's a 
warm-hearted foul-mouthed politician with the power to see death. They fight 
crime! 





More information about the xdg mailing list