diff options
Diffstat (limited to 'coreutils/mkfifo.c')
-rw-r--r-- | coreutils/mkfifo.c | 53 |
1 files changed, 22 insertions, 31 deletions
diff --git a/coreutils/mkfifo.c b/coreutils/mkfifo.c index ca217fa23..77e0e6dd8 100644 --- a/coreutils/mkfifo.c +++ b/coreutils/mkfifo.c | |||
@@ -1,8 +1,8 @@ | |||
1 | /* vi: set sw=4 ts=4: */ | 1 | /* vi: set sw=4 ts=4: */ |
2 | /* | 2 | /* |
3 | * Mini mkfifo implementation for busybox | 3 | * mkfifo implementation for busybox |
4 | * | 4 | * |
5 | * Copyright (C) 1999 by Randolph Chung <tausq@debian.org> | 5 | * Copyright (C) 2003 Manuel Novoa III <mjn3@codepoet.org> |
6 | * | 6 | * |
7 | * This program is free software; you can redistribute it and/or modify | 7 | * This program is free software; you can redistribute it and/or modify |
8 | * it under the terms of the GNU General Public License as published by | 8 | * it under the terms of the GNU General Public License as published by |
@@ -20,41 +20,32 @@ | |||
20 | * | 20 | * |
21 | */ | 21 | */ |
22 | 22 | ||
23 | #include <stdio.h> | 23 | /* BB_AUDIT SUSv3 compliant */ |
24 | #include <sys/types.h> | 24 | /* http://www.opengroup.org/onlinepubs/007904975/utilities/mkfifo.html */ |
25 | #include <errno.h> | 25 | |
26 | #include <stdlib.h> | 26 | #include <stdlib.h> |
27 | #include <unistd.h> | ||
28 | #include <sys/types.h> | ||
27 | #include "busybox.h" | 29 | #include "busybox.h" |
30 | #include "libcoreutils/coreutils.h" | ||
28 | 31 | ||
29 | extern int mkfifo_main(int argc, char **argv) | 32 | extern int mkfifo_main(int argc, char **argv) |
30 | { | 33 | { |
31 | char *thisarg; | 34 | mode_t mode; |
32 | mode_t mode = 0666; | 35 | int retval = EXIT_SUCCESS; |
33 | 36 | ||
34 | argc--; | 37 | mode = getopt_mk_fifo_nod(argc, argv); |
35 | argv++; | ||
36 | 38 | ||
37 | /* Parse any options */ | 39 | if (!*(argv += optind)) { |
38 | while (argc > 1) { | 40 | bb_show_usage(); |
39 | if (**argv != '-') | ||
40 | show_usage(); | ||
41 | thisarg = *argv; | ||
42 | thisarg++; | ||
43 | switch (*thisarg) { | ||
44 | case 'm': | ||
45 | argc--; | ||
46 | argv++; | ||
47 | parse_mode(*argv, &mode); | ||
48 | break; | ||
49 | default: | ||
50 | show_usage(); | ||
51 | } | ||
52 | argc--; | ||
53 | argv++; | ||
54 | } | 41 | } |
55 | if (argc < 1 || *argv[0] == '-') | 42 | |
56 | show_usage(); | 43 | do { |
57 | if (mkfifo(*argv, mode) < 0) | 44 | if (mkfifo(*argv, mode) < 0) { |
58 | perror_msg_and_die("mkfifo"); | 45 | bb_perror_msg("%s", *argv); /* Avoid multibyte problems. */ |
59 | return EXIT_SUCCESS; | 46 | retval = EXIT_FAILURE; |
47 | } | ||
48 | } while (*++argv); | ||
49 | |||
50 | return retval; | ||
60 | } | 51 | } |