1: #define NMOUNT  16
   2: #define NAMSIZ  32
   3: 
   4: struct mtab {
   5:     char    file[NAMSIZ];
   6:     char    spec[NAMSIZ];
   7: } mtab[NMOUNT];
   8: 
   9: main(argc, argv)
  10: char **argv;
  11: {
  12:     register int ro;
  13:     register struct mtab *mp;
  14:     register char *np;
  15:     int n, mf;
  16: 
  17:     mf = open("/etc/mtab", 0);
  18:     read(mf, mtab, NMOUNT*2*NAMSIZ);
  19:     if (argc==1) {
  20:         for (mp = mtab; mp < &mtab[NMOUNT]; mp++)
  21:             if (mp->file[0])
  22:                 printf("%s on %s\n", mp->spec, mp->file);
  23:         return;
  24:     }
  25:     if(argc < 3) {
  26:         printf("arg count\n");
  27:         return;
  28:     }
  29:     ro = 0;
  30:     if(argc > 3)
  31:         ro++;
  32:     if(mount(argv[1], argv[2], ro) < 0) {
  33:         perror("mount");
  34:         return;
  35:     }
  36:     np = argv[1];
  37:     while(*np++)
  38:         ;
  39:     np--;
  40:     while(*--np == '/')
  41:         *np = '\0';
  42:     while(np > argv[1] && *--np != '/')
  43:         ;
  44:     if(*np == '/')
  45:         np++;
  46:     argv[1] = np;
  47:     for (mp = mtab; mp < &mtab[NMOUNT]; mp++) {
  48:         if (mp->file[0] == 0) {
  49:             for (np = mp->spec; np < &mp->spec[NAMSIZ-1];)
  50:                 if ((*np++ = *argv[1]++) == 0)
  51:                     argv[1]--;
  52:             for (np = mp->file; np < &mp->file[NAMSIZ-1];)
  53:                 if ((*np++ = *argv[2]++) == 0)
  54:                     argv[2]--;
  55:             mp = &mtab[NMOUNT];
  56:             while ((--mp)->file[0] == 0);
  57:             mf = creat("/etc/mtab", 0644);
  58:             write(mf, mtab, (mp-mtab+1)*2*NAMSIZ);
  59:             return;
  60:         }
  61:     }
  62: }

Defined functions

main defined in line 9; never used

Defined variables

mtab defined in line 7; used 8 times

Defined struct's

mtab defined in line 4; used 2 times
  • in line 13(2)

Defined macros

NAMSIZ defined in line 2; used 6 times
NMOUNT defined in line 1; used 5 times
Last modified: 1975-05-14
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 532
Valid CSS Valid XHTML 1.0 Strict