|
|
1.1 ! root 1: /* ! 2: * Copyright (c) 1982, 1986 Regents of the University of California. ! 3: * All rights reserved. The Berkeley software License Agreement ! 4: * specifies the terms and conditions for redistribution. ! 5: * ! 6: * @(#)drtest.c 7.3 (Berkeley) 3/4/88 ! 7: */ ! 8: ! 9: /* ! 10: * Standalone program to test a disk and driver ! 11: * by reading the disk a track at a time. ! 12: */ ! 13: #include "param.h" ! 14: #include "inode.h" ! 15: #include "fs.h" ! 16: #include "disklabel.h" ! 17: ! 18: #include "saio.h" ! 19: ! 20: #define SECTSIZ 512 ! 21: ! 22: extern int end; ! 23: char *malloc(); ! 24: ! 25: main() ! 26: { ! 27: register int fd, sector, lastsector, tracksize; ! 28: register char *bp; ! 29: struct disklabel dl; ! 30: int debug; ! 31: ! 32: printf("Testprogram for stand-alone driver\n\n"); ! 33: again: ! 34: debug = getdebug("Enable debugging (0=none, 1=bse, 2=ecc, 3=bse+ecc)? "); ! 35: if (debug < 0) ! 36: debug = 0; ! 37: fd = getfile("Device to read?", 2); ! 38: ioctl(fd, SAIODEVDATA, &dl); ! 39: printf("Device data: #cylinders=%d, #tracks=%d, #sectors=%d\n", ! 40: dl.d_ncylinders, dl.d_ntracks, dl.d_nsectors); ! 41: ioctl(fd, SAIODEBUG, (char *)debug); ! 42: tracksize = dl.d_nsectors * SECTSIZ; ! 43: bp = malloc(tracksize); ! 44: printf("Reading in %d byte records\n", tracksize); ! 45: printf("Start ...make sure drive is on-line\n"); ! 46: lseek(fd, 0, L_SET); ! 47: lastsector = dl.d_ncylinders * dl.d_secpercyl; ! 48: for (sector = 0; sector < lastsector; sector += dl.d_nsectors) { ! 49: if (sector && (sector % (dl.d_secpercyl * 10)) == 0) ! 50: printf("cylinder %d\n", sector/dl.d_secpercyl); ! 51: read(fd, bp, tracksize); ! 52: } ! 53: goto again; ! 54: /*NOTREACHED*/ ! 55: } ! 56: ! 57: static ! 58: getdebug(msg) ! 59: char *msg; ! 60: { ! 61: char buf[132]; ! 62: ! 63: printf("%s", msg); ! 64: gets(buf); ! 65: return (atoi(buf)); ! 66: } ! 67: ! 68: /* ! 69: * Allocate memory on a page-aligned address. ! 70: * Round allocated chunk to a page multiple to ! 71: * ease next request. ! 72: */ ! 73: static char * ! 74: malloc(size) ! 75: int size; ! 76: { ! 77: static caddr_t last = 0; ! 78: char *result; ! 79: ! 80: if (last == 0) ! 81: last = (caddr_t)(((int)&end + 511) & ~0x1ff); ! 82: size = (size + 511) & ~0x1ff; ! 83: result = (char *)last; ! 84: last += size; ! 85: return (result); ! 86: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.