X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=src%2Fudev%2Fata_id%2Fata_id.c;h=be064187f8c995e255b43a7ca9507c84c29b3440;hp=846a73b5470bb4d2a860e4f58fcebe6848c2451e;hb=b49d9b50cfd377f28de0886330ba7bbd231fb472;hpb=3e2147858f21943d5f4a781c60f33ac22c6096ed diff --git a/src/udev/ata_id/ata_id.c b/src/udev/ata_id/ata_id.c index 846a73b54..be064187f 100644 --- a/src/udev/ata_id/ata_id.c +++ b/src/udev/ata_id/ata_id.c @@ -25,7 +25,6 @@ #include #include #include -#include #include #include #include @@ -44,6 +43,7 @@ #include "libudev.h" #include "libudev-private.h" +#include "log.h" #define COMMAND_TIMEOUT_MSEC (30 * 1000) @@ -302,10 +302,6 @@ static void disk_identify_get_string(uint8_t identify[512], unsigned int c1; unsigned int c2; - assert(identify != NULL); - assert(dest != NULL); - assert((dest_len & 1) == 0); - while (dest_len > 0) { c1 = identify[offset_words * 2 + 1]; c2 = identify[offset_words * 2]; @@ -363,10 +359,7 @@ static int disk_identify(struct udev *udev, int n; int is_packet_device; - assert(out_identify != NULL); - /* init results */ - ret = -1; memset(out_identify, '\0', 512); is_packet_device = 0; @@ -469,7 +462,7 @@ int main(int argc, char *argv[]) if (udev == NULL) goto exit; - udev_log_init("ata_id"); + log_open(); udev_set_log_fn(udev, log_fn); while (1) { @@ -493,14 +486,14 @@ int main(int argc, char *argv[]) node = argv[optind]; if (node == NULL) { - err(udev, "no node specified\n"); + log_error("no node specified\n"); rc = 1; goto exit; } fd = open(node, O_RDONLY|O_NONBLOCK); if (fd < 0) { - err(udev, "unable to open '%s'\n", node); + log_error("unable to open '%s'\n", node); rc = 1; goto exit; } @@ -510,29 +503,29 @@ int main(int argc, char *argv[]) * fix up only the fields from the IDENTIFY data that we are going to * use and copy it into the hd_driveid struct for convenience */ - disk_identify_fixup_string (identify, 10, 20); /* serial */ - disk_identify_fixup_string (identify, 23, 6); /* fwrev */ - disk_identify_fixup_string (identify, 27, 40); /* model */ - disk_identify_fixup_uint16 (identify, 0); /* configuration */ - disk_identify_fixup_uint16 (identify, 75); /* queue depth */ - disk_identify_fixup_uint16 (identify, 75); /* SATA capabilities */ - disk_identify_fixup_uint16 (identify, 82); /* command set supported */ - disk_identify_fixup_uint16 (identify, 83); /* command set supported */ - disk_identify_fixup_uint16 (identify, 84); /* command set supported */ - disk_identify_fixup_uint16 (identify, 85); /* command set supported */ - disk_identify_fixup_uint16 (identify, 86); /* command set supported */ - disk_identify_fixup_uint16 (identify, 87); /* command set supported */ - disk_identify_fixup_uint16 (identify, 89); /* time required for SECURITY ERASE UNIT */ - disk_identify_fixup_uint16 (identify, 90); /* time required for enhanced SECURITY ERASE UNIT */ - disk_identify_fixup_uint16 (identify, 91); /* current APM values */ - disk_identify_fixup_uint16 (identify, 94); /* current AAM value */ - disk_identify_fixup_uint16 (identify, 128); /* device lock function */ - disk_identify_fixup_uint16 (identify, 217); /* nominal media rotation rate */ + disk_identify_fixup_string(identify, 10, 20); /* serial */ + disk_identify_fixup_string(identify, 23, 6); /* fwrev */ + disk_identify_fixup_string(identify, 27, 40); /* model */ + disk_identify_fixup_uint16(identify, 0); /* configuration */ + disk_identify_fixup_uint16(identify, 75); /* queue depth */ + disk_identify_fixup_uint16(identify, 75); /* SATA capabilities */ + disk_identify_fixup_uint16(identify, 82); /* command set supported */ + disk_identify_fixup_uint16(identify, 83); /* command set supported */ + disk_identify_fixup_uint16(identify, 84); /* command set supported */ + disk_identify_fixup_uint16(identify, 85); /* command set supported */ + disk_identify_fixup_uint16(identify, 86); /* command set supported */ + disk_identify_fixup_uint16(identify, 87); /* command set supported */ + disk_identify_fixup_uint16(identify, 89); /* time required for SECURITY ERASE UNIT */ + disk_identify_fixup_uint16(identify, 90); /* time required for enhanced SECURITY ERASE UNIT */ + disk_identify_fixup_uint16(identify, 91); /* current APM values */ + disk_identify_fixup_uint16(identify, 94); /* current AAM value */ + disk_identify_fixup_uint16(identify, 128); /* device lock function */ + disk_identify_fixup_uint16(identify, 217); /* nominal media rotation rate */ memcpy(&id, identify, sizeof id); } else { /* If this fails, then try HDIO_GET_IDENTITY */ if (ioctl(fd, HDIO_GET_IDENTITY, &id) != 0) { - info(udev, "HDIO_GET_IDENTITY failed for '%s': %m\n", node); + log_info("HDIO_GET_IDENTITY failed for '%s': %m\n", node); rc = 2; goto close; } @@ -716,6 +709,6 @@ close: close(fd); exit: udev_unref(udev); - udev_log_close(); + log_close(); return rc; }