chiark / gitweb /
util: unify how we see srand()
[elogind.git] / src / udev / scsi_id / scsi_serial.c
index 2f2afcee6edfea097b8ba9ada823be2c605708c5..933867159118162287138c9ea1ea2c1be3d6d50c 100644 (file)
@@ -26,7 +26,6 @@
 #include <fcntl.h>
 #include <stdlib.h>
 #include <unistd.h>
-#include <syslog.h>
 #include <time.h>
 #include <inttypes.h>
 #include <scsi/scsi.h>
@@ -818,7 +817,7 @@ int scsi_std_inquiry(struct udev *udev,
         struct stat statbuf;
         int err = 0;
 
-        fd = open(devname, O_RDONLY | O_NONBLOCK);
+        fd = open(devname, O_RDONLY | O_NONBLOCK | O_CLOEXEC);
         if (fd < 0) {
                 log_debug("scsi_id: cannot open %s: %m", devname);
                 return 1;
@@ -862,11 +861,11 @@ int scsi_get_serial(struct udev *udev,
         int retval;
 
         memzero(dev_scsi->serial, len);
-        srand((unsigned int)getpid());
+        initialize_srand();
         for (cnt = 20; cnt > 0; cnt--) {
                 struct timespec duration;
 
-                fd = open(devname, O_RDONLY | O_NONBLOCK);
+                fd = open(devname, O_RDONLY | O_NONBLOCK | O_CLOEXEC);
                 if (fd >= 0 || errno != EBUSY)
                         break;
                 duration.tv_sec = 0;