blob: 65494609cee7075fe79c76f0cec552ae402b24a0 [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 *
"Robert P. J. Day"801ab142006-07-12 07:56:04 +00007 * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
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
Denis Vlasenko9b49a5e2007-10-11 10:05:36 +000016int mkfifo_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
Denis Vlasenkoa60f84e2008-07-05 09:18:54 +000017int mkfifo_main(int argc UNUSED_PARAM, char **argv)
Eric Andersen19db07b1999-12-11 08:41:28 +000018{
Manuel Novoa III cad53642003-03-19 09:13:01 +000019 mode_t mode;
20 int retval = EXIT_SUCCESS;
Eric Andersen19db07b1999-12-11 08:41:28 +000021
Denis Vlasenko68404f12008-03-17 09:00:54 +000022 mode = getopt_mk_fifo_nod(argv);
Erik Andersene49d5ec2000-02-08 19:58:47 +000023
Denis Vlasenko99912ca2007-04-10 15:43:37 +000024 argv += optind;
25 if (!*argv) {
Manuel Novoa III cad53642003-03-19 09:13:01 +000026 bb_show_usage();
Erik Andersene49d5ec2000-02-08 19:58:47 +000027 }
Manuel Novoa III cad53642003-03-19 09:13:01 +000028
29 do {
30 if (mkfifo(*argv, mode) < 0) {
Denis Vlasenko0c97c9d2007-10-01 11:58:38 +000031 bb_simple_perror_msg(*argv); /* Avoid multibyte problems. */
Manuel Novoa III cad53642003-03-19 09:13:01 +000032 retval = EXIT_FAILURE;
33 }
34 } while (*++argv);
35
36 return retval;
Eric Andersen19db07b1999-12-11 08:41:28 +000037}