Mercurial > hg > toybox
annotate 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 |
rev | line source |
---|---|
530 | 1 /* vi: set sw=4 ts=4: |
2 * | |
3 * mkfifo.c - Create FIFOs (named pipes) | |
4 * | |
5 * Copyright 2012 Georgi Chorbadzhiyski <georgi@unixsol.org> | |
6 * | |
7 * See http://pubs.opengroup.org/onlinepubs/009695399/utilities/mkfifo.html | |
8 * | |
9 * TODO: Add -m | |
10 | |
11 USE_MKFIFO(NEWTOY(mkfifo, "<1", TOYFLAG_BIN)) | |
12 | |
13 config MKFIFO | |
14 bool "mkfifo" | |
15 default y | |
16 help | |
17 usage: mkfifo [fifo_name...] | |
531
6fedb88874a4
Cleanups: use perror_msg() and make mode a global.
Rob Landley <rob@landley.net>
parents:
530
diff
changeset
|
18 |
530 | 19 Create FIFOs (named pipes). |
20 */ | |
21 | |
22 #include "toys.h" | |
23 | |
531
6fedb88874a4
Cleanups: use perror_msg() and make mode a global.
Rob Landley <rob@landley.net>
parents:
530
diff
changeset
|
24 DEFINE_GLOBALS( |
6fedb88874a4
Cleanups: use perror_msg() and make mode a global.
Rob Landley <rob@landley.net>
parents:
530
diff
changeset
|
25 long mode; |
6fedb88874a4
Cleanups: use perror_msg() and make mode a global.
Rob Landley <rob@landley.net>
parents:
530
diff
changeset
|
26 ) |
6fedb88874a4
Cleanups: use perror_msg() and make mode a global.
Rob Landley <rob@landley.net>
parents:
530
diff
changeset
|
27 |
6fedb88874a4
Cleanups: use perror_msg() and make mode a global.
Rob Landley <rob@landley.net>
parents:
530
diff
changeset
|
28 #define TT this.mkfifo |
6fedb88874a4
Cleanups: use perror_msg() and make mode a global.
Rob Landley <rob@landley.net>
parents:
530
diff
changeset
|
29 |
530 | 30 void mkfifo_main(void) |
31 { | |
32 char **s; | |
531
6fedb88874a4
Cleanups: use perror_msg() and make mode a global.
Rob Landley <rob@landley.net>
parents:
530
diff
changeset
|
33 |
6fedb88874a4
Cleanups: use perror_msg() and make mode a global.
Rob Landley <rob@landley.net>
parents:
530
diff
changeset
|
34 TT.mode = 0666; |
6fedb88874a4
Cleanups: use perror_msg() and make mode a global.
Rob Landley <rob@landley.net>
parents:
530
diff
changeset
|
35 |
530 | 36 for (s = toys.optargs; *s; s++) { |
531
6fedb88874a4
Cleanups: use perror_msg() and make mode a global.
Rob Landley <rob@landley.net>
parents:
530
diff
changeset
|
37 if (mknod(*s, S_IFIFO | TT.mode, 0) < 0) { |
6fedb88874a4
Cleanups: use perror_msg() and make mode a global.
Rob Landley <rob@landley.net>
parents:
530
diff
changeset
|
38 perror_msg("cannot create fifo '%s'", *s); |
530 | 39 toys.exitval = 1; |
40 } | |
41 } | |
42 } |