version 1.3, 1996/08/28 07:31:51 |
version 1.4, 1996/08/30 07:04:33 |
|
|
#include <locale.h> |
#include <locale.h> |
#include <errno.h> |
#include <errno.h> |
#include <sys/types.h> |
#include <sys/types.h> |
#include <sys/socket.h> |
|
#include <sys/un.h> |
|
#include <sys/stat.h> |
#include <sys/stat.h> |
#include <unistd.h> |
#include <unistd.h> |
#include <err.h> |
#include <err.h> |
|
|
static void usage(); |
static void usage(); |
|
|
int mksocket; |
|
|
|
int |
int |
main(argc, argv) |
main(argc, argv) |
int argc; |
int argc; |
|
|
int ch, exitval; |
int ch, exitval; |
void * set; |
void * set; |
mode_t mode; |
mode_t mode; |
int sock; |
|
struct sockaddr_un name; |
|
|
|
setlocale (LC_ALL, ""); |
setlocale (LC_ALL, ""); |
|
|
|
|
modified by the file creation mask */ |
modified by the file creation mask */ |
mode = 0666 & ~umask(0); |
mode = 0666 & ~umask(0); |
|
|
while ((ch = getopt(argc, argv, "m:s")) != -1) |
while ((ch = getopt(argc, argv, "m:")) != -1) |
switch(ch) { |
switch(ch) { |
case 'm': |
case 'm': |
if (!(set = setmode(optarg))) { |
if (!(set = setmode(optarg))) { |
|
|
a=rw. */ |
a=rw. */ |
mode = getmode (set, 0666); |
mode = getmode (set, 0666); |
break; |
break; |
case 's': |
|
mksocket = 1; |
|
break; |
|
case '?': |
case '?': |
default: |
default: |
usage(); |
usage(); |
|
|
if (argv[0] == NULL) |
if (argv[0] == NULL) |
usage(); |
usage(); |
|
|
if (mksocket) { |
for (exitval = 0; *argv; ++argv) { |
for (exitval = 0; *argv; ++argv) { |
if (mkfifo(*argv, mode) < 0) { |
if ((sock = socket(AF_UNIX, SOCK_DGRAM, 0)) < 0) |
|
goto error; |
|
|
|
name.sun_family = AF_UNIX; |
|
strncpy(name.sun_path, *argv, sizeof(name.sun_path)-1); |
|
name.sun_path[sizeof(name.sun_path) - 1]; |
|
if (bind(sock, (struct sockaddr *)&name, |
|
SUN_LEN(&name)) < 0) |
|
goto error; |
|
|
|
if (chmod(*argv, mode) < 0) { |
|
unlink(*argv); |
|
goto error; |
|
} |
|
|
|
continue; |
|
error: |
|
warn("%s", *argv); |
warn("%s", *argv); |
exitval = 1; |
exitval = 1; |
} |
} |
} |
} |
else { |
|
for (exitval = 0; *argv; ++argv) { |
|
if (mkfifo(*argv, mode) < 0) { |
|
warn("%s", *argv); |
|
exitval = 1; |
|
} |
|
} |
|
} |
|
exit(exitval); |
exit(exitval); |
} |
} |
|
|
void |
void |
usage() |
usage() |
{ |
{ |
(void)fprintf(stderr, "usage: mkfifo [-m mode] [-s] filename ...\n"); |
(void)fprintf(stderr, "usage: mkfifo [-m mode] fifoname ...\n"); |
exit(1); |
exit(1); |
} |
} |