chiark / gitweb /
sd-rtnl: message - allow checking for attributes without reading out their contents
[elogind.git] / src / udev / collect / collect.c
index cb5df01c6a66c9269d16bda02e15f390b927d17d..90df360eb2b5ec110f1fc5e420250eb389072ca2 100644 (file)
@@ -86,16 +86,16 @@ static void usage(void)
  */
 static int prepare(char *dir, char *filename)
 {
-        struct stat statbuf;
         char buf[512];
-        int fd;
+        int r, fd;
 
-        if (stat(dir, &statbuf) < 0)
-                mkdir(dir, 0700);
+        r = mkdir(dir, 0700);
+        if (r < 0 && errno != EEXIST)
+                return -errno;
 
         snprintf(buf, sizeof(buf), "%s/%s", dir, filename);
 
-        fd = open(buf,O_RDWR|O_CREAT, S_IRUSR|S_IWUSR);
+        fd = open(buf,O_RDWR|O_CREAT|O_CLOEXEC, S_IRUSR|S_IWUSR);
         if (fd < 0)
                 fprintf(stderr, "Cannot open %s: %m\n", buf);
 
@@ -254,7 +254,7 @@ static void reject(char *us)
  * kickout
  *
  * Remove all IDs in the internal list which are not part
- * of the list passed via the commandline.
+ * of the list passed via the command line.
  */
 static void kickout(void)
 {