xref: /csrg-svn/old/rxformat/rxformat.c (revision 12078)
1 /*	rxformat.c	4.2	83/04/28	*/
2 
3 #include <stdio.h>
4 #include <sys/file.h>
5 #include <errno.h>
6 #include "/sys/vaxuba/rxreg.h"
7 
8 /*
9  * format floppy disks on RX02
10  */
11 main(argc, argv)
12 	int argc;
13 	char *argv[];
14 {
15 	int fd, idens = 0, filarg = 1;
16 
17 	if (argc < 2)
18 		usage();
19 	if (argc == 3) {
20 		if (strncmp(argv[1],"-d",2) != 0)
21 			usage();
22 		idens++;
23 		filarg = 2;
24 	}
25 	if ((fd = open(argv[filarg], FRDWR, 0666)) < NULL) {
26 		perror(argv[filarg]);
27 		exit (0);
28 	}
29 	printf("Format %s to", *(argv[filarg]));
30 	if (idens)
31 		printf(" double density (y/n) ?");
32 	else
33 		printf(" single density (y/n) ?");
34 	if (getchar() != 'y')
35 		exit (0);
36 	if (ioctl(fd, RXIOC_FORMAT, &idens) != NULL)
37 		perror(argv[2]);
38 	close (fd);
39 }
40 
41 usage()
42 {
43 	fprintf(stderr, "usage: rxformat [-d] /dev/rx?\n");
44 	exit (0);
45 }
46