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 struct mtab *mp;
  13:     register char *p1, *p2;
  14:     int mf;
  15: 
  16:     sync();
  17:     mf = open("/etc/mtab", 0);
  18:     read(mf, mtab, NMOUNT*2*NAMSIZ);
  19:     if(argc != 2) {
  20:         printf("arg count\n");
  21:         return;
  22:     }
  23:     if (umount(argv[1]) < 0) {
  24:         perror("umount");
  25:         return;
  26:     }
  27:     p1 = argv[1];
  28:     while(*p1++)
  29:         ;
  30:     p1--;
  31:     while(*--p1 == '/')
  32:         *p1 = '\0';
  33:     while(p1 > argv[1] && *--p1 != '/')
  34:         ;
  35:     if(*p1 == '/')
  36:         p1++;
  37:     argv[1] = p1;
  38:     for (mp = mtab; mp < &mtab[NMOUNT]; mp++) {
  39:         p1 = argv[1];
  40:         p2 = &mp->spec[0];
  41:         while (*p1++ == *p2)
  42:             if (*p2++ == 0) {
  43:                 for (p1 = mp->file; p1 < &mp->file[NAMSIZ*2];)
  44:                     *p1++ = 0;
  45:                 mp = &mtab[NMOUNT];
  46:                 while ((--mp)->file[0] == 0);
  47:                 mf = creat("/etc/mtab", 0644);
  48:                 write(mf, mtab, (mp-mtab+1)*2*NAMSIZ);
  49:                 return;
  50:             }
  51:     }
  52:     printf("%s not in mount table\n", argv[1]);
  53: }

Defined functions

main defined in line 9; never used

Defined variables

mtab defined in line 7; used 6 times

Defined struct's

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

Defined macros

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