date and time created 88/10/19 11:50:43 by bostic
[unix-history] / usr / src / old / rxformat / rxformat.c
CommitLineData
8c5eec2f
DF
1/*
2 * Copyright (c) 1980 Regents of the University of California.
3 * All rights reserved. The Berkeley software License Agreement
4 * specifies the terms and conditions for redistribution.
5 */
6
7#ifndef lint
8char copyright[] =
9"@(#) Copyright (c) 1980 Regents of the University of California.\n\
10 All rights reserved.\n";
11#endif not lint
12
524aa063 13#ifndef lint
fcfbc8b6 14static char sccsid[] = "@(#)rxformat.c 5.4 (Berkeley) %G%";
8c5eec2f 15#endif not lint
b0564e95
HS
16
17#include <stdio.h>
18#include <sys/file.h>
19#include <errno.h>
2f887e17 20#include <vaxuba/rxreg.h>
b0564e95 21
f2685c79
HS
22char devname[] = "/dev/rrx?a";
23
b0564e95 24/*
2f887e17 25 * Format RX02 floppy disks.
b0564e95 26 */
f2685c79 27
b0564e95
HS
28main(argc, argv)
29 int argc;
30 char *argv[];
31{
32 int fd, idens = 0, filarg = 1;
fdeafb05 33 int i, c;
b0564e95 34
fdeafb05 35 if (argc < 2 || argc > 3)
b0564e95
HS
36 usage();
37 if (argc == 3) {
38 if (strncmp(argv[1],"-d",2) != 0)
39 usage();
40 idens++;
f2685c79 41 filarg++;
b0564e95 42 }
f2685c79 43 devname[8] = argv[filarg][7];
fdeafb05 44 if ((fd = open(devname, O_RDWR)) < 0) {
f2685c79 45 perror(devname);
fdeafb05 46 exit(1);
b0564e95 47 }
fdeafb05
JB
48 if (isatty(fileno(stdin))) {
49 printf("Format %s to %s density (y/n)? ",
50 argv[filarg], idens ? "double" : "single");
51 i = c = getchar();
52 while (c != '\n' && c != EOF)
53 c = getchar();
54 if (i != 'y')
55 exit(0);
56 } else
57 printf("Formatting %s to %s density\n",
58 argv[filarg], idens ? "double" : "single");
f2685c79 59 /*
2f887e17
SL
60 * Change the ioctl command when dkio.h has
61 * been finished.
f2685c79 62 */
fdeafb05
JB
63 if (ioctl(fd, RXIOC_FORMAT, &idens) == 0)
64 exit(0);
65 else {
f2685c79 66 perror(devname);
fdeafb05
JB
67 exit(1);
68 }
b0564e95
HS
69}
70
71usage()
72{
73 fprintf(stderr, "usage: rxformat [-d] /dev/rx?\n");
fdeafb05 74 exit(1);
b0564e95 75}