3 # $FreeBSD: src/usr.bin/kdump/mkioctls,v 1.15.2.5 2002/11/15 18:22:31 ru Exp $
7 if [ "x$1" = "x-s" ]; then
15 echo "usage: sh $0 [-s] include-dir"
19 LC_ALL=C; export LC_ALL
21 # Build a list of headers that have ioctls in them.
22 # XXX should we use an ANSI cpp?
23 # XXX leave out cam/, fs/, netatalk/, netatm/, netnatm/, netsmb/, nwfs/,
24 # and ufs/ because they are fake softlinks
27 find -s * -name '*.h' -follow |
28 egrep -v '^(cam/)|^(fs/)|^(netatalk/)|^(netatm/)|^(netnatm/)|^(netsmb/)|^(nwfs/)|^(ufs/)' |
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}' |
35 gcc -D_KERNEL_STRUCTURES -E -I$1 -dM - |
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/tty.h>"
42 print "#include <net/if_arp.h>"
43 print "#include <net/route.h>"
44 print "#include <netatm/atm.h>"
45 print "#include <netatm/atm_if.h>"
46 print "#include <netatm/atm_sap.h>"
47 print "#include <netatm/atm_sys.h>"
48 print "#include <netinet/in.h>"
49 print "#include <net/ip_mroute/ip_mroute.h>"
50 print "#include <netinet6/nd6.h>"
51 print "#include <netinet6/ip6_mroute.h>"
52 print "#include <stdio.h>"
53 print "#include <cam/cam.h>"
56 print "const char *ioctlname(u_long);"
59 print "ioctlname(u_long val)"
62 print "\tswitch(val) {"
65 /^#[ ]*define[ ]+[A-Za-z_][A-Za-z0-9_]*[ ]+_IO/ {
67 # find where the name starts
68 for (i = 1; i <= NF; i++)
74 printf("\tcase %s:\n\t\treturn(\"%s\");\n", $i, $i);
76 printf("\tif (val == %s)\n\t\treturn(\"%s\");\n", $i, $i);
82 print "\n\treturn(NULL);"