xref: /csrg-svn/sys/vax/stand/drtest.c (revision 11360)
1*11360Ssam /*	drtest.c	4.9	83/03/01	*/
29973Ssam 
3*11360Ssam /*
4*11360Ssam  * Standalone program to test a disk and driver
5*11360Ssam  * by reading the disk in CHUNK sector units.
6*11360Ssam  */
710354Shelge #include "../h/param.h"
810354Shelge #include "../h/inode.h"
910354Shelge #include "../h/fs.h"
1010354Shelge #include "saio.h"
1110354Shelge 
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];
2011170Shelge 	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");
2511170Shelge 	printf("Is the console terminal a hard-copy device (y/n)? ");
2611170Shelge 	gets(buf);
2711170Shelge 	if (*buf == 'y')
2811170Shelge 		hc = 1;
299973Ssam askunit:
30*11360Ssam 	printf("Enter disk name [type(adapter,unit), e.g, hp(1,3)] ? ");
319973Ssam 	gets(buf);
3211170Shelge 	unit = (*(buf + 3) - '0')*8 + *(buf + 5) - '0';
3311170Shelge 	diskname[0] = *buf;
3411170Shelge 	diskname[1] = *(buf + 1);
3511170Shelge 	diskname[3] = '0' + (unit / 10);
3611170Shelge 	diskname[4] = '0' + (unit % 10);
3711170Shelge 	if ((fd = open(diskname, 0)) < 0) {
389973Ssam 		goto askunit;
399973Ssam 	}
4011170Shelge 	ioctl(fd, SAIODEVDATA, &st);
4110719Shelge 	printf("Device data: #cylinders=%d, #tracks=%d, #sectors=%d\n",
4210726Ssam 		st.ncyl, st.ntrak, st.nsect);
4311170Shelge 	chunk = st.nsect * SECTSIZ;
4410627Shelge 	printf("Testing %s, chunk size is %d bytes\n",buf, chunk);
4511170Shelge 	printf("Start ...Make sure %s is online\n", buf);
4611170Shelge 	lseek(fd, 0, 0);
4711170Shelge 	for (i = 0; i < st.ncyl * st.ntrak; i++) {
4811170Shelge 		read(fd, buffer, chunk);
4911170Shelge 		if ((i % (st.ntrak*5)) == 0) {
5011170Shelge 			int x = i / st.ntrak;
5111170Shelge 
5211170Shelge 			if (!hc)
5311170Shelge 				printf("%d\r", x);
5411170Shelge 			else {
5511170Shelge 				printf(".");
56*11360Ssam 				if (x && (x % 125) == 0)
5711170Shelge 					printf(". %d\n", x);
5811170Shelge 			}
5911170Shelge 		}
609973Ssam 	}
619973Ssam 	goto askunit;
629973Ssam }
63