Annotation of 3BSD/cmd/umount.c, revision 1.1

1.1     ! root        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, (char *)mtab, NMOUNT*2*NAMSIZ);
        !            19:        if(argc != 2) {
        !            20:                printf("arg count\n");
        !            21:                return(1);
        !            22:        }
        !            23:        if (umount(argv[1]) < 0) {
        !            24:                perror("umount");
        !            25:                return(1);
        !            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, (char *)mtab, (mp-mtab+1)*2*NAMSIZ);
        !            49:                                return(0);
        !            50:                        }
        !            51:        }
        !            52:        printf("%s not in mount table\n", argv[1]);
        !            53:        return(1);
        !            54: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.