|
|
1.1 ! root 1: #define NBLK 100 ! 2: #define BSIZE 512 ! 3: char buf[BSIZE*NBLK]; ! 4: main(argc, argv) ! 5: char **argv; ! 6: { ! 7: long i; ! 8: register j; ! 9: register fi, fo; ! 10: int cfi; ! 11: int err, k; ! 12: long SIZE, atol(); ! 13: ! 14: if (argc!=5) { ! 15: printf("dskcpy infile rawinfile outfile size (512)\n"); ! 16: exit(1); ! 17: } ! 18: SIZE = atol(argv[4]); ! 19: printf("Copying %ld blocks\n", SIZE); ! 20: fi = open(argv[2], 0); ! 21: cfi = open(argv[1], 0); ! 22: if (fi<0 || cfi<0) { ! 23: printf("read open\n"); ! 24: exit(1); ! 25: } ! 26: fo = open(argv[3], 1); ! 27: if (fo < 0) { ! 28: printf("write open\n"); ! 29: exit(1); ! 30: } ! 31: err = 0; ! 32: for (i=0; i<SIZE; i+=NBLK) { ! 33: if (err) { ! 34: lseek(fi, i*BSIZE, 0); ! 35: lseek(fo, i*BSIZE, 0); ! 36: lseek(cfi, i*BSIZE, 0); ! 37: } ! 38: err = 0; ! 39: if (read(fi, buf, BSIZE*NBLK) != BSIZE*NBLK) { ! 40: printf("PRE %D\n", i); ! 41: err++; ! 42: } ! 43: if (write(fo, buf, BSIZE*NBLK) != BSIZE*NBLK) ! 44: err++; ! 45: if (err) { ! 46: for (j=0; j<NBLK; j++) { ! 47: if ((i+j)>=SIZE) ! 48: break; ! 49: lseek(cfi, (i+j)*BSIZE, 0); ! 50: lseek(fo, (i+j)*BSIZE, 0); ! 51: if (read(cfi, buf, BSIZE) != BSIZE) { ! 52: printf("RE %D\n", i+j); ! 53: for (k=0;k<BSIZE;k++) ! 54: buf[k] = 0; ! 55: } ! 56: if (write(fo, buf, BSIZE) != BSIZE) ! 57: printf("WE %D\n", i+j); ! 58: } ! 59: } ! 60: } ! 61: printf("done\n"); ! 62: return(0); ! 63: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.