[PATCH] read drive serial number

David Zeuthen david at fubar.dk
Sun Aug 1 13:11:07 PDT 2004


On Sun, 2004-08-01 at 00:30 +0200, Kay Sievers wrote:
> Here is the code, that reads the serial number of a drive, directly
> connected to an ATA or SCSI bus. HAL probes for the values and adds:
> 
> 	storage.serial
> 	storage.firmware_version
> 	storage.revision
> 
> if available.
> 

Thanks Kay, this looks good; I've committed it. Sorry for the lag, btw.

> Note:
>   This will only work on native interfaces. For devices behind USB, it's
>   not possible to get any of these values. There are some bridges out there,
>   which are capable to set the USB-values itself, to the values from a ATA
>   Inquiry, but unfortunally, most of the bridges out there, don't do it.
>   "USB storage compliance" mandates a unique serial number, but most of the
>   vendors seems not to care about it.
> 
> I changed the compute_udi for block devices. If we get a serial number
> or a uuid we use it to compute the udi. 

I've added code such that if we don't get these we take the UDI of the
physical device backing the block device (using the string property
storage.physical_device) and append the SCSI LUN. However, this only
works if there is SCSI inbetween so we may fall back to major/minor
naming.

So, for my USB floppy drive I get (note that this particular device
hasn't got a USB serial number)

 /org/freedesktop/Hal/devices/block_usb_57b_0_601_-1_noserial-lun0

and for one of my 6in1 readers I get these (note the USB serial number)

 /org/freedesktop/Hal/devices/block_usb_424_20fc_129_-1_00005000806E-lun0
 /org/freedesktop/Hal/devices/block_usb_424_20fc_129_-1_00005000806E-lun1
 /org/freedesktop/Hal/devices/block_usb_424_20fc_129_-1_00005000806E-lun2
 /org/freedesktop/Hal/devices/block_usb_424_20fc_129_-1_00005000806E-lun3

which is kind of nice as it's very unique. 

At this point, I think the only case that remains to be solved are
volumes missing both label and UUID - this is especially true for e.g.
swap partitions. 

Cheers,
David

_______________________________________________
hal mailing list
hal at freedesktop.org
http://freedesktop.org/mailman/listinfo/hal



More information about the Hal mailing list