1 /* mkfifo -- make fifo's (named pipes)
2 Copyright (C) 1990, 1991, 1995 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> */
28 #include <sys/types.h>
31 #include "modechange.h"
37 /* The name this program was run with. */
40 /* If non-zero, display usage information and exit. */
43 /* If non-zero, print the version on standard output and exit. */
44 static int show_version;
46 static struct option const longopts[] =
48 {"mode", required_argument, NULL, 'm'},
49 {"help", no_argument, &show_help, 1},
50 {"version", no_argument, &show_version, 1},
59 unsigned short newmode;
60 struct mode_change *change;
65 program_name = argv[0];
69 error (4, 0, "fifo files not supported");
71 while ((optc = getopt_long (argc, argv, "m:", longopts, (int *) 0)) != EOF)
78 symbolic_mode = optarg;
87 printf ("%s\n", version_string);
96 error (0, 0, "too few arguments");
100 newmode = 0666 & ~umask (0);
103 change = mode_compile (symbolic_mode, 0);
104 if (change == MODE_INVALID)
105 error (1, 0, "invalid mode");
106 else if (change == MODE_MEMORY_EXHAUSTED)
107 error (1, 0, "virtual memory exhausted");
108 newmode = mode_adjust (newmode, change);
111 for (; optind < argc; ++optind)
113 if (mkfifo (argv[optind], newmode))
115 error (0, errno, "cannot make fifo `%s'", argv[optind]);
130 fprintf (stderr, "Try `%s --help' for more information.\n",
134 printf ("Usage: %s [OPTION] PATH...\n", program_name);
137 -m, --mode=MODE set permission mode (as in chmod), not 0666 - umask\n\
138 --help display this help and exit\n\
139 --version output version information and exit\n");