blob: 4388ccaa3d6ab53b328130ded01f976a7731c3e9 [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
Denis Vlasenkob6adbf12007-05-26 19:00:18 +000013#include "libbb.h"
Manuel Novoa III cad53642003-03-19 09:13:01 +000014#include "libcoreutils/coreutils.h"
Eric Andersen19db07b1999-12-11 08:41:28 +000015
Dan Fandrich2d1a78b2010-09-30 14:31:12 -070016/* This is a NOEXEC applet. Be very careful! */
17
Denis Vlasenko9b49a5e2007-10-11 10:05:36 +000018int mkfifo_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
Denis Vlasenkoa60f84e2008-07-05 09:18:54 +000019int mkfifo_main(int argc UNUSED_PARAM, char **argv)
Eric Andersen19db07b1999-12-11 08:41:28 +000020{
Manuel Novoa III cad53642003-03-19 09:13:01 +000021 mode_t mode;
22 int retval = EXIT_SUCCESS;
Eric Andersen19db07b1999-12-11 08:41:28 +000023
Denis Vlasenko68404f12008-03-17 09:00:54 +000024 mode = getopt_mk_fifo_nod(argv);
Erik Andersene49d5ec2000-02-08 19:58:47 +000025
Denis Vlasenko99912ca2007-04-10 15:43:37 +000026 argv += optind;
27 if (!*argv) {
Manuel Novoa III cad53642003-03-19 09:13:01 +000028 bb_show_usage();
Erik Andersene49d5ec2000-02-08 19:58:47 +000029 }
Manuel Novoa III cad53642003-03-19 09:13:01 +000030
31 do {
32 if (mkfifo(*argv, mode) < 0) {
Denis Vlasenko0c97c9d2007-10-01 11:58:38 +000033 bb_simple_perror_msg(*argv); /* Avoid multibyte problems. */
Manuel Novoa III cad53642003-03-19 09:13:01 +000034 retval = EXIT_FAILURE;
35 }
36 } while (*++argv);
37
38 return retval;
Eric Andersen19db07b1999-12-11 08:41:28 +000039}