3 # $FreeBSD: src/usr.bin/kdump/mkioctls,v 1.15.2.5 2002/11/15 18:22:31 ru Exp $
4 # $DragonFly: src/usr.bin/kdump/mkioctls,v 1.7 2007/05/20 23:21:37 dillon Exp $
6 if [ "x$1" = "x-s" ]; then
14 echo "usage: sh $0 [-s] include-dir"
18 LC_ALL=C; export LC_ALL
20 # Build a list of headers that have ioctls in them.
21 # XXX should we use an ANSI cpp?
22 # XXX netipx conflicts with netns (leave out netns).
23 # XXX leave out cam/, isa/ pccard/, pci/, and usb/ because they
24 # are fake softlinks and handled by bus/
27 find -s * -name '*.h' -follow |
28 egrep -v '^(netns/)|^(cam/)|^(isa/)|^(pccard/)|^(pci/)|^(usb/)|^(netproto/natm/)' |
30 '^#[ ]*define[ ]+[A-Za-z_][A-Za-z0-9_]*[ ]+_IO[^a-z0-9_]' |
31 awk '{printf("#include <%s>\\\\n", $1)}'
34 awk -v x="$ioctl_includes" 'BEGIN {print x}' |
36 awk -v ioctl_includes="$ioctl_includes" -v use_switch="$use_switch" '
38 print "/* XXX obnoxious prerequisites. */"
39 print "#define COMPAT_43"
40 print "#define _KERNEL_STRUCTURES"
41 print "#include <sys/param.h>"
42 print "#include <sys/devicestat.h>"
43 print "#include <sys/disklabel.h>"
44 print "#include <sys/diskslice.h>"
45 print "#include <sys/socket.h>"
46 print "#include <sys/time.h>"
47 print "#include <sys/tty.h>"
48 print "#include <net/ethernet.h>"
49 print "#include <net/if.h>"
50 print "#include <net/if_var.h>"
51 print "#include <net/route.h>"
52 print "#include <netatm/atm.h>"
53 print "#include <netatm/atm_if.h>"
54 print "#include <netatm/atm_sap.h>"
55 print "#include <netatm/atm_sys.h>"
56 print "#include <netinet/in.h>"
57 print "#include <net/ip_mroute/ip_mroute.h>"
58 print "#include <netinet6/in6_var.h>"
59 print "#include <netinet6/nd6.h>"
60 print "#include <netinet6/ip6_mroute.h>"
61 print "#include <cam/cam.h>"
62 print "#include <stdio.h>"
67 print "ioctlname(register_t val)"
71 print "\tswitch(val) {"
74 /^#[ ]*define[ ]+[A-Za-z_][A-Za-z0-9_]*[ ]+_IO/ {
76 # find where the name starts
77 for (i = 1; i <= NF; i++)
83 printf("\tcase %s:\n\t\treturn(\"%s\");\n", $i, $i);
85 printf("\tif (val == %s)\n\t\treturn(\"%s\");\n", $i, $i);
91 print "\n\treturn(NULL);"