kernel - Fix smbfs readdir and umount
[dragonfly.git] / usr.bin / kdump / mkioctls
blob120adfa11cf4bb10f9bdc225f219b432c3bcf263
1 #!/bin/sh
3 # $FreeBSD: src/usr.bin/kdump/mkioctls,v 1.15.2.5 2002/11/15 18:22:31 ru Exp $
5 set -e
7 if [ "x$1" = "x-s" ]; then
8 use_switch=1
9 shift
10 else
11 use_switch=0
14 if [ -z "$1" -o -z "$2" ]; then
15 echo "usage: sh $0 [-s] include-dir current-dir"
16 exit 1
19 LC_ALL=C; export LC_ALL
21 # Build a list of headers that have ioctls in them.
22 # Leave out fake softlinks.
23 ioctl_includes=`
24 cd $1
25 find -s * -name '*.h' -follow |
26 egrep -v '^(cam/)|^(compat/)|^(fs/)|^(isofs/)|^(mfs/)|^(msdosfs/)|^(netipsec/)|^(netkey/)|^(netsmb/)|^(nfs/)|^(ntfs/)|^(pccard/)|^(ufs/)' |
27 xargs egrep -l \
28 '^#[ ]*define[ ]+[A-Za-z_][A-Za-z0-9_]*[ ]+_IO[^a-z0-9_]' |
29 awk '{printf("#include <%s>\\\\n", $1)}'
30 printf '#undef loff_t /* XXX ext2_fs.h defines it */\\\\n'
31 printf '#include <dev/drm/include/uapi_drm/drm.h>\\\\n'
32 printf '#include <dev/drm/include/uapi_drm/i915_drm.h>\\\\n'
33 printf '#include <dev/drm/include/uapi_drm/radeon_drm.h>\\\\n'
36 awk -v x="$ioctl_includes" 'BEGIN {print x}' |
37 gcc -D_KERNEL_STRUCTURES -E -I$1 -I$2/../../sys -I$2/../../sys/dev/drm/include -dM - |
38 awk -v ioctl_includes="$ioctl_includes" -v use_switch="$use_switch" '
39 BEGIN {
40 print "/* XXX obnoxious prerequisites. */"
41 print "#define _KERNEL_STRUCTURES"
42 print "#include <sys/tty.h>"
43 print "#include <net/if_arp.h>"
44 print "#include <net/route.h>"
45 print "#include <netinet/in.h>"
46 print "#include <net/ip_mroute/ip_mroute.h>"
47 print "#include <netinet6/nd6.h>"
48 print "#include <netinet6/ip6_mroute.h>"
49 print "#include <stdio.h>"
50 print "#include <cam/cam.h>"
51 print "#define ACPI_DEBUG_OUTPUT"
52 print "#define ACPI_APPLICATION"
53 print "#include <contrib/dev/acpica/source/include/acpi.h>"
54 print "#undef ACPI_APPLICATION"
55 print "#undef ACPI_DEBUG_OUTPUT"
56 print ""
57 print ioctl_includes
58 print "const char *ioctlname(u_long);"
59 print ""
60 print "const char *"
61 print "ioctlname(u_long val)"
62 print "{"
63 if (use_switch)
64 print "\tswitch(val) {"
67 /^#[ ]*define[ ]+[A-Za-z_][A-Za-z0-9_]*[ ]+_IO/ {
69 # find where the name starts
70 for (i = 1; i <= NF; i++)
71 if ($i ~ /define/)
72 break;
73 ++i;
75 if (use_switch)
76 printf("\tcase %s:\n\t\treturn(\"%s\");\n", $i, $i);
77 else
78 printf("\tif (val == %s)\n\t\treturn(\"%s\");\n", $i, $i);
82 /^#[ ]*define[ ]+[^ ]+[ ]+DRM_IO/ {
83 if (use_switch)
84 printf("\tcase %s:\n\t\treturn(\"%s\");\n", $2, $2);
85 else
86 printf("\tif (val == %s)\n\t\treturn(\"%s\");\n", $2, $2);
89 /^#[ ]*define[ ]+[^ ]+[ ]+MIXER_(READ|WRITE)/ {
90 if (use_switch)
91 printf("\tcase %s:\n\t\treturn(\"%s\");\n", $2, $2);
92 else
93 printf("\tif (val == %s)\n\t\treturn(\"%s\");\n", $2, $2);
96 END {
97 if (use_switch)
98 print "\t}"
99 print "\n\treturn(NULL);"
100 print "}"