annotate toys/mkfifo.c @ 562:4d802d438983

Match uint64_t with PRIu64 to avoid warnings on 64 bit builds.
author Rob Landley <rob@landley.net>
date Sat, 14 Apr 2012 21:27:00 -0500
parents 2548e6e590b2
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
530
6afff0596646 Add mkfifo.
Georgi Chorbadzhiyski <gf@unixsol.org>
parents:
diff changeset
1 /* vi: set sw=4 ts=4:
6afff0596646 Add mkfifo.
Georgi Chorbadzhiyski <gf@unixsol.org>
parents:
diff changeset
2 *
6afff0596646 Add mkfifo.
Georgi Chorbadzhiyski <gf@unixsol.org>
parents:
diff changeset
3 * mkfifo.c - Create FIFOs (named pipes)
6afff0596646 Add mkfifo.
Georgi Chorbadzhiyski <gf@unixsol.org>
parents:
diff changeset
4 *
6afff0596646 Add mkfifo.
Georgi Chorbadzhiyski <gf@unixsol.org>
parents:
diff changeset
5 * Copyright 2012 Georgi Chorbadzhiyski <georgi@unixsol.org>
6afff0596646 Add mkfifo.
Georgi Chorbadzhiyski <gf@unixsol.org>
parents:
diff changeset
6 *
6afff0596646 Add mkfifo.
Georgi Chorbadzhiyski <gf@unixsol.org>
parents:
diff changeset
7 * See http://pubs.opengroup.org/onlinepubs/009695399/utilities/mkfifo.html
6afff0596646 Add mkfifo.
Georgi Chorbadzhiyski <gf@unixsol.org>
parents:
diff changeset
8 *
6afff0596646 Add mkfifo.
Georgi Chorbadzhiyski <gf@unixsol.org>
parents:
diff changeset
9 * TODO: Add -m
6afff0596646 Add mkfifo.
Georgi Chorbadzhiyski <gf@unixsol.org>
parents:
diff changeset
10
551
2548e6e590b2 Add string to mode_t parser
Daniel Walter <d.walter@0x90.at>
parents: 531
diff changeset
11 USE_MKFIFO(NEWTOY(mkfifo, "<1m:", TOYFLAG_BIN))
530
6afff0596646 Add mkfifo.
Georgi Chorbadzhiyski <gf@unixsol.org>
parents:
diff changeset
12
6afff0596646 Add mkfifo.
Georgi Chorbadzhiyski <gf@unixsol.org>
parents:
diff changeset
13 config MKFIFO
6afff0596646 Add mkfifo.
Georgi Chorbadzhiyski <gf@unixsol.org>
parents:
diff changeset
14 bool "mkfifo"
6afff0596646 Add mkfifo.
Georgi Chorbadzhiyski <gf@unixsol.org>
parents:
diff changeset
15 default y
6afff0596646 Add mkfifo.
Georgi Chorbadzhiyski <gf@unixsol.org>
parents:
diff changeset
16 help
6afff0596646 Add mkfifo.
Georgi Chorbadzhiyski <gf@unixsol.org>
parents:
diff changeset
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
6afff0596646 Add mkfifo.
Georgi Chorbadzhiyski <gf@unixsol.org>
parents:
diff changeset
19 Create FIFOs (named pipes).
6afff0596646 Add mkfifo.
Georgi Chorbadzhiyski <gf@unixsol.org>
parents:
diff changeset
20 */
6afff0596646 Add mkfifo.
Georgi Chorbadzhiyski <gf@unixsol.org>
parents:
diff changeset
21
6afff0596646 Add mkfifo.
Georgi Chorbadzhiyski <gf@unixsol.org>
parents:
diff changeset
22 #include "toys.h"
6afff0596646 Add mkfifo.
Georgi Chorbadzhiyski <gf@unixsol.org>
parents:
diff changeset
23
531
6fedb88874a4 Cleanups: use perror_msg() and make mode a global.
Rob Landley <rob@landley.net>
parents: 530
diff changeset
24 DEFINE_GLOBALS(
551
2548e6e590b2 Add string to mode_t parser
Daniel Walter <d.walter@0x90.at>
parents: 531
diff changeset
25 char *m_string;
2548e6e590b2 Add string to mode_t parser
Daniel Walter <d.walter@0x90.at>
parents: 531
diff changeset
26 mode_t mode;
531
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
6fedb88874a4 Cleanups: use perror_msg() and make mode a global.
Rob Landley <rob@landley.net>
parents: 530
diff changeset
29 #define TT this.mkfifo
551
2548e6e590b2 Add string to mode_t parser
Daniel Walter <d.walter@0x90.at>
parents: 531
diff changeset
30 #define FLAG_m (1)
531
6fedb88874a4 Cleanups: use perror_msg() and make mode a global.
Rob Landley <rob@landley.net>
parents: 530
diff changeset
31
530
6afff0596646 Add mkfifo.
Georgi Chorbadzhiyski <gf@unixsol.org>
parents:
diff changeset
32 void mkfifo_main(void)
6afff0596646 Add mkfifo.
Georgi Chorbadzhiyski <gf@unixsol.org>
parents:
diff changeset
33 {
6afff0596646 Add mkfifo.
Georgi Chorbadzhiyski <gf@unixsol.org>
parents:
diff changeset
34 char **s;
531
6fedb88874a4 Cleanups: use perror_msg() and make mode a global.
Rob Landley <rob@landley.net>
parents: 530
diff changeset
35
6fedb88874a4 Cleanups: use perror_msg() and make mode a global.
Rob Landley <rob@landley.net>
parents: 530
diff changeset
36 TT.mode = 0666;
551
2548e6e590b2 Add string to mode_t parser
Daniel Walter <d.walter@0x90.at>
parents: 531
diff changeset
37 if (toys.optflags & FLAG_m) {
2548e6e590b2 Add string to mode_t parser
Daniel Walter <d.walter@0x90.at>
parents: 531
diff changeset
38 TT.mode = string_to_mode(TT.m_string, 0);
2548e6e590b2 Add string to mode_t parser
Daniel Walter <d.walter@0x90.at>
parents: 531
diff changeset
39 }
531
6fedb88874a4 Cleanups: use perror_msg() and make mode a global.
Rob Landley <rob@landley.net>
parents: 530
diff changeset
40
530
6afff0596646 Add mkfifo.
Georgi Chorbadzhiyski <gf@unixsol.org>
parents:
diff changeset
41 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
42 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
43 perror_msg("cannot create fifo '%s'", *s);
530
6afff0596646 Add mkfifo.
Georgi Chorbadzhiyski <gf@unixsol.org>
parents:
diff changeset
44 toys.exitval = 1;
6afff0596646 Add mkfifo.
Georgi Chorbadzhiyski <gf@unixsol.org>
parents:
diff changeset
45 }
6afff0596646 Add mkfifo.
Georgi Chorbadzhiyski <gf@unixsol.org>
parents:
diff changeset
46 }
6afff0596646 Add mkfifo.
Georgi Chorbadzhiyski <gf@unixsol.org>
parents:
diff changeset
47 }