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 # if /bin/sh is bash this will avoid further errors due to missing commands
22 if set -o | grep -q pipefail; then
27 if [ "${MK_PF}" = "no" ]; then
28 filter='egrep -v (net/pfvar|net/if_pfsync)\.h'
30 # find -s would avoid the need to invoke sort but it is non-portable
31 find -L ./* -type f -name '*.h' | \
35 '^#[ ]*define[ ]+[A-Za-z_][A-Za-z0-9_]*[ ]+_IO[^a-z0-9_]' |
36 awk '{printf("#include <%s>\\n", $1)}'
39 if [ -z "$ioctl_includes" ]; then
40 echo "Failed to build list of ioctl headers"
44 awk -v x="$ioctl_includes" 'BEGIN {print x}' |
45 $CPP -nostdinc -I$includedir -dM -DCOMPAT_43TTY - |
46 awk -v ioctl_includes="$ioctl_includes" '
48 print "/* XXX obnoxious prerequisites. */"
49 print "#define COMPAT_43"
50 print "#define COMPAT_43TTY"
51 print "#include <sys/param.h>"
52 print "#include <sys/devicestat.h>"
53 print "#include <sys/disklabel.h>"
54 print "#include <sys/mman.h>"
55 print "#include <sys/socket.h>"
56 print "#include <sys/time.h>"
57 print "#include <sys/tty.h>"
58 print "#include <bsm/audit.h>"
59 print "#include <net/ethernet.h>"
60 print "#include <net/if.h>"
62 print "#include <net/pfvar.h>"
63 print "#include <net/if_pfsync.h>"
65 print "#include <net/route.h>"
66 print "#include <netinet/in.h>"
67 print "#include <netinet/ip_mroute.h>"
68 print "#include <netinet6/in6_var.h>"
69 print "#include <netinet6/nd6.h>"
70 print "#include <netinet6/ip6_mroute.h>"
71 print "#include <stdio.h>"
72 print "#include <cam/cam.h>"
73 print "#include <stdbool.h>"
74 print "#include <stddef.h>"
75 print "#include <stdint.h>"
76 print "#include <sysdecode.h>"
81 print "sysdecode_ioctlname(unsigned long val)"
83 print "\tconst char *str = NULL;"
87 /^#[ ]*define[ ]+[A-Za-z_][A-Za-z0-9_]*[ ]+_IO/ {
89 # find where the name starts
90 for (i = 1; i <= NF; i++)
98 printf("if (val == %s)\n", $i);
99 printf("\t\tstr = \"%s\";\n", $i);
103 print "\treturn (str);"