X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=extras%2Fata_id%2Fata_id.c;h=25c771012710faa3fe0a5262b8013b8e55d3d1ba;hp=66b9f42332858d717e30fd3c1baead3f792231d5;hb=d80f8ffd1a182fe7fff9816e8a4efc09e877964b;hpb=66094a4a7fc1d303e80785d586800eae9841502b diff --git a/extras/ata_id/ata_id.c b/extras/ata_id/ata_id.c index 66b9f4233..25c771012 100644 --- a/extras/ata_id/ata_id.c +++ b/extras/ata_id/ata_id.c @@ -1,4 +1,5 @@ -/* +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- + * * ata_id - reads product/serial number from ATA drives * * Copyright (C) 2005-2008 Kay Sievers @@ -38,6 +39,7 @@ #include #include #include +#include #include #include "libudev.h" @@ -210,6 +212,16 @@ static int disk_identify (struct udev *udev, goto fail; } + /* + * do not confuse optical drive firmware with ATA commands + * some drives are reported to blank CD-RWs + */ + if (ioctl(fd, CDROM_GET_CAPABILITY, NULL) >= 0) { + errno = EIO; + ret = -1; + goto fail; + } + /* So, it's a block device. Let's make sure the ioctls work */ if ((ret = ioctl(fd, BLKGETSIZE64, &size)) < 0) goto fail; @@ -509,6 +521,8 @@ int main(int argc, char *argv[]) wwwn <<= 16; wwwn |= *((uint16_t *) identify + 111); printf("ID_WWN=0x%llx\n", (unsigned long long int) wwwn); + /* ATA devices have no vendor extension */ + printf("ID_WWN_WITH_EXTENSION=0x%llx\n", (unsigned long long int) wwwn); } } else { if (serial[0] != '\0')