xref: /csrg-svn/old/rxformat/rxformat.c (revision 12333)
1*12333Shelge /*	rxformat.c	4.3	83/05/08	*/
212077Shelge 
312077Shelge #include <stdio.h>
412077Shelge #include <sys/file.h>
512077Shelge #include <errno.h>
612077Shelge #include "/sys/vaxuba/rxreg.h"
712077Shelge 
8*12333Shelge char devname[] = "/dev/rrx?a";
9*12333Shelge 
1012077Shelge /*
1112077Shelge  * format floppy disks on RX02
1212077Shelge  */
13*12333Shelge 
1412077Shelge main(argc, argv)
1512077Shelge 	int argc;
1612077Shelge 	char *argv[];
1712077Shelge {
1812077Shelge 	int fd, idens = 0, filarg = 1;
1912077Shelge 
2012077Shelge 	if (argc < 2)
2112077Shelge 		usage();
2212077Shelge 	if (argc == 3) {
2312077Shelge 		if (strncmp(argv[1],"-d",2) != 0)
2412077Shelge 			usage();
2512077Shelge 		idens++;
26*12333Shelge 		filarg++;
2712077Shelge 	}
28*12333Shelge 	devname[8] = argv[filarg][7];
29*12333Shelge 	if ((fd = open(devname, FRDWR, 0600)) < NULL) {
30*12333Shelge 		perror(devname);
3112077Shelge 		exit (0);
3212077Shelge 	}
33*12333Shelge 	printf("Format %s to", argv[filarg]);
3412077Shelge 	if (idens)
3512077Shelge 		printf(" double density (y/n) ?");
3612077Shelge 	else
3712077Shelge 		printf(" single density (y/n) ?");
3812077Shelge 	if (getchar() != 'y')
3912077Shelge 		exit (0);
40*12333Shelge 	/*
41*12333Shelge 	 * change the ioctl command when dkio.h has
42*12333Shelge 	 * been finished
43*12333Shelge 	 */
4412077Shelge 	if (ioctl(fd, RXIOC_FORMAT, &idens) != NULL)
45*12333Shelge 		perror(devname);
4612077Shelge 	close (fd);
4712077Shelge }
4812077Shelge 
4912077Shelge usage()
5012077Shelge {
5112077Shelge 	fprintf(stderr, "usage: rxformat [-d] /dev/rx?\n");
5212077Shelge 	exit (0);
5312077Shelge }
54