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?
20 find -H -s * -name '*.h' | \
21 egrep -v '(.*disk.*|net/pfvar|net/if_pfsync)\.h' | \
23 '^#[ ]*define[ ]+[A-Za-z_][A-Za-z0-9_]*[ ]+_IO[^a-z0-9_]' |
24 awk '{printf("#include <%s>\\n", $1)}'
27 : ${MACHINE=$(uname -m)}
30 ioctl_includes="$ioctl_includes#include <sys/diskpc98.h>\\n"
33 ioctl_includes="$ioctl_includes#include <sys/diskmbr.h>\\n"
37 awk -v x="$ioctl_includes" 'BEGIN {print x}' |
38 $CPP -nostdinc -I$includedir -dM -DCOMPAT_43TTY - |
39 awk -v ioctl_includes="$ioctl_includes" '
41 print "/* XXX obnoxious prerequisites. */"
42 print "#define COMPAT_43"
43 print "#define COMPAT_43TTY"
44 print "#include <sys/param.h>"
45 print "#include <sys/devicestat.h>"
46 print "#include <sys/disklabel.h>"
47 print "#include <sys/socket.h>"
48 print "#include <sys/time.h>"
49 print "#include <sys/tty.h>"
50 print "#include <bsm/audit.h>"
51 print "#include <net/ethernet.h>"
52 print "#include <net/if.h>"
54 print "#include <net/pfvar.h>"
55 print "#include <net/if_pfsync.h>"
57 print "#include <net/route.h>"
58 print "#include <netinet/in.h>"
59 print "#include <netinet/ip_mroute.h>"
60 print "#include <netinet6/in6_var.h>"
61 print "#include <netinet6/nd6.h>"
62 print "#include <netinet6/ip6_mroute.h>"
63 print "#include <stdio.h>"
64 print "#include <cam/cam.h>"
65 print "#include <stddef.h>"
66 print "#include <stdint.h>"
67 print "#include <sysdecode.h>"
72 print "sysdecode_ioctlname(unsigned long val)"
74 print "\tconst char *str = NULL;"
78 /^#[ ]*define[ ]+[A-Za-z_][A-Za-z0-9_]*[ ]+_IO/ {
80 # find where the name starts
81 for (i = 1; i <= NF; i++)
89 printf("if (val == %s)\n", $i);
90 printf("\t\tstr = \"%s\";\n", $i);
94 print "\treturn (str);"