Implement -m for mkfifo(1)
This commit is contained in:
parent
651dbdd700
commit
7808f4161d
10
mkfifo.1
10
mkfifo.1
@ -3,9 +3,17 @@
|
||||
mkfifo \- make named pipe
|
||||
.SH SYNOPSIS
|
||||
.B mkfifo
|
||||
.RI [ name ...]
|
||||
.RB [ \-m
|
||||
.IR mode ]
|
||||
.I name ...
|
||||
.SH DESCRIPTION
|
||||
.B mkfifo
|
||||
creates named pipes (FIFOs) with the given names.
|
||||
.SH OPTIONS
|
||||
.TP
|
||||
.B \-m
|
||||
Set the file permission bits of newly created FIFOs to mode. The mode
|
||||
is specified in octal as we do not currently support all the formats that
|
||||
the chmod(1) utility supports.
|
||||
.SH SEE ALSO
|
||||
.IR mkfifo (3)
|
||||
|
15
mkfifo.c
15
mkfifo.c
@ -8,13 +8,19 @@
|
||||
static void
|
||||
usage(void)
|
||||
{
|
||||
eprintf("usage: %s name...\n", argv0);
|
||||
eprintf("usage: %s [-m mode] name...\n", argv0);
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
mode_t mode = S_IRUSR | S_IWUSR | S_IRGRP |
|
||||
S_IWGRP | S_IROTH | S_IWOTH;
|
||||
|
||||
ARGBEGIN {
|
||||
case 'm':
|
||||
mode = estrtol(EARGF(usage()), 8);
|
||||
break;
|
||||
default:
|
||||
usage();
|
||||
} ARGEND;
|
||||
@ -22,12 +28,9 @@ main(int argc, char *argv[])
|
||||
if (argc < 1)
|
||||
usage();
|
||||
|
||||
for(; argc > 0; argc--, argv++) {
|
||||
if(mkfifo(argv[0], S_IRUSR|S_IWUSR|S_IRGRP|\
|
||||
S_IWGRP|S_IROTH|S_IWOTH) == -1) {
|
||||
for(; argc > 0; argc--, argv++)
|
||||
if(mkfifo(argv[0], mode) == -1)
|
||||
eprintf("mkfifo %s:", argv[0]);
|
||||
}
|
||||
}
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user