|
|
1.1 ! root 1: #include "/usr/include/stdio.h" ! 2: #include <sys/param.h> ! 3: #include <sys/ino.h> ! 4: #include <sys/inode.h> ! 5: #include <sys/filsys.h> ! 6: #include <sys/fblk.h> ! 7: #include <sys/dir.h> ! 8: ! 9: int fsi; ! 10: char buf[BSIZE(0)]; ! 11: ! 12: main() ! 13: { ! 14: short *s = (short *)buf; ! 15: int i; ! 16: ! 17: fsi = open("/dev/rsd1a", 0); ! 18: rdfs(1, buf); ! 19: for(i = 0; i < sizeof(buf)/2; i++) ! 20: if(*s++ != i) ! 21: printf("%d is %d\n", i, *(s - 1)); ! 22: } ! 23: ! 24: rdfs(bno, bf) ! 25: daddr_t bno; ! 26: char *bf; ! 27: { ! 28: int n; ! 29: ! 30: lseek(fsi, bno*BSIZE(0), 0); ! 31: n = read(fsi, bf, BSIZE(0)); ! 32: if(n != BSIZE(0)) { ! 33: printf("read error: %ld\n", bno); ! 34: exit(1); ! 35: } ! 36: } ! 37: ! 38: wrfs(bno, bf) ! 39: daddr_t bno; ! 40: char *bf; ! 41: { ! 42: int n; ! 43: ! 44: lseek(fsi, bno*BSIZE(0), 0); ! 45: n = write(fsi, bf, BSIZE(0)); ! 46: if(n != BSIZE(0)) { ! 47: printf("write error: %ld\n", bno); ! 48: exit(1); ! 49: } ! 50: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.