X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fudev%2Fcollect%2Fcollect.c;h=4bb6edbef11da04c35b3099b2a664e6e8f3fb4a3;hb=6cb8e687f038424ef54b5c5c3c433be974fbe371;hp=4ecb6b0d19158cefae5366febcb86e4d9edc8008;hpb=c8a202b7d47f9d6bba3100a208abdadfc383499e;p=elogind.git diff --git a/src/udev/collect/collect.c b/src/udev/collect/collect.c index 4ecb6b0d1..4bb6edbef 100644 --- a/src/udev/collect/collect.c +++ b/src/udev/collect/collect.c @@ -68,15 +68,19 @@ noreturn static void sig_alrm(int signo) static void usage(void) { - printf("usage: collect [--add|--remove] [--debug] \n" - "\n" + printf("%s [options] \n\n" + "Collect variables across events.\n\n" + " -h --help Print this message\n" + " -a --add Add ID to the list \n" + " -r --remove Remove ID from the list \n" + " -d --debug Debug to stderr\n\n" " Adds ID to the list governed by .\n" " must be part of the list .\n" " If all IDs given by are listed (ie collect has been\n" " invoked for each ID in ) collect returns 0, the\n" " number of missing IDs otherwise.\n" - " On error a negative number is returned.\n" - "\n"); + " On error a negative number is returned.\n\n" + , program_invocation_short_name); } /* @@ -86,12 +90,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 +157,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; @@ -254,7 +258,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) {