1 2 #include "../h/param.h" 3 #include "../h/inode.h" 4 #include "../h/fs.h" 5 #include "saio.h" 6 7 /* Standalone program to test a disk driver by reading every sector on 8 * the disk in chunks of CHUNK. 9 */ 10 11 #define CHUNK 32 12 #define SECTSIZ 512 13 14 main() 15 { 16 char buf[50], buffer[CHUNK*SECTSIZ]; 17 int unit,fd,chunk,j; 18 struct st st; 19 register i; 20 21 printf("Testprogram for stand-alone hp or up driver\n"); 22 askunit: 23 printf("Enter device name (e.g, hp(0,0) ) or q to quit >"); 24 gets(buf); 25 unit = (int)*(buf+3) - '0'; 26 if (unit <0 || unit > 3 ) { 27 printf("unit number out of range\n"); 28 goto askunit; 29 } 30 if ((fd=open(buf,0)) < 0) { 31 printf("Can't open %s \n",buf); 32 goto askunit; 33 } 34 ioctl(fd,SAIODEVDATA,&st); 35 36 chunk = st.nsect*SECTSIZ; 37 printf("Testing %s, chunk size is %d\n",buf, chunk); 38 printf("Start ...Make sure %s is online\n",buf); 39 lseek(fd,0,0); 40 for (i=0;i < st.ncyl*st.ntrak; i++) { 41 /* for (j=8;j<st.ntrak+8;j++) { 42 lseek(fd,(i*st.nspc+((j%st.ntrak)*st.nsect))*SECTSIZ,0); 43 */ 44 read(fd,buffer, chunk); 45 /* } */ 46 if (i%st.ntrak == 0) printf("%d\r",i/st.ntrak); 47 } 48 goto askunit; 49 } 50