ata_id.c revision cf0fbc49e67b55f8d346fc94de28c90113505297
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * ata_id - reads product/serial number from ATA drives
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Copyright (C) 2005-2008 Kay Sievers <kay@vrfy.org>
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Copyright (C) 2009 Lennart Poettering <lennart@poettering.net>
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Copyright (C) 2009-2010 David Zeuthen <zeuthen@gmail.com>
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * This program is free software: you can redistribute it and/or modify
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * it under the terms of the GNU General Public License as published by
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * the Free Software Foundation, either version 2 of the License, or
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * (at your option) any later version.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * This program is distributed in the hope that it will be useful,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * but WITHOUT ANY WARRANTY; without even the implied warranty of
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * GNU General Public License for more details.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * You should have received a copy of the GNU General Public License
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * along with this program. If not, see <http://www.gnu.org/licenses/>.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * INQUIRY, see SPC-4 section 6.4
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /* could be that the driver doesn't do version 4, try version 3 */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /* even if the ioctl succeeds, we need to check the return value */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /* even if the ioctl succeeds, we need to check the return value */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * ATA Pass-Through 12 byte command, as described in
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * T10 04-262r8 ATA Command Pass-Through
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * from http://www.t10.org/ftp/t10/document.04/04-262r8.pdf
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster [0] = 0xa1, /* OPERATION CODE: 12 byte pass through */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster [2] = 0x2e, /* OFF_LINE=0, CK_COND=1, T_DIR=1, BYT_BLOK=1, T_LENGTH=2 */
int ret;
if (ret != 0) {
if (ret != 0)
return ret;
return ret;
void *buf,
int ret;
if (ret != 0) {
if (ret != 0)
return ret;
return ret;
unsigned int offset_words,
char *dest,
unsigned int c1;
unsigned int c2;
while (dest_len > 0) {
dest++;
dest++;
offset_words++;
unsigned int offset_words,
uint16_t *p;
* @out_is_packet_device: Return location for whether returned data is from a IDENTIFY PACKET DEVICE.
int fd,
int *out_is_packet_device)
int ret;
int all_nul_bytes;
int is_packet_device = 0;
* the original bug-fix and see http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=556635
if (ret != 0)
goto out;
goto check_nul_bytes;
goto out;
if (ret != 0)
goto out;
all_nul_bytes = 0;
if (all_nul_bytes) {
goto out;
out:
return ret;
} identify;
int export = 0;
int is_packet_device = 0;
log_open();
int option;
switch (option) {
if (fd < 0) {
if (export) {
wwwn);