xref: /csrg-svn/old/rxformat/rxformat.c (revision 24446)
121177Sdist /*
221177Sdist  * Copyright (c) 1980 Regents of the University of California.
321177Sdist  * All rights reserved.  The Berkeley software License Agreement
421177Sdist  * specifies the terms and conditions for redistribution.
521177Sdist  */
621177Sdist 
714556Ssam #ifndef lint
821177Sdist char copyright[] =
921177Sdist "@(#) Copyright (c) 1980 Regents of the University of California.\n\
1021177Sdist  All rights reserved.\n";
1121177Sdist #endif not lint
1212077Shelge 
1321177Sdist #ifndef lint
14*24446Sbloom static char sccsid[] = "@(#)rxformat.c	5.2 (Berkeley) 08/28/85";
1521177Sdist #endif not lint
1621177Sdist 
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;
33*24446Sbloom 	int i, c;
3412077Shelge 
35*24446Sbloom 	if (argc < 2 || argc > 3)
3612077Shelge 		usage();
3712077Shelge 	if (argc == 3) {
3812077Shelge 		if (strncmp(argv[1],"-d",2) != 0)
3912077Shelge 			usage();
4012077Shelge 		idens++;
4112333Shelge 		filarg++;
4212077Shelge 	}
4312333Shelge 	devname[8] = argv[filarg][7];
44*24446Sbloom 	if ((fd = open(devname, O_RDWR)) < 0) {
4512333Shelge 		perror(devname);
46*24446Sbloom 		exit(1);
4712077Shelge 	}
48*24446Sbloom 	if (isatty(fileno(stdin))) {
49*24446Sbloom 		printf("Format %s to %s density (y/n)? ",
50*24446Sbloom 			argv[filarg], idens ? "double" : "single");
51*24446Sbloom 		i = c = getchar();
52*24446Sbloom 		while (c != '\n' && c != EOF)
53*24446Sbloom 			c = getchar();
54*24446Sbloom 		if (i != 'y')
55*24446Sbloom 			exit(0);
56*24446Sbloom 	} else
57*24446Sbloom 		printf("Formatting %s to %s density\n",
58*24446Sbloom 			argv[filarg], idens ? "double" : "single");
5912333Shelge 	/*
6012896Ssam 	 * Change the ioctl command when dkio.h has
6112896Ssam 	 * been finished.
6212333Shelge 	 */
63*24446Sbloom 	if (ioctl(fd, RXIOC_FORMAT, &idens) == 0)
64*24446Sbloom 		exit(0);
65*24446Sbloom 	else {
6612333Shelge 		perror(devname);
67*24446Sbloom 		exit(1);
68*24446Sbloom 	}
6912077Shelge }
7012077Shelge 
7112077Shelge usage()
7212077Shelge {
7312077Shelge 	fprintf(stderr, "usage: rxformat [-d] /dev/rx?\n");
74*24446Sbloom 	exit(1);
7512077Shelge }
76