1 /* drtest.c 4.1 82/12/26 */ 2 3 /* 4 * Standalone program to test a disk driver by reading 5 * every sector on the disk in chunks of CHUNK. 6 */ 7 extern struct hpst { 8 short nsect; 9 short ntrak; 10 short nspc; 11 short ncyl; 12 short *off; 13 } hpst[] ; 14 15 extern struct upst { 16 short nsect; 17 short ntrak; 18 short nspc; 19 short ncyl; 20 short *off; 21 } upst[] ; 22 extern struct updevice; 23 extern struct hpdevice; 24 extern char up_type[]; 25 extern char hp_type[]; 26 27 #define CHUNK 32 28 29 main() 30 { 31 char buf[50], buffer[CHUNK*512]; 32 int unit,fd,chunk,j; 33 register struct upst *st; 34 register i; 35 36 printf("Testprogram for stand-alone hp or up driver\n"); 37 askunit: 38 printf("Enter device name (e.g, hp(0,0) ) or q to quit >"); 39 gets(buf); 40 unit = (int)*(buf+3) - '0'; 41 if (unit <0 || unit > 3 ) { 42 printf("unit number out of range\n"); 43 goto askunit; 44 } 45 if ((fd=open(buf,0)) < 0) { 46 printf("Can't open %s \n",buf); 47 goto askunit; 48 } 49 switch(*buf) { 50 51 case 'u': 52 st = &upst[up_type[unit]]; 53 break; 54 55 case 'h': 56 st = (struct upst *)&hpst[hp_type[unit]]; 57 break; 58 59 default: 60 printf("Illegal device name\n"); 61 goto askunit; 62 } 63 64 chunk = st->nsect; 65 printf("Testing %s\n",buf); 66 printf("Start ...Make sure %s is online\n",buf); 67 lseek(fd,0,0); 68 for (i=0;i < st->ncyl;i++) { 69 for (j=8;j<st->ntrak+8;j++) { 70 lseek(fd,(i*st->nspc+((j%st->ntrak)*st->nsect))*512,0); 71 read(fd,buffer, chunk*512); 72 } 73 printf("%d\015",i); 74 } 75 goto askunit; 76 } 77