xref: /csrg-svn/old/rxformat/rxformat.c (revision 12896)
1*12896Ssam /*	rxformat.c	4.4	83/06/02	*/
212077Shelge 
312077Shelge #include <stdio.h>
412077Shelge #include <sys/file.h>
512077Shelge #include <errno.h>
6*12896Ssam #include <vaxuba/rxreg.h>
712077Shelge 
812333Shelge char devname[] = "/dev/rrx?a";
912333Shelge 
1012077Shelge /*
11*12896Ssam  * Format RX02 floppy disks.
1212077Shelge  */
1312333Shelge 
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++;
2612333Shelge 		filarg++;
2712077Shelge 	}
2812333Shelge 	devname[8] = argv[filarg][7];
29*12896Ssam 	if ((fd = open(devname, O_RDWR)) < NULL) {
3012333Shelge 		perror(devname);
3112077Shelge 		exit (0);
3212077Shelge 	}
3312333Shelge 	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);
4012333Shelge 	/*
41*12896Ssam 	 * Change the ioctl command when dkio.h has
42*12896Ssam 	 * been finished.
4312333Shelge 	 */
4412077Shelge 	if (ioctl(fd, RXIOC_FORMAT, &idens) != NULL)
4512333Shelge 		perror(devname);
4612077Shelge 	close (fd);
4712077Shelge }
4812077Shelge 
4912077Shelge usage()
5012077Shelge {
5112077Shelge 	fprintf(stderr, "usage: rxformat [-d] /dev/rx?\n");
5212077Shelge 	exit (0);
5312077Shelge }
54