aboutsummaryrefslogtreecommitdiff
path: root/coreutils/mkfifo.c
diff options
context:
space:
mode:
Diffstat (limited to 'coreutils/mkfifo.c')
-rw-r--r--coreutils/mkfifo.c64
1 files changed, 36 insertions, 28 deletions
diff --git a/coreutils/mkfifo.c b/coreutils/mkfifo.c
index 676592ac7..c74402d4c 100644
--- a/coreutils/mkfifo.c
+++ b/coreutils/mkfifo.c
@@ -1,3 +1,4 @@
1/* vi: set sw=4 ts=4: */
1/* 2/*
2 * Mini mkfifo implementation for busybox 3 * Mini mkfifo implementation for busybox
3 * 4 *
@@ -26,36 +27,43 @@
26#include <errno.h> 27#include <errno.h>
27 28
28static const char mkfifo_usage[] = "mkfifo [OPTIONS] name\n\n" 29static const char mkfifo_usage[] = "mkfifo [OPTIONS] name\n\n"
29"Create the named fifo\n\n" 30 "Create the named fifo\n\n"
30"Options:\n" 31
31"\t-m\tcreate the fifo with the specified mode; default = a=rw-umask\n"; 32 "Options:\n"
33 "\t-m\tcreate the fifo with the specified mode; default = a=rw-umask\n";
32 34
33extern int mkfifo_main(int argc, char **argv) 35extern int mkfifo_main(int argc, char **argv)
34{ 36{
35 char *thisarg; 37 char *thisarg;
36 mode_t mode = 0666; 38 mode_t mode = 0666;
37 argc--; 39
38 argv++; 40 argc--;
41 argv++;
39 42
40 /* Parse any options */ 43 /* Parse any options */
41 while (argc > 1) { 44 while (argc > 1) {
42 if (**argv != '-') usage(mkfifo_usage); 45 if (**argv != '-')
43 thisarg = *argv; thisarg++; 46 usage(mkfifo_usage);
44 switch (*thisarg) { 47 thisarg = *argv;
45 case 'm': 48 thisarg++;
46 argc--; argv++; 49 switch (*thisarg) {
47 parse_mode(*argv, &mode); 50 case 'm':
48 break; 51 argc--;
49 default: 52 argv++;
50 usage (mkfifo_usage); 53 parse_mode(*argv, &mode);
51 } 54 break;
52 argc--; argv++; 55 default:
53 } 56 usage(mkfifo_usage);
54 if (argc < 1) usage (mkfifo_usage); 57 }
55 if (mkfifo(*argv, mode) < 0) { 58 argc--;
56 perror("mkfifo"); 59 argv++;
57 exit(255); 60 }
58 } else { 61 if (argc < 1)
59 exit(TRUE); 62 usage(mkfifo_usage);
60 } 63 if (mkfifo(*argv, mode) < 0) {
64 perror("mkfifo");
65 exit(255);
66 } else {
67 exit(TRUE);
68 }
61} 69}