8 echo "usage: sh $0 include-dir"
14 LC_ALL=C; export LC_ALL
16 # Build a list of headers that have ioctls in them.
17 # XXX should we use an ANSI cpp?
21 filter='(.*disk.*)\.h'
22 if [ "${MK_PF}" == "no" ]; then
23 filter="(${filter})|((net/pfvar|net/if_pfsync)\.h)"
26 find -H -s * -name '*.h' | \
27 egrep -v ${filter} | \
29 '^#[ ]*define[ ]+[A-Za-z_][A-Za-z0-9_]*[ ]+_IO[^a-z0-9_]' |
30 awk '{printf("#include <%s>\\n", $1)}'
33 : ${MACHINE=$(uname -m)}
36 ioctl_includes="$ioctl_includes#include <sys/diskpc98.h>\\n"
39 ioctl_includes="$ioctl_includes#include <sys/diskmbr.h>\\n"
43 awk -v x="$ioctl_includes" 'BEGIN {print x}' |
44 $CPP -nostdinc -I$includedir -dM -DCOMPAT_43TTY - |
45 awk -v ioctl_includes="$ioctl_includes" '
47 print "/* XXX obnoxious prerequisites. */"
48 print "#define COMPAT_43"
49 print "#define COMPAT_43TTY"
50 print "#include <sys/param.h>"
51 print "#include <sys/devicestat.h>"
52 print "#include <sys/disklabel.h>"
53 print "#include <sys/socket.h>"
54 print "#include <sys/time.h>"
55 print "#include <sys/tty.h>"
56 print "#include <bsm/audit.h>"
57 print "#include <net/ethernet.h>"
58 print "#include <net/if.h>"
60 print "#include <net/pfvar.h>"
61 print "#include <net/if_pfsync.h>"
63 print "#include <net/route.h>"
64 print "#include <netinet/in.h>"
65 print "#include <netinet/ip_mroute.h>"
66 print "#include <netinet6/in6_var.h>"
67 print "#include <netinet6/nd6.h>"
68 print "#include <netinet6/ip6_mroute.h>"
69 print "#include <stdio.h>"
70 print "#include <cam/cam.h>"
71 print "#include <stdbool.h>"
72 print "#include <stddef.h>"
73 print "#include <stdint.h>"
74 print "#include <sysdecode.h>"
79 print "sysdecode_ioctlname(unsigned long val)"
81 print "\tconst char *str = NULL;"
85 /^#[ ]*define[ ]+[A-Za-z_][A-Za-z0-9_]*[ ]+_IO/ {
87 # find where the name starts
88 for (i = 1; i <= NF; i++)
96 printf("if (val == %s)\n", $i);
97 printf("\t\tstr = \"%s\";\n", $i);
101 print "\treturn (str);"