blob: ef58325b36b4d476ae54c18bb0ee29a454542766 [file] [log] [blame]
Erik Andersene49d5ec2000-02-08 19:58:47 +00001/* vi: set sw=4 ts=4: */
Eric Andersen19db07b1999-12-11 08:41:28 +00002/*
Manuel Novoa III cad53642003-03-19 09:13:01 +00003 * mkfifo implementation for busybox
Eric Andersen19db07b1999-12-11 08:41:28 +00004 *
Manuel Novoa III cad53642003-03-19 09:13:01 +00005 * Copyright (C) 2003 Manuel Novoa III <mjn3@codepoet.org>
Eric Andersen19db07b1999-12-11 08:41:28 +00006 *
Denys Vlasenko0ef64bd2010-08-16 20:14:46 +02007 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
Eric Andersen19db07b1999-12-11 08:41:28 +00008 */
9
Manuel Novoa III cad53642003-03-19 09:13:01 +000010/* BB_AUDIT SUSv3 compliant */
11/* http://www.opengroup.org/onlinepubs/007904975/utilities/mkfifo.html */
12
Pere Orga34425382011-03-31 14:43:25 +020013//usage:#define mkfifo_trivial_usage
14//usage: "[-m MODE] " IF_SELINUX("[-Z] ") "NAME"
15//usage:#define mkfifo_full_usage "\n\n"
16//usage: "Create named pipe\n"
Pere Orga34425382011-03-31 14:43:25 +020017//usage: "\n -m MODE Mode (default a=rw)"
18//usage: IF_SELINUX(
19//usage: "\n -Z Set security context"
20//usage: )
21
Denis Vlasenkob6adbf12007-05-26 19:00:18 +000022#include "libbb.h"
Manuel Novoa III cad53642003-03-19 09:13:01 +000023#include "libcoreutils/coreutils.h"
Eric Andersen19db07b1999-12-11 08:41:28 +000024
Dan Fandrich2d1a78b2010-09-30 14:31:12 -070025/* This is a NOEXEC applet. Be very careful! */
26
Denis Vlasenko9b49a5e2007-10-11 10:05:36 +000027int mkfifo_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
Denis Vlasenkoa60f84e2008-07-05 09:18:54 +000028int mkfifo_main(int argc UNUSED_PARAM, char **argv)
Eric Andersen19db07b1999-12-11 08:41:28 +000029{
Manuel Novoa III cad53642003-03-19 09:13:01 +000030 mode_t mode;
31 int retval = EXIT_SUCCESS;
Eric Andersen19db07b1999-12-11 08:41:28 +000032
Denis Vlasenko68404f12008-03-17 09:00:54 +000033 mode = getopt_mk_fifo_nod(argv);
Erik Andersene49d5ec2000-02-08 19:58:47 +000034
Denis Vlasenko99912ca2007-04-10 15:43:37 +000035 argv += optind;
36 if (!*argv) {
Manuel Novoa III cad53642003-03-19 09:13:01 +000037 bb_show_usage();
Erik Andersene49d5ec2000-02-08 19:58:47 +000038 }
Manuel Novoa III cad53642003-03-19 09:13:01 +000039
40 do {
41 if (mkfifo(*argv, mode) < 0) {
Denys Vlasenkoe4dcba12010-10-28 18:57:19 +020042 bb_simple_perror_msg(*argv); /* Avoid multibyte problems. */
Manuel Novoa III cad53642003-03-19 09:13:01 +000043 retval = EXIT_FAILURE;
44 }
45 } while (*++argv);
46
47 return retval;
Eric Andersen19db07b1999-12-11 08:41:28 +000048}