1: #ifndef lint
   2: static char *sccsid = "@(#)mknod.c	4.2 (Berkeley) 8/28/85";
   3: #endif not lint
   4: 
   5: #include <stdio.h>
   6: 
   7: main(argc, argv)
   8:     int argc;
   9:     char **argv;
  10: {
  11:     int m, a, b;
  12: 
  13:     if(argc != 5) {
  14:         printf("arg count\n");
  15:         goto usage;
  16:     }
  17:     if(*argv[2] == 'b')
  18:         m = 060666; else
  19:     if(*argv[2] == 'c')
  20:         m = 020666; else
  21:         goto usage;
  22:     a = number(argv[3]);
  23:     if(a < 0)
  24:         goto usage;
  25:     b = number(argv[4]);
  26:     if(b < 0)
  27:         goto usage;
  28:     if(mknod(argv[1], m, (a<<8)|b) < 0) {
  29:         fprintf(stderr, "mknod: ");
  30:         perror(argv[1]);
  31:     }
  32:     exit(0);
  33: 
  34: usage:
  35:     printf("usage: mknod name b/c major minor\n");
  36: }
  37: 
  38: number(s)
  39: char *s;
  40: {
  41:     int n, c;
  42: 
  43:     n = 0;
  44:     while(c = *s++) {
  45:         if(c<'0' || c>'9')
  46:             return(-1);
  47:         n = n*10 + c-'0';
  48:     }
  49:     return(n);
  50: }

Defined functions

main defined in line 7; never used
number defined in line 38; used 2 times

Defined variables

sccsid defined in line 2; never used
Last modified: 1987-02-16
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 2420
Valid CSS Valid XHTML 1.0 Strict