2011-05-25 06:00:15 -04:00
|
|
|
/* See LICENSE file for copyright and license details. */
|
|
|
|
#include <sys/stat.h>
|
2015-02-14 15:02:41 -05:00
|
|
|
|
|
|
|
#include <stdlib.h>
|
2014-11-13 12:29:30 -05:00
|
|
|
|
2011-05-25 06:00:15 -04:00
|
|
|
#include "util.h"
|
|
|
|
|
2013-06-14 14:20:47 -04:00
|
|
|
static void
|
|
|
|
usage(void)
|
|
|
|
{
|
2015-03-02 11:25:29 -05:00
|
|
|
eprintf("usage: %s [-m mode] name ...\n", argv0);
|
2013-06-14 14:20:47 -04:00
|
|
|
}
|
|
|
|
|
2011-05-25 06:00:15 -04:00
|
|
|
int
|
|
|
|
main(int argc, char *argv[])
|
|
|
|
{
|
2015-03-02 11:25:29 -05:00
|
|
|
mode_t mode = 0, mask;
|
|
|
|
int mflag = 0, ret = 0;
|
2013-11-30 15:56:34 -05:00
|
|
|
|
2013-06-14 14:20:47 -04:00
|
|
|
ARGBEGIN {
|
2013-11-30 15:56:34 -05:00
|
|
|
case 'm':
|
2015-01-28 14:55:50 -05:00
|
|
|
mflag = 1;
|
|
|
|
mask = getumask();
|
|
|
|
mode = parsemode(EARGF(usage()), mode, mask);
|
2013-11-30 15:56:34 -05:00
|
|
|
break;
|
2013-06-14 14:20:47 -04:00
|
|
|
default:
|
|
|
|
usage();
|
2015-11-01 05:16:49 -05:00
|
|
|
} ARGEND
|
2013-08-31 18:04:49 -04:00
|
|
|
|
2015-03-02 11:25:29 -05:00
|
|
|
if (!argc)
|
2013-08-31 18:04:49 -04:00
|
|
|
usage();
|
|
|
|
|
2015-03-02 11:25:29 -05:00
|
|
|
for (; *argv; argc--, argv++) {
|
|
|
|
if (mkfifo(*argv, S_IRUSR | S_IWUSR | S_IRGRP |
|
|
|
|
S_IWGRP | S_IROTH | S_IWOTH) < 0) {
|
|
|
|
weprintf("mkfifo %s:", *argv);
|
2014-11-22 06:18:05 -05:00
|
|
|
ret = 1;
|
2015-03-02 11:25:29 -05:00
|
|
|
} else if (mflag) {
|
|
|
|
if (chmod(*argv, mode) < 0) {
|
|
|
|
weprintf("chmod %s:", *argv);
|
2015-01-28 14:55:50 -05:00
|
|
|
ret = 1;
|
|
|
|
}
|
|
|
|
}
|
2014-11-22 06:18:05 -05:00
|
|
|
}
|
2015-03-02 11:25:29 -05:00
|
|
|
|
2014-11-22 06:18:05 -05:00
|
|
|
return ret;
|
2011-05-25 06:00:15 -04:00
|
|
|
}
|