xref: /csrg-svn/old/rxformat/rxformat.c (revision 14556)
1*14556Ssam #ifndef lint
2*14556Ssam static char sccsid[] = "@(#)rxformat.c	4.5 (Berkeley) 08/11/83";
3*14556Ssam #endif
412077Shelge 
512077Shelge #include <stdio.h>
612077Shelge #include <sys/file.h>
712077Shelge #include <errno.h>
812896Ssam #include <vaxuba/rxreg.h>
912077Shelge 
1012333Shelge char devname[] = "/dev/rrx?a";
1112333Shelge 
1212077Shelge /*
1312896Ssam  * Format RX02 floppy disks.
1412077Shelge  */
1512333Shelge 
1612077Shelge main(argc, argv)
1712077Shelge 	int argc;
1812077Shelge 	char *argv[];
1912077Shelge {
2012077Shelge 	int fd, idens = 0, filarg = 1;
2112077Shelge 
2212077Shelge 	if (argc < 2)
2312077Shelge 		usage();
2412077Shelge 	if (argc == 3) {
2512077Shelge 		if (strncmp(argv[1],"-d",2) != 0)
2612077Shelge 			usage();
2712077Shelge 		idens++;
2812333Shelge 		filarg++;
2912077Shelge 	}
3012333Shelge 	devname[8] = argv[filarg][7];
3112896Ssam 	if ((fd = open(devname, O_RDWR)) < NULL) {
3212333Shelge 		perror(devname);
3312077Shelge 		exit (0);
3412077Shelge 	}
3512333Shelge 	printf("Format %s to", argv[filarg]);
3612077Shelge 	if (idens)
3712077Shelge 		printf(" double density (y/n) ?");
3812077Shelge 	else
3912077Shelge 		printf(" single density (y/n) ?");
4012077Shelge 	if (getchar() != 'y')
4112077Shelge 		exit (0);
4212333Shelge 	/*
4312896Ssam 	 * Change the ioctl command when dkio.h has
4412896Ssam 	 * been finished.
4512333Shelge 	 */
4612077Shelge 	if (ioctl(fd, RXIOC_FORMAT, &idens) != NULL)
4712333Shelge 		perror(devname);
4812077Shelge 	close (fd);
4912077Shelge }
5012077Shelge 
5112077Shelge usage()
5212077Shelge {
5312077Shelge 	fprintf(stderr, "usage: rxformat [-d] /dev/rx?\n");
5412077Shelge 	exit (0);
5512077Shelge }
56