chiark / gitweb /
systemd-hwdb: introduce new tool
[elogind.git] / src / udev / collect / collect.c
index dc849bd0f00839340038902de73bd67fb5f47d5e..16675fbe0e0feab01eadfd16dfc6a3535407f8f8 100644 (file)
@@ -86,12 +86,12 @@ 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);
 
@@ -153,7 +153,7 @@ static int checkout(int fd)
                         if (!ptr && word < (buf + len)) {
                                 bufsize = bufsize << 1;
                                 if (debug)
-                                        fprintf(stderr, "ID overflow, restarting with size %zi\n", bufsize);
+                                        fprintf(stderr, "ID overflow, restarting with size %zu\n", bufsize);
                                 free(buf);
                                 lseek(fd, 0, SEEK_SET);
                                 goto restart;