1 /* mkfifo -- make fifo's (named pipes)
2 Copyright (C) 1990, 1991 Free Software Foundation, Inc.
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2, or (at your option)
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
19 -m, --mode=mode Set the mode of created fifo's to MODE, which is
20 symbolic as in chmod and uses the umask as a point of
23 David MacKenzie <djm@ai.mit.edu> */
26 #if defined (CONFIG_BROKETS)
27 /* We use <config.h> instead of "config.h" so that a compilation
28 using -I. -I$srcdir will use ./config.h rather than $srcdir/config.h
29 (which it would do because it found this file in $srcdir). */
38 #include <sys/types.h>
40 #include "modechange.h"
47 /* The name this program was run with. */
50 /* If non-zero, display usage information and exit. */
53 /* If non-zero, print the version on standard output and exit. */
54 static int show_version
;
56 static struct option
const longopts
[] =
58 {"mode", required_argument
, NULL
, 'm'},
59 {"help", no_argument
, &show_help
, 1},
60 {"version", no_argument
, &show_version
, 1},
69 unsigned short newmode
;
70 struct mode_change
*change
;
75 program_name
= argv
[0];
79 error (4, 0, "fifo files not supported");
81 while ((optc
= getopt_long (argc
, argv
, "m:", longopts
, (int *) 0)) != EOF
)
88 symbolic_mode
= optarg
;
97 printf ("%s\n", version_string
);
107 newmode
= 0666 & ~umask (0);
110 change
= mode_compile (symbolic_mode
, 0);
111 if (change
== MODE_INVALID
)
112 error (1, 0, "invalid mode");
113 else if (change
== MODE_MEMORY_EXHAUSTED
)
114 error (1, 0, "virtual memory exhausted");
115 newmode
= mode_adjust (newmode
, change
);
118 for (; optind
< argc
; ++optind
)
120 if (mkfifo (argv
[optind
], newmode
))
122 error (0, errno
, "cannot make fifo `%s'", argv
[optind
]);
136 Usage: %s [-m mode] [--mode=mode] [--help] [--version] path...\n",