chiark / gitweb /
ata_id: Support SG_IO version 4 interface
authorDavid Zeuthen <davidz@redhat.com>
Sat, 30 Oct 2010 15:44:06 +0000 (11:44 -0400)
committerDavid Zeuthen <davidz@redhat.com>
Sat, 30 Oct 2010 17:03:00 +0000 (13:03 -0400)
commit6992637e3165d433353c996aad16c8d141b00845
tree737bfe85020d6bf251de935d8c2c4f3c1dd57eb2
parentd43e5e5b5a2e27fb75a6e19cca457ca40ad160e4
ata_id: Support SG_IO version 4 interface

This makes it possible to use /dev/bsg/* nodes for ata_id:

 # /lib/udev/ata_id --export /dev/bsg/0\:0\:0\:0
 ID_ATA=1
 ID_TYPE=disk
 ID_BUS=ata
 ID_MODEL=INTEL_SSDSA2MH080G1GC
 ID_MODEL_ENC=INTEL\x20SSDSA2MH080G1GC\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20
 ID_REVISION=045C8802
 [...]

This means that our cd-rom detection as per commit

 http://git.kernel.org/?p=linux/hotplug/udev.git;a=commit;h=160b069c25690bfb0c785994c7c3710289179107

needs to be reworked since we can't just use the CDROM_GET_CAPABILITY
ioctl on a /dev/bsg node (which is a character device). We do this by
just sending the SCSI INQUIRY command and checking the type (CD-ROM's
are all type 0x05 and disks are type 0x00) before we issue the ATA
IDENTIFY command through the SCSI command ATA PASS_THROUGH (12).

 (Yes, it's a bit perverse how we have to tunnel our ATA commands
 through a SCSI command  but that's how Linux currently work.)

We still support for SG_IO version 3 (we fail back if version 4 fails
with EINVAL) because testing reveals that some drivers (such as
mpt2sas) still only support version 3 on the block nodes.

Signed-off-by: David Zeuthen <davidz@redhat.com>
extras/ata_id/ata_id.c