121177Sdist /*
239889Sbostic * Copyright (c) 1983 The Regents of the University of California.
339889Sbostic * All rights reserved.
439889Sbostic *
542820Sbostic * %sccs.include.redist.c%
621177Sdist */
721177Sdist
814556Ssam #ifndef lint
921177Sdist char copyright[] =
1039889Sbostic "@(#) Copyright (c) 1983 The Regents of the University of California.\n\
1121177Sdist All rights reserved.\n";
1239889Sbostic #endif /* not lint */
1312077Shelge
1421177Sdist #ifndef lint
15*47874Ssklower static char sccsid[] = "@(#)rxformat.c 5.6 (Berkeley) 04/11/91";
1639889Sbostic #endif /* not lint */
1721177Sdist
1837980Sbostic #include <sys/file.h>
19*47874Ssklower #include <vax/uba/rxreg.h>
2012077Shelge #include <stdio.h>
2112077Shelge #include <errno.h>
2239889Sbostic #include "pathnames.h"
2312077Shelge
2437980Sbostic char devname[] = _PATH_DEVNAME;
2512333Shelge
2612077Shelge /*
2712896Ssam * Format RX02 floppy disks.
2812077Shelge */
2912333Shelge
main(argc,argv)3012077Shelge main(argc, argv)
3112077Shelge int argc;
3212077Shelge char *argv[];
3312077Shelge {
3412077Shelge int fd, idens = 0, filarg = 1;
3524446Sbloom int i, c;
3612077Shelge
3724446Sbloom if (argc < 2 || argc > 3)
3812077Shelge usage();
3912077Shelge if (argc == 3) {
4012077Shelge if (strncmp(argv[1],"-d",2) != 0)
4112077Shelge usage();
4212077Shelge idens++;
4312333Shelge filarg++;
4412077Shelge }
4512333Shelge devname[8] = argv[filarg][7];
4624446Sbloom if ((fd = open(devname, O_RDWR)) < 0) {
4712333Shelge perror(devname);
4824446Sbloom exit(1);
4912077Shelge }
5024446Sbloom if (isatty(fileno(stdin))) {
5124446Sbloom printf("Format %s to %s density (y/n)? ",
5224446Sbloom argv[filarg], idens ? "double" : "single");
5324446Sbloom i = c = getchar();
5424446Sbloom while (c != '\n' && c != EOF)
5524446Sbloom c = getchar();
5624446Sbloom if (i != 'y')
5724446Sbloom exit(0);
5824446Sbloom } else
5924446Sbloom printf("Formatting %s to %s density\n",
6024446Sbloom argv[filarg], idens ? "double" : "single");
6112333Shelge /*
6212896Ssam * Change the ioctl command when dkio.h has
6312896Ssam * been finished.
6412333Shelge */
6524446Sbloom if (ioctl(fd, RXIOC_FORMAT, &idens) == 0)
6624446Sbloom exit(0);
6724446Sbloom else {
6812333Shelge perror(devname);
6924446Sbloom exit(1);
7024446Sbloom }
7112077Shelge }
7212077Shelge
usage()7312077Shelge usage()
7412077Shelge {
7512077Shelge fprintf(stderr, "usage: rxformat [-d] /dev/rx?\n");
7624446Sbloom exit(1);
7712077Shelge }
78