[BACK]Return to mkfifo.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / mkfifo

Diff for /src/usr.bin/mkfifo/Attic/mkfifo.c between version 1.2 and 1.3

version 1.2, 1996/06/26 05:37:11 version 1.3, 1996/08/28 07:31:51
Line 53 
Line 53 
 #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;
Line 67 
Line 71 
         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, "");
   
Line 75 
Line 81 
            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:")) != -1)          while ((ch = getopt(argc, argv, "m:s")) != -1)
                 switch(ch) {                  switch(ch) {
                 case 'm':                  case 'm':
                         if (!(set = setmode(optarg))) {                          if (!(set = setmode(optarg))) {
Line 87 
Line 93 
                            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();
Line 96 
Line 105 
         if (argv[0] == NULL)          if (argv[0] == NULL)
                 usage();                  usage();
   
         for (exitval = 0; *argv; ++argv) {          if (mksocket) {
                 if (mkfifo(*argv, mode) < 0) {                  for (exitval = 0; *argv; ++argv) {
                           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] fifoname ...\n");          (void)fprintf(stderr, "usage: mkfifo [-m mode] [-s] filename ...\n");
         exit(1);          exit(1);
 }  }

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.3