xref: /original-bsd/old/rxformat/rxformat.c (revision 23a40993)
1 /*	rxformat.c	4.4	83/06/02	*/
2 
3 #include <stdio.h>
4 #include <sys/file.h>
5 #include <errno.h>
6 #include <vaxuba/rxreg.h>
7 
8 char devname[] = "/dev/rrx?a";
9 
10 /*
11  * Format RX02 floppy disks.
12  */
13 
14 main(argc, argv)
15 	int argc;
16 	char *argv[];
17 {
18 	int fd, idens = 0, filarg = 1;
19 
20 	if (argc < 2)
21 		usage();
22 	if (argc == 3) {
23 		if (strncmp(argv[1],"-d",2) != 0)
24 			usage();
25 		idens++;
26 		filarg++;
27 	}
28 	devname[8] = argv[filarg][7];
29 	if ((fd = open(devname, O_RDWR)) < NULL) {
30 		perror(devname);
31 		exit (0);
32 	}
33 	printf("Format %s to", argv[filarg]);
34 	if (idens)
35 		printf(" double density (y/n) ?");
36 	else
37 		printf(" single density (y/n) ?");
38 	if (getchar() != 'y')
39 		exit (0);
40 	/*
41 	 * Change the ioctl command when dkio.h has
42 	 * been finished.
43 	 */
44 	if (ioctl(fd, RXIOC_FORMAT, &idens) != NULL)
45 		perror(devname);
46 	close (fd);
47 }
48 
49 usage()
50 {
51 	fprintf(stderr, "usage: rxformat [-d] /dev/rx?\n");
52 	exit (0);
53 }
54