bridge(4): document net.link.bridge.pfil_onlyip
[dragonfly.git] / usr.sbin / fdcontrol / fdcontrol.c
blob1637da8dff229c10ef08b7bcc9a76a25403b51b0
1 /*
2 * Copyright (C) 1994 by Joerg Wunsch, Dresden
3 * All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY
15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE
18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
20 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
21 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
22 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
24 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
25 * DAMAGE.
27 * $FreeBSD: src/usr.sbin/fdcontrol/fdcontrol.c,v 1.6 1999/08/28 01:16:13 peter Exp $
30 #include <err.h>
31 #include <fcntl.h>
32 #include <stdio.h>
33 #include <stdlib.h>
34 #include <unistd.h>
35 #include <machine/ioctl_fd.h>
37 static int
38 getnumber(void)
40 int i;
41 char b[80];
43 fgets(b, 80, stdin);
44 if (b[0] == '\n')
45 return -1;
47 sscanf(b, " %i", &i);
48 return i;
51 __dead2 static void
52 usage(void)
54 fprintf(stderr, "usage: fdcontrol device-node\n");
55 exit(2);
59 #define ask(name, fmt) do { \
60 printf(#name "? [" fmt "]: ", ft.name); fflush(stdout); \
61 if((i = getnumber()) != -1) \
62 ft.name = i; \
63 } while (0)
65 int
66 main(int argc, char **argv)
68 struct fd_type ft;
69 int fd, i;
71 if (argc != 2)
72 usage();
74 if ((fd = open(argv[1], 0)) < 0) {
75 warn("open(floppy)");
76 return 1;
79 if (ioctl(fd, FD_GTYPE, &ft) < 0) {
80 warn("ioctl(FD_GTYPE)");
81 return 1;
84 ask(sectrac, "%d");
85 ask(secsize, "%d");
86 ask(datalen, "0x%x");
87 ask(gap, "0x%x");
88 ask(tracks, "%d");
89 ask(size, "%d");
90 ask(steptrac, "%d");
91 ask(trans, "%d");
92 ask(heads, "%d");
93 ask(f_gap, "0x%x");
94 ask(f_inter, "%d");
96 if(ioctl(fd, FD_STYPE, &ft) < 0) {
97 warn("ioctl(FD_STYPE)");
98 return 1;
100 return 0;