Annotation of researchv10no/cmd/worm/scsi/osanity/tstsk.c, revision 1.1

1.1     ! root        1: main(argc, argv)
        !             2:        char **argv;
        !             3: {
        !             4:        long first, last, t;
        !             5:        char buf[32768], buf1[32768], *bufp;
        !             6:        int fd, n, i;
        !             7:        char *worm = "/dev/worm0";
        !             8:        long bands[50][2];
        !             9:        int nbands;
        !            10:        long loop;
        !            11:        double tseek, tbl;
        !            12:        float floop;
        !            13: 
        !            14:        if(argc < 3){
        !            15:                print("Usage: tstsk [device] firstblock firstnonblock ...\n");
        !            16:                exit(1);
        !            17:        }
        !            18:        if((argc&1) == 0)
        !            19:                worm = *++argv;
        !            20:        if((fd = open(worm, 0)) < 0){
        !            21:                perror(worm);
        !            22:                exit(1);
        !            23:        }
        !            24:        nbands = 0;
        !            25:        while(*++argv){
        !            26:                first = atol(*argv);
        !            27:                last = atol(*++argv);
        !            28:                if((first < 0) || (last <= first)){
        !            29:                        print("bad first=%ld last=%ld\n", first, last);
        !            30:                        exit(1);
        !            31:                }
        !            32:                bands[nbands][0] = first;
        !            33:                bands[nbands][1] = last;
        !            34:                nbands++;
        !            35:        }
        !            36:        tseek = tbl = 0;
        !            37:        last = 0;
        !            38:        fillbuf(buf, 32);
        !            39:        for(loop = 0;; loop++){
        !            40:                i = nrand(nbands);
        !            41:                first = bands[i][0] + lrand()%(bands[i][1]-bands[i][0]);
        !            42:                n = 20;
        !            43:                if(first+n > bands[i][1])
        !            44:                        first = bands[i][1]-n;
        !            45:                if(first < bands[i][0])
        !            46:                        first = bands[i][0], n = bands[i][1]-first;
        !            47:                tbl += n;
        !            48:                lseek(fd, first*1024, 0);
        !            49:                last -= first;
        !            50:                if(last < 0) last = -last;
        !            51:                tseek += last;
        !            52:                bufp = &buf[1024*(first%5)];
        !            53:                if(read(fd, buf1, n*1024) != n*1024){
        !            54:                        print("block %ld: ", first);
        !            55:                        perror("read");
        !            56:                        exit(1);
        !            57:                }
        !            58:                if(memcmp(bufp, buf1, n*1024)){
        !            59:                        print("block %ld: bytes differ\n", first);
        !            60:                        exit(1);
        !            61:                }
        !            62:                if(loop && ((loop%100) == 0)){
        !            63:                        t = time((long *)0);
        !            64:                        floop = loop+1;
        !            65:                        print("loop %ld: ave blocks=%.1f, ave seek=%.1fk at %s",
        !            66:                                loop, tbl/floop, tseek/floop, ctime(&t));
        !            67:                }
        !            68:                last = first+n;
        !            69:        }
        !            70: }

unix.superglobalmegacorp.com

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