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