19973Ssam 210354Shelge #include "../h/param.h" 310354Shelge #include "../h/inode.h" 410354Shelge #include "../h/fs.h" 510354Shelge #include "saio.h" 610354Shelge 710354Shelge /* Standalone program to test a disk driver by reading every sector on 810354Shelge * the disk in chunks of CHUNK. 99973Ssam */ 109973Ssam 1110354Shelge #define CHUNK 32 1210354Shelge #define SECTSIZ 512 139973Ssam 1410608Ssam char diskname[] = "xx(00,0)"; 1510608Ssam 169973Ssam main() 179973Ssam { 1810354Shelge char buf[50], buffer[CHUNK*SECTSIZ]; 199973Ssam int unit,fd,chunk,j; 2010354Shelge struct st st; 219973Ssam register i; 229973Ssam 2310719Shelge printf("Testprogram for stand-alone hp or up driver\n\n"); 249973Ssam askunit: 2510608Ssam printf("Enter disk name [ type(adapter,unit), e.g, hp(1,3) ] > "); 269973Ssam gets(buf); 2710608Ssam unit = (*(buf+3) - '0')*8 + *(buf+5)-'0'; 2810608Ssam diskname[0] = *buf; 2910608Ssam diskname[1] = *(buf+1); 3010608Ssam diskname[3] = '0' + unit/10; 3110608Ssam diskname[4] = '0' + unit%10; 3210608Ssam if ((fd=open(diskname,0)) < 0) { 339973Ssam goto askunit; 349973Ssam } 3510354Shelge ioctl(fd,SAIODEVDATA,&st); 3610719Shelge printf("Device data: #cylinders=%d, #tracks=%d, #sectors=%d\n", 37*10726Ssam st.ncyl, st.ntrak, st.nsect); 3810354Shelge chunk = st.nsect*SECTSIZ; 3910627Shelge printf("Testing %s, chunk size is %d bytes\n",buf, chunk); 409973Ssam printf("Start ...Make sure %s is online\n",buf); 419973Ssam lseek(fd,0,0); 4210354Shelge for (i=0;i < st.ncyl*st.ntrak; i++) { 4310354Shelge /* for (j=8;j<st.ntrak+8;j++) { 4410354Shelge lseek(fd,(i*st.nspc+((j%st.ntrak)*st.nsect))*SECTSIZ,0); 4510354Shelge */ 4610354Shelge read(fd,buffer, chunk); 4710354Shelge /* } */ 4810627Shelge if (i%(st.ntrak*5) == 0) printf("%d\r",i/st.ntrak); 499973Ssam } 509973Ssam goto askunit; 519973Ssam } 52