chiark / gitweb /
udev: switch to systemd logging functions
[elogind.git] / src / udev / ata_id / ata_id.c
index 4d30fd899468d3198ebcb31eb661f8594d835416..0d56f9b09d491c4cc8c410fa8e365166e329ebbd 100644 (file)
@@ -334,11 +334,10 @@ static int disk_identify(struct udev *udev,
         int peripheral_device_type;
         int all_nul_bytes;
         int n;
-        int is_packet_device;
+        int is_packet_device = 0;
 
         /* init results */
-        zero(out_identify);
-        is_packet_device = 0;
+        memzero(out_identify, 512);
 
         /* If we were to use ATA PASS_THROUGH (12) on an ATAPI device
          * we could accidentally blank media. This is because MMC's BLANK
@@ -402,17 +401,10 @@ static int disk_identify(struct udev *udev,
 
 out:
         if (out_is_packet_device != NULL)
-          *out_is_packet_device = is_packet_device;
+                *out_is_packet_device = is_packet_device;
         return ret;
 }
 
-static void log_fn(struct udev *udev, int priority,
-                   const char *file, int line, const char *fn,
-                   const char *format, va_list args)
-{
-        vsyslog(priority, format, args);
-}
-
 int main(int argc, char *argv[])
 {
         struct udev *udev;
@@ -435,13 +427,13 @@ int main(int argc, char *argv[])
                 {}
         };
 
+        log_parse_environment();
+        log_open();
+
         udev = udev_new();
         if (udev == NULL)
                 goto exit;
 
-        log_open();
-        udev_set_log_fn(udev, log_fn);
-
         while (1) {
                 int option;
 
@@ -463,14 +455,14 @@ int main(int argc, char *argv[])
 
         node = argv[optind];
         if (node == NULL) {
-                log_error("no node specified\n");
+                log_error("no node specified");
                 rc = 1;
                 goto exit;
         }
 
-        fd = open(node, O_RDONLY|O_NONBLOCK);
+        fd = open(node, O_RDONLY|O_NONBLOCK|O_CLOEXEC);
         if (fd < 0) {
-                log_error("unable to open '%s'\n", node);
+                log_error("unable to open '%s'", node);
                 rc = 1;
                 goto exit;
         }
@@ -502,7 +494,7 @@ int main(int argc, char *argv[])
         } else {
                 /* If this fails, then try HDIO_GET_IDENTITY */
                 if (ioctl(fd, HDIO_GET_IDENTITY, &id) != 0) {
-                        log_info("HDIO_GET_IDENTITY failed for '%s': %m\n", node);
+                        log_debug("HDIO_GET_IDENTITY failed for '%s': %m", node);
                         rc = 2;
                         goto close;
                 }