Mercurial > hg > toybox
comparison toys/mkfifo.c @ 531:6fedb88874a4
Cleanups: use perror_msg() and make mode a global.
author | Rob Landley <rob@landley.net> |
---|---|
date | Tue, 06 Mar 2012 21:19:57 -0600 |
parents | 6afff0596646 |
children | 2548e6e590b2 |
comparison
equal
deleted
inserted
replaced
530:6afff0596646 | 531:6fedb88874a4 |
---|---|
13 config MKFIFO | 13 config MKFIFO |
14 bool "mkfifo" | 14 bool "mkfifo" |
15 default y | 15 default y |
16 help | 16 help |
17 usage: mkfifo [fifo_name...] | 17 usage: mkfifo [fifo_name...] |
18 | |
18 Create FIFOs (named pipes). | 19 Create FIFOs (named pipes). |
19 | |
20 */ | 20 */ |
21 | 21 |
22 #include "toys.h" | 22 #include "toys.h" |
23 | 23 |
24 DEFINE_GLOBALS( | |
25 long mode; | |
26 ) | |
27 | |
28 #define TT this.mkfifo | |
29 | |
24 void mkfifo_main(void) | 30 void mkfifo_main(void) |
25 { | 31 { |
26 char **s; | 32 char **s; |
27 mode_t mode = 0666; | 33 |
34 TT.mode = 0666; | |
35 | |
28 for (s = toys.optargs; *s; s++) { | 36 for (s = toys.optargs; *s; s++) { |
29 if (mknod(*s, S_IFIFO | mode, 0) < 0) { | 37 if (mknod(*s, S_IFIFO | TT.mode, 0) < 0) { |
30 fprintf(stderr, "mkfifo: cannot create fifo `%s': %s\n", *s, strerror(errno)); | 38 perror_msg("cannot create fifo '%s'", *s); |
31 toys.exitval = 1; | 39 toys.exitval = 1; |
32 } | 40 } |
33 } | 41 } |
34 } | 42 } |