blob: 4e0fca3ffc2a58f80144b130b9d4cd54d038efd4 [file] [log] [blame]
Rob Landley7aa651a2012-11-13 17:14:08 -06001/* mkfifo.c - Create FIFOs (named pipes)
Georgi Chorbadzhiyskif656fc92012-03-06 20:58:13 -06002 *
3 * Copyright 2012 Georgi Chorbadzhiyski <georgi@unixsol.org>
4 *
Rob Landleyf91b7c82012-08-25 18:08:51 -05005 * See http://opengroup.org/onlinepubs/9699919799/utilities/mkfifo.html
Georgi Chorbadzhiyskif656fc92012-03-06 20:58:13 -06006
Paul Barker1dd37042015-04-04 11:58:06 -05007USE_MKFIFO(NEWTOY(mkfifo, "<1m:", TOYFLAG_USR|TOYFLAG_BIN))
Georgi Chorbadzhiyskif656fc92012-03-06 20:58:13 -06008
9config MKFIFO
Rob Landley7aa651a2012-11-13 17:14:08 -060010 bool "mkfifo"
11 default y
12 help
13 usage: mkfifo [fifo_name...]
Georgi Chorbadzhiyskif656fc92012-03-06 20:58:13 -060014
Rob Landley7aa651a2012-11-13 17:14:08 -060015 Create FIFOs (named pipes).
Georgi Chorbadzhiyskif656fc92012-03-06 20:58:13 -060016*/
17
Rob Landleyc0e56ed2012-10-08 00:02:30 -050018#define FOR_mkfifo
Georgi Chorbadzhiyskif656fc92012-03-06 20:58:13 -060019#include "toys.h"
20
Rob Landleyc0e56ed2012-10-08 00:02:30 -050021GLOBALS(
Rob Landley7aa651a2012-11-13 17:14:08 -060022 char *m_string;
23 mode_t mode;
Rob Landleye430db22012-03-06 21:19:57 -060024)
25
Georgi Chorbadzhiyskif656fc92012-03-06 20:58:13 -060026void mkfifo_main(void)
27{
Rob Landley7aa651a2012-11-13 17:14:08 -060028 char **s;
Rob Landleye430db22012-03-06 21:19:57 -060029
Rob Landley7aa651a2012-11-13 17:14:08 -060030 TT.mode = 0666;
Felix Jandad0d0f402012-12-27 17:52:14 +010031 if (toys.optflags & FLAG_m) TT.mode = string_to_mode(TT.m_string, 0);
Rob Landleye430db22012-03-06 21:19:57 -060032
Rob Landley662a2672013-01-02 02:00:35 -060033 for (s = toys.optargs; *s; s++)
34 if (mknod(*s, S_IFIFO | TT.mode, 0) < 0) perror_msg("%s", *s);
Georgi Chorbadzhiyskif656fc92012-03-06 20:58:13 -060035}