xref: /csrg-svn/old/rxformat/rxformat.c (revision 21177)
1*21177Sdist /*
2*21177Sdist  * Copyright (c) 1980 Regents of the University of California.
3*21177Sdist  * All rights reserved.  The Berkeley software License Agreement
4*21177Sdist  * specifies the terms and conditions for redistribution.
5*21177Sdist  */
6*21177Sdist 
714556Ssam #ifndef lint
8*21177Sdist char copyright[] =
9*21177Sdist "@(#) Copyright (c) 1980 Regents of the University of California.\n\
10*21177Sdist  All rights reserved.\n";
11*21177Sdist #endif not lint
1212077Shelge 
13*21177Sdist #ifndef lint
14*21177Sdist static char sccsid[] = "@(#)rxformat.c	5.1 (Berkeley) 05/28/85";
15*21177Sdist #endif not lint
16*21177Sdist 
1712077Shelge #include <stdio.h>
1812077Shelge #include <sys/file.h>
1912077Shelge #include <errno.h>
2012896Ssam #include <vaxuba/rxreg.h>
2112077Shelge 
2212333Shelge char devname[] = "/dev/rrx?a";
2312333Shelge 
2412077Shelge /*
2512896Ssam  * Format RX02 floppy disks.
2612077Shelge  */
2712333Shelge 
2812077Shelge main(argc, argv)
2912077Shelge 	int argc;
3012077Shelge 	char *argv[];
3112077Shelge {
3212077Shelge 	int fd, idens = 0, filarg = 1;
3312077Shelge 
3412077Shelge 	if (argc < 2)
3512077Shelge 		usage();
3612077Shelge 	if (argc == 3) {
3712077Shelge 		if (strncmp(argv[1],"-d",2) != 0)
3812077Shelge 			usage();
3912077Shelge 		idens++;
4012333Shelge 		filarg++;
4112077Shelge 	}
4212333Shelge 	devname[8] = argv[filarg][7];
4312896Ssam 	if ((fd = open(devname, O_RDWR)) < NULL) {
4412333Shelge 		perror(devname);
4512077Shelge 		exit (0);
4612077Shelge 	}
4712333Shelge 	printf("Format %s to", argv[filarg]);
4812077Shelge 	if (idens)
4912077Shelge 		printf(" double density (y/n) ?");
5012077Shelge 	else
5112077Shelge 		printf(" single density (y/n) ?");
5212077Shelge 	if (getchar() != 'y')
5312077Shelge 		exit (0);
5412333Shelge 	/*
5512896Ssam 	 * Change the ioctl command when dkio.h has
5612896Ssam 	 * been finished.
5712333Shelge 	 */
5812077Shelge 	if (ioctl(fd, RXIOC_FORMAT, &idens) != NULL)
5912333Shelge 		perror(devname);
6012077Shelge 	close (fd);
6112077Shelge }
6212077Shelge 
6312077Shelge usage()
6412077Shelge {
6512077Shelge 	fprintf(stderr, "usage: rxformat [-d] /dev/rx?\n");
6612077Shelge 	exit (0);
6712077Shelge }
68