xref: /csrg-svn/sys/vax/stand/drtest.c (revision 11170)
1*11170Shelge /*	drtest.c	4.8	83/02/20	*/
29973Ssam 
310354Shelge #include "../h/param.h"
410354Shelge #include "../h/inode.h"
510354Shelge #include "../h/fs.h"
610354Shelge #include "saio.h"
710354Shelge 
810354Shelge /* Standalone program to test a disk driver by reading every sector on
910354Shelge  * the disk in chunks of CHUNK.
109973Ssam  */
119973Ssam 
1210354Shelge #define CHUNK	32
1310354Shelge #define SECTSIZ	512
149973Ssam 
1510608Ssam char diskname[] = "xx(00,0)";
1610608Ssam 
179973Ssam main()
189973Ssam {
1910354Shelge 	char buf[50], buffer[CHUNK*SECTSIZ];
20*11170Shelge 	int unit, fd, chunk, j, hc = 0;
2110354Shelge 	struct st st;
229973Ssam 	register i;
239973Ssam 
2410719Shelge 	printf("Testprogram for stand-alone hp or up driver\n\n");
25*11170Shelge 	printf("Is the console terminal a hard-copy device (y/n)? ");
26*11170Shelge 	gets(buf);
27*11170Shelge 	if (*buf == 'y')
28*11170Shelge 		hc = 1;
299973Ssam askunit:
30*11170Shelge 	printf("Enter disk name [ type(adapter,unit), e.g, hp(1,3) ] ? ");
319973Ssam 	gets(buf);
32*11170Shelge 	unit = (*(buf + 3) - '0')*8 + *(buf + 5) - '0';
33*11170Shelge 	diskname[0] = *buf;
34*11170Shelge 	diskname[1] = *(buf + 1);
35*11170Shelge 	diskname[3] = '0' + (unit / 10);
36*11170Shelge 	diskname[4] = '0' + (unit % 10);
37*11170Shelge 	if ((fd = open(diskname, 0)) < 0) {
389973Ssam 		goto askunit;
399973Ssam 	}
40*11170Shelge 	ioctl(fd, SAIODEVDATA, &st);
4110719Shelge 	printf("Device data: #cylinders=%d, #tracks=%d, #sectors=%d\n",
4210726Ssam 		st.ncyl, st.ntrak, st.nsect);
43*11170Shelge 	chunk = st.nsect * SECTSIZ;
4410627Shelge 	printf("Testing %s, chunk size is %d bytes\n",buf, chunk);
45*11170Shelge 	printf("Start ...Make sure %s is online\n", buf);
46*11170Shelge 	lseek(fd, 0, 0);
47*11170Shelge 	for (i = 0; i < st.ncyl * st.ntrak; i++) {
48*11170Shelge 		read(fd, buffer, chunk);
49*11170Shelge 		if ((i % (st.ntrak*5)) == 0) {
50*11170Shelge 			int x = i / st.ntrak;
51*11170Shelge 
52*11170Shelge 			if (!hc)
53*11170Shelge 				printf("%d\r", x);
54*11170Shelge 			else {
55*11170Shelge 				printf(".");
56*11170Shelge 				if ((x + 1 % 25) == 0)
57*11170Shelge 					printf(". %d\n", x);
58*11170Shelge 			}
59*11170Shelge 		}
609973Ssam 	}
619973Ssam 	goto askunit;
629973Ssam }
63