|
|
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;
7: char *worm = "/dev/worm0";
8:
9: if((argc < 3) || (argc > 4)){
10: print("Usage: tstrd [device] firstblock firstnonblock\n");
11: exit(1);
12: }
13: if(argc > 3)
14: worm = *++argv;
15: if((fd = open(worm, 0)) < 0){
16: perror(worm);
17: exit(1);
18: }
19: first = atol(argv[1]);
20: last = atol(argv[2]);
21: if((first < 0) || (last <= first)){
22: print("bad first=%ld last=%ld\n", first, last);
23: exit(1);
24: }
25: print("reading blocks %ld - %ld inclusive on %s\n", first, last-1, worm);
26: fillbuf(buf, 32);
27: bufp = &buf[1024*(first%5)];
28: lseek(fd, first*1024, 0);
29: while(first < last){
30: n = last-first;
31: if(n > 25) n = 25;
32: if(read(fd, buf1, n*1024) != n*1024){
33: print("block %ld: ", first);
34: perror("read");
35: exit(1);
36: }
37: if(memcmp(bufp, buf1, n*1024)){
38: print("block %ld: bytes differ\n", first);
39: exit(1);
40: }
41: if((first%5000) == 0){
42: t = time((long *)0);
43: print("done block %ld: %s", first, ctime(&t));
44: }
45: first += n;
46: }
47: exit(0);
48: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.