summaryrefslogtreecommitdiff
path: root/extras/ata_id/ata_id.c
AgeCommit message (Collapse)Author
2010-11-04Use ata_id, not scsi_id, on ATAPI devicesDavid Zeuthen
The major benefit here, is that we get the ATAPI device serial number. With SCSI ID we didn't get this since it's not part of the SCSI INQUIRY command. Specifically this means that we get symlinks to empty optical drives, e.g. /dev/disk/by-id/ata-VBOX_CD-ROM_VB2-01700376 which we didn't get earlier. So this is a major win. Also make ata_id work on CD-ROM devices when using /dev/bsg nodes so this works on both the scsi_device as well as the block device. We do this, basically, by issuing the ATA IDENTIFY PACKET DEVICE command instead of the ATA IDENTIFY command. We also use 16-byte pass-through ATA passthrough instead of 12-byte passthrough to avoid clashing with the MMC BLANK command. This means that we get this output # udevadm info -q all -p /sys/devices/pci0000:00/0000:00:01.1/host3/target3:0:0/3:0:0:0 P: /devices/pci0000:00/0000:00:01.1/host3/target3:0:0/3:0:0:0 E: UDEV_LOG=3 E: DEVPATH=/devices/pci0000:00/0000:00:01.1/host3/target3:0:0/3:0:0:0 E: DEVTYPE=scsi_device E: DRIVER=sr E: MODALIAS=scsi:t-0x05 E: SUBSYSTEM=scsi E: ID_ATA=1 E: ID_TYPE=cd E: ID_BUS=ata E: ID_MODEL=VBOX_CD-ROM E: ID_MODEL_ENC=VBOX\x20CD-ROM\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x 20\x20\x20\x20\x20\x20\x20 E: ID_REVISION=1.0 E: ID_SERIAL=VBOX_CD-ROM_VB2-01700376 E: ID_SERIAL_SHORT=VB2-01700376 instead of just # udevadm info -q all -p /sys/devices/pci0000:00/0000:00:01.1/host3/target3:0:0/3:0:0:0 P: /devices/pci0000:00/0000:00:01.1/host3/target3:0:0/3:0:0:0 E: UDEV_LOG=3 E: DEVPATH=/devices/pci0000:00/0000:00:01.1/host3/target3:0:0/3:0:0:0 E: DEVTYPE=scsi_device E: DRIVER=sr E: MODALIAS=scsi:t-0x05 E: SUBSYSTEM=scsi E: ID_SCSI=1 E: ID_VENDOR=VBOX E: ID_VENDOR_ENC=VBOX\x20\x20\x20\x20 E: ID_MODEL=CD-ROM E: ID_MODEL_ENC=CD-ROM\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20 E: ID_REVISION=1.0 E: ID_TYPE=cd Signed-off-by: David Zeuthen <davidz@redhat.com>
2010-10-30ata_id: Support SG_IO version 4 interfaceDavid Zeuthen
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>
2010-06-21remove a few comments in file headersKay Sievers
2009-12-04Export ID_WWN_VENDOR_EXTENSION and ID_WWN_WITH_EXTENSIONDavid Zeuthen
Some SCSI devices use the same WWN and have a WWN extension that we need to take into account when creating the /dev/disk/by-id/wwn symlinks. Thus, introduce ID_WWN_WITH_EXTENSION. This property will contain either the WWN (if no extension is present) or the WWN with the vendor extension appended. Example: # /lib/udev/ata_id/ata_id --export /dev/sda |grep WWN ID_WWN=0x5001517387d61905 ID_WWN_WITH_EXTENSION=0x5001517387d61905 # /lib/udev/scsi_id --whitelisted --export -d /dev/sdb |grep WWN ID_WWN=0x600508b400105df7 ID_WWN_VENDOR_EXTENSION=0x0000e00000d80000 ID_WWN_WITH_EXTENSION=0x600508b400105df70000e00000d80000 # /lib/udev/scsi_id --whitelisted --export -d /dev/sdc |grep WWN ID_WWN=0x600508b400105df7 ID_WWN_VENDOR_EXTENSION=0x0000e00000db0000 ID_WWN_WITH_EXTENSION=0x600508b400105df70000e00000db0000 Signed-off-by: David Zeuthen <davidz@redhat.com>
2009-11-20ata_id: skip ATA commands if we find an optical driveKay Sievers
Some drives are reported to erase CD-RW media with the ATA commands we send. Thanks to Christoph Stritt <phoenix@jobob.com> for his debugging. Original bug is here: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=556635
2009-11-04ata_id: export more advanced ATA featuresDavid Zeuthen
2009-06-28ata_id: sync ID_SERIAL(_SHORT) with other *_id toolsKay Sievers
ID_SERIAL is the full serial number used for the links, ID_SERIAL_SHORT is the device serial number.
2009-06-09move syslog wrapper to libudevKay Sievers
2009-02-17*_id: add model/vendor enc stringsDavid Zeuthen
So ID_MODEL and ID_VENDOR are pretty useful keys. However since we fix them up (removing leading/trailing whitespace, converts spaces to underscores) for use in device naming etc. we also force these fixups on the desktop shell. And this looks pretty ugly. The attached patch introduces the ID_MODEL_ENC and ID_VENDOR_ENC keys that contains the encoded version of the raw strings obtained. It's pretty similar in spirit to ID_FS_LABEL and its cousin ID_FS_LABEL_ENC. With this patch a desktop shell can fix up these strings as it sees fit. Note that some fixup is still needed though, for example # /lib/udev/ata_id --export /dev/sda |grep ID_MODEL 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 Note the trailing and leading whitespace. Anyway with the attached patch the desktop shell should be able to display "INTEL SSDSA2MH080G1GC" rather than "INTEL_SSDSA2MH080G1GC" to the user.
2009-01-06extras: fix mis-spelling of "environment"Adam Buchbinder
2008-11-20ata_id: make sure, we do not have slashes in valuesKay Sievers
2008-11-05unify string replacementKay Sievers
2008-10-02use no_argument, required_argument, optional_argument in longoptsKay Sievers
2008-09-10update file headersKay Sievers
2008-09-06use libudev code, unify logging, pass udev context around everywhereKay Sievers
2008-07-30use autotoolsKay Sievers
2008-04-20logging: add trailing newline to all stringsKay Sievers
2007-05-01ata_id: use getopt_long()Kay Sievers
2007-04-29ata_id: don't log error for libata devices on older kernelsMatthias Schwarzott
2006-01-09replace libsysfsKay Sievers
We never used any of the libsysfs convenience features. Here we replace it completely with 300 lines of code, which are much simpler and a bit faster cause udev(d) does not open any syfs file for a simple event which does not need any parent device information. Signed-off-by: Kay Sievers <kay.sievers@suse.de>
2005-09-27switch tools and volume_id from LGPL to GPLv2Kay Sievers
After beeing hit by proprietary applications which statically link the LGPL'd libusb, which needs a patch to reflect the recent kernel changes, I decided not to provide LGPL code anymore. Signed-off-by: Kay Sievers <kay.sievers@suse.de>
2005-09-16ata_id: open volume O_NONBLOCKKay Sievers
Opticals like that and should be ok for disks too, as long as we don't read(). Signed-off-by: Kay Sievers <kay.sievers@suse.de>
2005-08-22*_id: fix zero length in set_str()Kay Sievers
Thanks to Olaf Hering <olh@suse.de> Signed-off-by: Kay Sievers <kay.sievers@suse.de>
2005-08-01fix GGC signed pointer warnings and switch volume_id to stdintKay Sievers
Solaris uses volume_id now and they fiddled around with configure scripts to map the linux kernel int types. Adding the types locally to volume_id breaks the klibc build, so just switch to these ugly types and forget it. :) Signed-off-by: Kay Sievers <kay.sievers@suse.de>
2005-07-19add ID_BUS to *_id programsHannes Reinecke
2005-07-13trivial fixes for *_id programsKay Sievers
Signed-off-by: Kay Sievers <kay.sievers@suse.de>
2005-07-12ata_id: check for empty serial numberKay Sievers
Signed-off-by: Kay Sievers <kay.sievers@suse.de>
2005-06-27add ID_TYPE to the id probersKay Sievers
Export the type of device from ata_id and scsi_id, also strip leading and trailing whitespace and substitute consecutive whitespace with a single underline char. From: Hannes Reinecke <hare@suse.de> Signed-off-by: Kay Sievers <kay.sievers@suse.de>
2005-06-26rename udev_volume_id to vol_id and add --export optionKay Sievers
Signed-off-by: Kay Sievers <kay.sievers@suse.de>
2005-06-25add ata_id to read serial numbers from ATA drivesKay Sievers
Signed-off-by: Kay Sievers <kay.sievers@suse.de>