Make POSIX 1003.2 (D11.2) compliant.
Add RCS Headers.
This commit is contained in:
parent
07f439a7a5
commit
6b020f1e7d
@ -33,6 +33,7 @@
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" @(#)mkfifo.1 5.6 (Berkeley) 7/1/91
|
||||
.\" $Header: /cvsroot/src/usr.bin/mkfifo/mkfifo.1,v 1.2 1993/07/22 16:30:06 jtc Exp $
|
||||
.\"
|
||||
.Dd July 1, 1991
|
||||
.Dt MKFIFO 1
|
||||
@ -42,19 +43,29 @@
|
||||
.Nd make fifos
|
||||
.Sh SYNOPSIS
|
||||
.Nm mkfifo
|
||||
.Op Fl p
|
||||
.Op Fl m Ar mode
|
||||
.Ar fifo_name ...
|
||||
.Sh DESCRIPTION
|
||||
.Nm Mkfifo
|
||||
creates the fifos requested, in the order specified,
|
||||
using mode
|
||||
.Li \&0777 .
|
||||
.Li \&0666
|
||||
modified by the current
|
||||
.Xr umask 2 .
|
||||
.Pp
|
||||
Options available are:
|
||||
The options are as follows:
|
||||
.Bl -tag -width Ds
|
||||
.It Fl p
|
||||
Create intermediate directories as required. If this option is not
|
||||
specified, the full path prefix of each operand must already exist.
|
||||
.It Fl m
|
||||
Set the file permission bits of newly-created directories to
|
||||
.Ar mode .
|
||||
The mode is specified as in
|
||||
.Xr chmod 1 .
|
||||
In symbolic mode strings, the
|
||||
.Dq +
|
||||
and
|
||||
.Dq -
|
||||
operators are interpreted relative to an assumed initial mode of
|
||||
.Dq a=rw
|
||||
.El
|
||||
.Pp
|
||||
.Nm Mkfifo
|
||||
@ -63,18 +74,16 @@ requires write permission in the parent directory.
|
||||
.Nm Mkfifo
|
||||
exits 0 if successful, and >0 if an error occurred.
|
||||
.Sh STANDARDS
|
||||
.Nm Mkfifo is
|
||||
The
|
||||
.Nm Mkfifo
|
||||
command is expected to be
|
||||
.St -p1003.2
|
||||
compliant.
|
||||
.Pp
|
||||
This manual page derived from the
|
||||
.St p1003.2
|
||||
manual page.
|
||||
compatible.
|
||||
.Sh SEE ALSO
|
||||
.Xr mkdir 1 ,
|
||||
.Xr rm 1
|
||||
.Sh HISTORY
|
||||
The
|
||||
.Nm
|
||||
.Nm mkfifo
|
||||
command is
|
||||
.Ud
|
||||
|
@ -39,26 +39,43 @@ char copyright[] =
|
||||
|
||||
#ifndef lint
|
||||
static char sccsid[] = "@(#)mkfifo.c 5.3 (Berkeley) 6/1/90";
|
||||
static char rcsid[] = "$Header: /cvsroot/src/usr.bin/mkfifo/mkfifo.c,v 1.2 1993/07/22 16:30:08 jtc Exp $";
|
||||
#endif /* not lint */
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
extern void *setmode();
|
||||
extern mode_t getmode();
|
||||
|
||||
main(argc, argv)
|
||||
int argc;
|
||||
char **argv;
|
||||
{
|
||||
extern int errno, optind;
|
||||
int ch, exitval, pflag;
|
||||
int ch, exitval;
|
||||
void * set;
|
||||
mode_t mode;
|
||||
|
||||
pflag = 0;
|
||||
while ((ch = getopt(argc, argv, "p")) != EOF)
|
||||
/* The default mode is the value of the bitwise inclusive or of
|
||||
S_IRUSR, S_IWUSR, S_IRGRP, S_IWGRP, S_IROTH, and S_IWOTH
|
||||
modified by the file creation mask */
|
||||
mode = 0666 & ~umask(0);
|
||||
|
||||
while ((ch = getopt(argc, argv, "m:")) != EOF)
|
||||
switch(ch) {
|
||||
case 'p':
|
||||
pflag = 1;
|
||||
case 'm':
|
||||
if (!(set = setmode(optarg))) {
|
||||
(void)fprintf(stderr, "mkfifo: invalid file mode.\n");
|
||||
exit(1);
|
||||
}
|
||||
/* In symbolic mode strings, the + and - operators are
|
||||
interpreted relative to an assumed initial mode of
|
||||
a=rw. */
|
||||
mode = getmode (set, 0666);
|
||||
break;
|
||||
case '?':
|
||||
default:
|
||||
@ -69,42 +86,17 @@ main(argc, argv)
|
||||
usage();
|
||||
|
||||
for (exitval = 0; *argv; ++argv) {
|
||||
if (pflag && build(*argv)) {
|
||||
exitval |= 1;
|
||||
continue;
|
||||
}
|
||||
if (mkfifo(*argv, 0777) < 0) {
|
||||
if (mkfifo(*argv, mode) < 0) {
|
||||
(void)fprintf(stderr, "mkfifo: %s: %s\n",
|
||||
*argv, strerror(errno));
|
||||
exitval |= 1;
|
||||
exitval = 1;
|
||||
}
|
||||
}
|
||||
exit(exitval);
|
||||
}
|
||||
|
||||
build(path)
|
||||
char *path;
|
||||
{
|
||||
register char *p;
|
||||
struct stat sb;
|
||||
|
||||
for (p = path; *p; p++) {
|
||||
if (*p != '/')
|
||||
continue;
|
||||
if (stat(path, &sb)) {
|
||||
if (errno != ENOENT || mkdir(path, 0777) < 0) {
|
||||
(void)fprintf(stderr, "mkdir: %s: %s\n",
|
||||
path, strerror(errno));
|
||||
return(1);
|
||||
}
|
||||
}
|
||||
*p = '/';
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
||||
usage()
|
||||
{
|
||||
(void)fprintf(stderr, "usage: mkfifo [-p] fifoname ...\n");
|
||||
(void)fprintf(stderr, "usage: mkfifo [-m mode] fifoname ...\n");
|
||||
exit(1);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user