Le 23/09/2014 16:46, Brice Goglin a écrit :
> Le 23/09/2014 16:38, Guy Streeter a écrit :
>> I know that udev gathers this information:
>>
>> # ll /sys/block/sda/bdi
>> lrwxrwxrwx. 1 root root 0 Sep 23 09:33 /sys/block/sda/bdi ->
>> ../../../../../../../../virtual/bdi/8:0
>> # grep SERIAL '/run/udev/data/b8:0'
>> E:ID_SERIAL=SAMSUNG_MZ7TD256HAFV-000L9_S17LNSADC13325
>> E:ID_SERIAL_SHORT=S17LNSADC13325
>>
>> So you could get it from udev or gather it the same way udev does. If you
>> want to know how udev does it, I can research that.
> If you can get more information, that'd be great. I wonder if they are
> using ioctls to retrieve these, I can't find anything in sysfs even
> though udev has similar info on my machines.
>

Indeed there's a struct hd_driveid in linux/hdreg.h that you get with
ioctl HDIO_GET_IDENTITY on the device.

There's also a libblkid that may help.

Brice

Reply via email to