xref: /csrg-svn/sys/vax/stand/drtest.c (revision 10627)
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 
239973Ssam 	printf("Testprogram for stand-alone hp or up driver\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);
369973Ssam 
3710354Shelge 	chunk = st.nsect*SECTSIZ;
38*10627Shelge 	printf("Testing %s, chunk size is %d bytes\n",buf, chunk);
399973Ssam 	printf("Start ...Make sure %s is online\n",buf);
409973Ssam 	lseek(fd,0,0);
4110354Shelge 	for (i=0;i < st.ncyl*st.ntrak; i++) {
4210354Shelge /*		for (j=8;j<st.ntrak+8;j++) {
4310354Shelge 			lseek(fd,(i*st.nspc+((j%st.ntrak)*st.nsect))*SECTSIZ,0);
4410354Shelge */
4510354Shelge 			read(fd,buffer, chunk);
4610354Shelge /*		}					*/
47*10627Shelge 		if (i%(st.ntrak*5) == 0) printf("%d\r",i/st.ntrak);
489973Ssam 	}
499973Ssam 	goto askunit;
509973Ssam }
51