chiark / gitweb /
log: rearrange log function naming
[elogind.git] / src / udev / collect / collect.c
index 1346f27f91be55190f80ee6e5a0308eb47314082..90df360eb2b5ec110f1fc5e420250eb389072ca2 100644 (file)
@@ -61,7 +61,7 @@ static inline struct _mate *node_to_mate(struct udev_list_node *node)
         return container_of(node, struct _mate, node);
 }
 
-_noreturn_ static void sig_alrm(int signo)
+noreturn static void sig_alrm(int signo)
 {
         exit(4);
 }
@@ -86,18 +86,18 @@ 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: %s\n", buf, strerror(errno));
+                fprintf(stderr, "Cannot open %s: %m\n", buf);
 
         if (lockf(fd,F_TLOCK,0) < 0) {
                 if (debug)
@@ -109,7 +109,7 @@ static int prepare(char *dir, char *filename)
                                 fprintf(stderr, "Acquired lock on %s\n", buf);
                 } else {
                         if (debug)
-                                fprintf(stderr, "Could not get lock on %s: %s\n", buf, strerror(errno));
+                                fprintf(stderr, "Could not get lock on %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)
 {
@@ -404,7 +404,7 @@ int main(int argc, char **argv)
         us = argv[argi++];
 
         if (signal(SIGALRM, sig_alrm) == SIG_ERR) {
-                fprintf(stderr, "Cannot set SIGALRM: %s\n", strerror(errno));
+                fprintf(stderr, "Cannot set SIGALRM: %m\n");
                 ret = 2;
                 goto exit;
         }