1 /* drtest.c 4.8 83/02/20 */ 2 3 #include "../h/param.h" 4 #include "../h/inode.h" 5 #include "../h/fs.h" 6 #include "saio.h" 7 8 /* Standalone program to test a disk driver by reading every sector on 9 * the disk in chunks of CHUNK. 10 */ 11 12 #define CHUNK 32 13 #define SECTSIZ 512 14 15 char diskname[] = "xx(00,0)"; 16 17 main() 18 { 19 char buf[50], buffer[CHUNK*SECTSIZ]; 20 int unit, fd, chunk, j, hc = 0; 21 struct st st; 22 register i; 23 24 printf("Testprogram for stand-alone hp or up driver\n\n"); 25 printf("Is the console terminal a hard-copy device (y/n)? "); 26 gets(buf); 27 if (*buf == 'y') 28 hc = 1; 29 askunit: 30 printf("Enter disk name [ type(adapter,unit), e.g, hp(1,3) ] ? "); 31 gets(buf); 32 unit = (*(buf + 3) - '0')*8 + *(buf + 5) - '0'; 33 diskname[0] = *buf; 34 diskname[1] = *(buf + 1); 35 diskname[3] = '0' + (unit / 10); 36 diskname[4] = '0' + (unit % 10); 37 if ((fd = open(diskname, 0)) < 0) { 38 goto askunit; 39 } 40 ioctl(fd, SAIODEVDATA, &st); 41 printf("Device data: #cylinders=%d, #tracks=%d, #sectors=%d\n", 42 st.ncyl, st.ntrak, st.nsect); 43 chunk = st.nsect * SECTSIZ; 44 printf("Testing %s, chunk size is %d bytes\n",buf, chunk); 45 printf("Start ...Make sure %s is online\n", buf); 46 lseek(fd, 0, 0); 47 for (i = 0; i < st.ncyl * st.ntrak; i++) { 48 read(fd, buffer, chunk); 49 if ((i % (st.ntrak*5)) == 0) { 50 int x = i / st.ntrak; 51 52 if (!hc) 53 printf("%d\r", x); 54 else { 55 printf("."); 56 if ((x + 1 % 25) == 0) 57 printf(". %d\n", x); 58 } 59 } 60 } 61 goto askunit; 62 } 63