| @@ -1,463 +1,469 @@ | | | @@ -1,463 +1,469 @@ |
1 | #!/bin/sh - | | 1 | #!/bin/sh - |
2 | copyright="\ | | 2 | copyright="\ |
3 | /* | | 3 | /* |
4 | * Copyright (c) 1992, 1993, 1994, 1995 | | 4 | * Copyright (c) 1992, 1993, 1994, 1995 |
5 | * The Regents of the University of California. All rights reserved. | | 5 | * The Regents of the University of California. All rights reserved. |
6 | * | | 6 | * |
7 | * Redistribution and use in source and binary forms, with or without | | 7 | * Redistribution and use in source and binary forms, with or without |
8 | * modification, are permitted provided that the following conditions | | 8 | * modification, are permitted provided that the following conditions |
9 | * are met: | | 9 | * are met: |
10 | * 1. Redistributions of source code must retain the above copyright | | 10 | * 1. Redistributions of source code must retain the above copyright |
11 | * notice, this list of conditions and the following disclaimer. | | 11 | * notice, this list of conditions and the following disclaimer. |
12 | * 2. Redistributions in binary form must reproduce the above copyright | | 12 | * 2. Redistributions in binary form must reproduce the above copyright |
13 | * notice, this list of conditions and the following disclaimer in the | | 13 | * notice, this list of conditions and the following disclaimer in the |
14 | * documentation and/or other materials provided with the distribution. | | 14 | * documentation and/or other materials provided with the distribution. |
15 | * 3. Neither the name of the University nor the names of its contributors | | 15 | * 3. Neither the name of the University nor the names of its contributors |
16 | * may be used to endorse or promote products derived from this software | | 16 | * may be used to endorse or promote products derived from this software |
17 | * without specific prior written permission. | | 17 | * without specific prior written permission. |
18 | * | | 18 | * |
19 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS \`\`AS IS'' AND | | 19 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS \`\`AS IS'' AND |
20 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | | 20 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
21 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | | 21 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
22 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | | 22 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE |
23 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | | 23 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
24 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | | 24 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
25 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | | 25 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
26 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | | 26 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
27 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | | 27 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
28 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | | 28 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
29 | * SUCH DAMAGE. | | 29 | * SUCH DAMAGE. |
30 | */ | | 30 | */ |
31 | " | | 31 | " |
32 | SCRIPT_ID='$NetBSD: vnode_if.sh,v 1.51 2008/11/19 14:10:49 pooka Exp $' | | 32 | SCRIPT_ID='$NetBSD: vnode_if.sh,v 1.52 2009/09/29 11:51:02 pooka Exp $' |
33 | | | 33 | |
34 | # Script to produce VFS front-end sugar. | | 34 | # Script to produce VFS front-end sugar. |
35 | # | | 35 | # |
36 | # usage: vnode_if.sh srcfile | | 36 | # usage: vnode_if.sh srcfile |
37 | # (where srcfile is currently /sys/kern/vnode_if.src) | | 37 | # (where srcfile is currently /sys/kern/vnode_if.src) |
38 | # | | 38 | # |
39 | | | 39 | |
40 | if [ $# -ne 1 ] ; then | | 40 | if [ $# -ne 1 ] ; then |
41 | echo 'usage: vnode_if.sh srcfile' | | 41 | echo 'usage: vnode_if.sh srcfile' |
42 | exit 1 | | 42 | exit 1 |
43 | fi | | 43 | fi |
44 | | | 44 | |
45 | # Name and revision of the source file. | | 45 | # Name and revision of the source file. |
46 | src=$1 | | 46 | src=$1 |
47 | SRC_ID=`head -1 $src | sed -e 's/.*\$\(.*\)\$.*/\1/'` | | 47 | SRC_ID=`head -1 $src | sed -e 's/.*\$\(.*\)\$.*/\1/'` |
48 | | | 48 | |
49 | # Names of the created files. | | 49 | # Names of the created files. |
50 | out_c=vnode_if.c | | 50 | out_c=vnode_if.c |
51 | out_rumpc=../rump/librump/rumpvfs/rumpvnode_if.c | | 51 | out_rumpc=../rump/librump/rumpvfs/rumpvnode_if.c |
52 | out_h=../sys/vnode_if.h | | 52 | out_h=../sys/vnode_if.h |
53 | out_rumph=../rump/include/rump/rumpvnode_if.h | | 53 | out_rumph=../rump/include/rump/rumpvnode_if.h |
54 | | | 54 | |
| | | 55 | # generate VNODE_LOCKDEBUG checks (not fully functional) |
| | | 56 | lockdebug=0 |
| | | 57 | |
55 | # Awk program (must support nawk extensions) | | 58 | # Awk program (must support nawk extensions) |
56 | # Use "awk" at Berkeley, "nawk" or "gawk" elsewhere. | | 59 | # Use "awk" at Berkeley, "nawk" or "gawk" elsewhere. |
57 | awk=${AWK:-awk} | | 60 | awk=${AWK:-awk} |
58 | | | 61 | |
59 | # Does this awk have a "toupper" function? (i.e. is it GNU awk) | | 62 | # Does this awk have a "toupper" function? (i.e. is it GNU awk) |
60 | isgawk=`$awk 'BEGIN { print toupper("true"); exit; }' 2>/dev/null` | | 63 | isgawk=`$awk 'BEGIN { print toupper("true"); exit; }' 2>/dev/null` |
61 | | | 64 | |
62 | # If this awk does not define "toupper" then define our own. | | 65 | # If this awk does not define "toupper" then define our own. |
63 | if [ "$isgawk" = TRUE ] ; then | | 66 | if [ "$isgawk" = TRUE ] ; then |
64 | # GNU awk provides it. | | 67 | # GNU awk provides it. |
65 | toupper= | | 68 | toupper= |
66 | else | | 69 | else |
67 | # Provide our own toupper() | | 70 | # Provide our own toupper() |
68 | toupper=' | | 71 | toupper=' |
69 | function toupper(str) { | | 72 | function toupper(str) { |
70 | _toupper_cmd = "echo "str" |tr a-z A-Z" | | 73 | _toupper_cmd = "echo "str" |tr a-z A-Z" |
71 | _toupper_cmd | getline _toupper_str; | | 74 | _toupper_cmd | getline _toupper_str; |
72 | close(_toupper_cmd); | | 75 | close(_toupper_cmd); |
73 | return _toupper_str; | | 76 | return _toupper_str; |
74 | }' | | 77 | }' |
75 | fi | | 78 | fi |
76 | | | 79 | |
77 | # | | 80 | # |
78 | # This is the common part of all awk programs that read $src | | 81 | # This is the common part of all awk programs that read $src |
79 | # This parses the input for one function into the arrays: | | 82 | # This parses the input for one function into the arrays: |
80 | # argdir, argtype, argname, willrele | | 83 | # argdir, argtype, argname, willrele |
81 | # and calls "doit()" to generate output for the function. | | 84 | # and calls "doit()" to generate output for the function. |
82 | # | | 85 | # |
83 | # Input to this parser is pre-processed slightly by sed | | 86 | # Input to this parser is pre-processed slightly by sed |
84 | # so this awk parser doesn't have to work so hard. The | | 87 | # so this awk parser doesn't have to work so hard. The |
85 | # changes done by the sed pre-processing step are: | | 88 | # changes done by the sed pre-processing step are: |
86 | # insert a space beween * and pointer name | | 89 | # insert a space beween * and pointer name |
87 | # replace semicolons with spaces | | 90 | # replace semicolons with spaces |
88 | # | | 91 | # |
89 | sed_prep='s:\*\([^\*/]\):\* \1:g | | 92 | sed_prep='s:\*\([^\*/]\):\* \1:g |
90 | s/;/ /' | | 93 | s/;/ /' |
91 | awk_parser=' | | 94 | awk_parser=' |
92 | # Comment line | | 95 | # Comment line |
93 | /^#/ { next; } | | 96 | /^#/ { next; } |
94 | # First line of description | | 97 | # First line of description |
95 | /^vop_/ { | | 98 | /^vop_/ { |
96 | name=rump $1; | | 99 | name=rump $1; |
97 | argc=0; | | 100 | argc=0; |
98 | willmake=-1; | | 101 | willmake=-1; |
99 | next; | | 102 | next; |
100 | } | | 103 | } |
101 | # Last line of description | | 104 | # Last line of description |
102 | /^}/ { | | 105 | /^}/ { |
103 | doit(); | | 106 | doit(); |
104 | next; | | 107 | next; |
105 | } | | 108 | } |
106 | # Middle lines of description | | 109 | # Middle lines of description |
107 | { | | 110 | { |
108 | argdir[argc] = $1; i=2; | | 111 | argdir[argc] = $1; i=2; |
109 | | | 112 | |
110 | if ($2 == "LOCKED=YES") { | | 113 | if ($2 == "LOCKED=YES") { |
111 | lockstate[argc] = 1; | | 114 | lockstate[argc] = 1; |
112 | i++; | | 115 | i++; |
113 | } else if ($2 == "LOCKED=NO") { | | 116 | } else if ($2 == "LOCKED=NO") { |
114 | lockstate[argc] = 0; | | 117 | lockstate[argc] = 0; |
115 | i++; | | 118 | i++; |
116 | } else | | 119 | } else |
117 | lockstate[argc] = -1; | | 120 | lockstate[argc] = -1; |
118 | | | 121 | |
119 | if ($2 == "WILLRELE" || | | 122 | if ($2 == "WILLRELE" || |
120 | $3 == "WILLRELE") { | | 123 | $3 == "WILLRELE") { |
121 | willrele[argc] = 1; | | 124 | willrele[argc] = 1; |
122 | i++; | | 125 | i++; |
123 | } else if ($2 == "WILLUNLOCK" || | | 126 | } else if ($2 == "WILLUNLOCK" || |
124 | $3 == "WILLUNLOCK") { | | 127 | $3 == "WILLUNLOCK") { |
125 | willrele[argc] = 2; | | 128 | willrele[argc] = 2; |
126 | i++; | | 129 | i++; |
127 | } else if ($2 == "WILLPUT" || | | 130 | } else if ($2 == "WILLPUT" || |
128 | $3 == "WILLPUT") { | | 131 | $3 == "WILLPUT") { |
129 | willrele[argc] = 3; | | 132 | willrele[argc] = 3; |
130 | i++; | | 133 | i++; |
131 | } else | | 134 | } else |
132 | willrele[argc] = 0; | | 135 | willrele[argc] = 0; |
133 | | | 136 | |
134 | if ($2 == "WILLMAKE") { | | 137 | if ($2 == "WILLMAKE") { |
135 | willmake=argc; | | 138 | willmake=argc; |
136 | i++; | | 139 | i++; |
137 | } | | 140 | } |
138 | | | 141 | |
139 | # XXX: replace non-portable types for rump. We should really | | 142 | # XXX: replace non-portable types for rump. We should really |
140 | # nuke the types from the kernel, but that is a battle for | | 143 | # nuke the types from the kernel, but that is a battle for |
141 | # another day. | | 144 | # another day. |
142 | at = $i; | | 145 | at = $i; |
143 | if (length(rump) != 0) { | | 146 | if (length(rump) != 0) { |
144 | if (at == "vm_prot_t") | | 147 | if (at == "vm_prot_t") |
145 | at = "int"; | | 148 | at = "int"; |
146 | if (at == "voff_t") | | 149 | if (at == "voff_t") |
147 | at = "off_t"; | | 150 | at = "off_t"; |
148 | } | | 151 | } |
149 | argtype[argc] = at; | | 152 | argtype[argc] = at; |
150 | i++; | | 153 | i++; |
151 | while (i < NF) { | | 154 | while (i < NF) { |
152 | argtype[argc] = argtype[argc]" "$i; | | 155 | argtype[argc] = argtype[argc]" "$i; |
153 | i++; | | 156 | i++; |
154 | } | | 157 | } |
155 | argname[argc] = $i; | | 158 | argname[argc] = $i; |
156 | argc++; | | 159 | argc++; |
157 | next; | | 160 | next; |
158 | } | | 161 | } |
159 | ' | | 162 | ' |
160 | | | 163 | |
161 | # This is put before the copyright on each generated file. | | 164 | # This is put before the copyright on each generated file. |
162 | warning="\ | | 165 | warning="\ |
163 | /* @NetBSD@ */ | | 166 | /* @NetBSD@ */ |
164 | | | 167 | |
165 | /* | | 168 | /* |
166 | * Warning: DO NOT EDIT! This file is automatically generated! | | 169 | * Warning: DO NOT EDIT! This file is automatically generated! |
167 | * (Modifications made here may easily be lost!) | | 170 | * (Modifications made here may easily be lost!) |
168 | * | | 171 | * |
169 | * Created from the file: | | 172 | * Created from the file: |
170 | * ${SRC_ID} | | 173 | * ${SRC_ID} |
171 | * by the script: | | 174 | * by the script: |
172 | * ${SCRIPT_ID} | | 175 | * ${SCRIPT_ID} |
173 | */ | | 176 | */ |
174 | " | | 177 | " |
175 | | | 178 | |
176 | # This is to satisfy McKusick (get rid of evil spaces 8^) | | 179 | # This is to satisfy McKusick (get rid of evil spaces 8^) |
177 | anal_retentive='s:\([^/]\*\) :\1:g' | | 180 | anal_retentive='s:\([^/]\*\) :\1:g' |
178 | | | 181 | |
179 | do_hfile () { | | 182 | do_hfile () { |
180 | # | | 183 | # |
181 | # Redirect stdout to the H file. | | 184 | # Redirect stdout to the H file. |
182 | # | | 185 | # |
183 | echo "$0: Creating $1" 1>&2 | | 186 | echo "$0: Creating $1" 1>&2 |
184 | exec > $1 | | 187 | exec > $1 |
185 | rump=$2 | | 188 | rump=$2 |
186 | | | 189 | |
187 | # Begin stuff | | 190 | # Begin stuff |
188 | if [ -z "${rump}" ]; then | | 191 | if [ -z "${rump}" ]; then |
189 | SYS='SYS_' | | 192 | SYS='SYS_' |
190 | else | | 193 | else |
191 | SYS='RUMP_RUMP' | | 194 | SYS='RUMP_RUMP' |
192 | fi | | 195 | fi |
193 | echo -n "$warning" | sed -e 's/\$//g;s/@/\$/g;s/ $//' | | 196 | echo -n "$warning" | sed -e 's/\$//g;s/@/\$/g;s/ $//' |
194 | echo "" | | 197 | echo "" |
195 | echo -n "$copyright" | | 198 | echo -n "$copyright" |
196 | echo '' | | 199 | echo '' |
197 | echo "#ifndef _${SYS}VNODE_IF_H_" | | 200 | echo "#ifndef _${SYS}VNODE_IF_H_" |
198 | echo "#define _${SYS}VNODE_IF_H_" | | 201 | echo "#define _${SYS}VNODE_IF_H_" |
199 | echo '' | | 202 | if [ ${lockdebug} -ne 0 ] ; then |
200 | echo '#ifdef _KERNEL_OPT' | | 203 | echo '' |
201 | echo '#include "opt_vnode_lockdebug.h"' | | 204 | echo '#ifdef _KERNEL_OPT' |
202 | echo '#endif /* _KERNEL_OPT */' | | 205 | echo '#include "opt_vnode_lockdebug.h"' |
| | | 206 | echo '#endif /* _KERNEL_OPT */' |
| | | 207 | fi |
203 | echo " | | 208 | echo " |
204 | extern const struct vnodeop_desc ${rump}vop_default_desc; | | 209 | extern const struct vnodeop_desc ${rump}vop_default_desc; |
205 | " | | 210 | " |
206 | | | 211 | |
207 | # Body stuff | | 212 | # Body stuff |
208 | # This awk program needs toupper() so define it if necessary. | | 213 | # This awk program needs toupper() so define it if necessary. |
209 | sed -e "$sed_prep" $src | $awk -v rump=${rump} "$toupper"' | | 214 | sed -e "$sed_prep" $src | $awk -v rump=${rump} "$toupper"' |
210 | function doit() { | | 215 | function doit() { |
211 | # Declare arg struct, descriptor. | | 216 | # Declare arg struct, descriptor. |
212 | printf("\n#define %s_DESCOFFSET %d\n", toupper(name), vop_offset++); | | 217 | printf("\n#define %s_DESCOFFSET %d\n", toupper(name), vop_offset++); |
213 | printf("struct %s_args {\n", name); | | 218 | printf("struct %s_args {\n", name); |
214 | printf("\tconst struct vnodeop_desc * a_desc;\n"); | | 219 | printf("\tconst struct vnodeop_desc * a_desc;\n"); |
215 | for (i=0; i<argc; i++) { | | 220 | for (i=0; i<argc; i++) { |
216 | printf("\t%s a_%s;\n", argtype[i], argname[i]); | | 221 | printf("\t%s a_%s;\n", argtype[i], argname[i]); |
217 | } | | 222 | } |
218 | printf("};\n"); | | 223 | printf("};\n"); |
219 | printf("extern const struct vnodeop_desc %s_desc;\n", name); | | 224 | printf("extern const struct vnodeop_desc %s_desc;\n", name); |
220 | # Prototype it. | | 225 | # Prototype it. |
221 | protoarg = sprintf("int %s(", toupper(name)); | | 226 | protoarg = sprintf("int %s(", toupper(name)); |
222 | protolen = length(protoarg); | | 227 | protolen = length(protoarg); |
223 | printf("%s", protoarg); | | 228 | printf("%s", protoarg); |
224 | for (i=0; i<argc; i++) { | | 229 | for (i=0; i<argc; i++) { |
225 | protoarg = sprintf("%s", argtype[i]); | | 230 | protoarg = sprintf("%s", argtype[i]); |
226 | if (i < (argc-1)) protoarg = (protoarg ", "); | | 231 | if (i < (argc-1)) protoarg = (protoarg ", "); |
227 | arglen = length(protoarg); | | 232 | arglen = length(protoarg); |
228 | if ((protolen + arglen) > 77) { | | 233 | if ((protolen + arglen) > 77) { |
229 | protoarg = ("\n " protoarg); | | 234 | protoarg = ("\n " protoarg); |
230 | arglen += 4; | | 235 | arglen += 4; |
231 | protolen = 0; | | 236 | protolen = 0; |
232 | } | | 237 | } |
233 | printf("%s", protoarg); | | 238 | printf("%s", protoarg); |
234 | protolen += arglen; | | 239 | protolen += arglen; |
235 | } | | 240 | } |
236 | printf(");\n"); | | 241 | printf(");\n"); |
237 | } | | 242 | } |
238 | BEGIN { | | 243 | BEGIN { |
239 | arg0special=""; | | 244 | arg0special=""; |
240 | vop_offset = 1; # start at 1, to count the 'default' op | | 245 | vop_offset = 1; # start at 1, to count the 'default' op |
241 | | | 246 | |
242 | printf("\n/* Special cases: */\nstruct buf;\n"); | | 247 | printf("\n/* Special cases: */\nstruct buf;\n"); |
243 | printf("#ifndef _KERNEL\n#include <stdbool.h>\n#endif\n\n"); | | 248 | printf("#ifndef _KERNEL\n#include <stdbool.h>\n#endif\n\n"); |
244 | | | 249 | |
245 | argc=1; | | 250 | argc=1; |
246 | argtype[0]="struct buf *"; | | 251 | argtype[0]="struct buf *"; |
247 | argname[0]="bp"; | | 252 | argname[0]="bp"; |
248 | lockstate[0] = -1; | | 253 | lockstate[0] = -1; |
249 | arg0special="->b_vp"; | | 254 | arg0special="->b_vp"; |
250 | name=rump "vop_bwrite"; | | 255 | name=rump "vop_bwrite"; |
251 | doit(); | | 256 | doit(); |
252 | printf("/* End of special cases */\n"); | | 257 | printf("/* End of special cases */\n"); |
253 | } | | 258 | } |
254 | END { | | 259 | END { |
255 | printf("\n#define VNODE_OPS_COUNT\t%d\n", vop_offset); | | 260 | printf("\n#define VNODE_OPS_COUNT\t%d\n", vop_offset); |
256 | } | | 261 | } |
257 | '"$awk_parser" | sed -e "$anal_retentive" | | 262 | '"$awk_parser" | sed -e "$anal_retentive" |
258 | | | 263 | |
259 | # End stuff | | 264 | # End stuff |
260 | echo ' | | 265 | echo ' |
261 | /* End of special cases. */' | | 266 | /* End of special cases. */' |
262 | echo '' | | 267 | echo '' |
263 | echo "#endif /* !_${SYS}VNODE_IF_H_ */" | | 268 | echo "#endif /* !_${SYS}VNODE_IF_H_ */" |
264 | } | | 269 | } |
265 | do_hfile $out_h '' | | 270 | do_hfile $out_h '' |
266 | do_hfile $out_rumph 'rump_' | | 271 | do_hfile $out_rumph 'rump_' |
267 | | | 272 | |
268 | do_cfile () { | | 273 | do_cfile () { |
269 | # | | 274 | # |
270 | # Redirect stdout to the C file. | | 275 | # Redirect stdout to the C file. |
271 | # | | 276 | # |
272 | echo "$0: Creating $1" 1>&2 | | 277 | echo "$0: Creating $1" 1>&2 |
273 | exec > $1 | | 278 | exec > $1 |
274 | rump=$2 | | 279 | rump=$2 |
275 | | | 280 | |
276 | # Begin stuff | | 281 | # Begin stuff |
277 | echo -n "$warning" | sed -e 's/\$//g;s/@/\$/g;s/ $//' | | 282 | echo -n "$warning" | sed -e 's/\$//g;s/@/\$/g;s/ $//' |
278 | echo "" | | 283 | echo "" |
279 | echo -n "$copyright" | | 284 | echo -n "$copyright" |
280 | echo " | | 285 | echo " |
281 | #include <sys/cdefs.h> | | 286 | #include <sys/cdefs.h> |
282 | __KERNEL_RCSID(0, \"\$NetBSD\$\"); | | 287 | __KERNEL_RCSID(0, \"\$NetBSD\$\");" |
283 | " | | 288 | |
| | | 289 | [ ${lockdebug} -ne 0 ] && echo && echo '#include "opt_vnode_lockdebug.h"' |
284 | | | 290 | |
285 | echo ' | | | |
286 | #include "opt_vnode_lockdebug.h"' | | | |
287 | echo ' | | 291 | echo ' |
288 | #include <sys/param.h> | | 292 | #include <sys/param.h> |
289 | #include <sys/mount.h> | | 293 | #include <sys/mount.h> |
290 | #include <sys/buf.h> | | 294 | #include <sys/buf.h> |
291 | #include <sys/vnode.h> | | 295 | #include <sys/vnode.h> |
292 | #include <sys/lock.h>' | | 296 | #include <sys/lock.h>' |
293 | [ ! -z "${rump}" ] && echo '#include <rump/rumpvnode_if.h>' | | 297 | [ ! -z "${rump}" ] && echo '#include <rump/rumpvnode_if.h>' |
294 | | | 298 | |
295 | echo " | | 299 | echo " |
296 | const struct vnodeop_desc ${rump}vop_default_desc = {" | | 300 | const struct vnodeop_desc ${rump}vop_default_desc = {" |
297 | echo ' 0, | | 301 | echo ' 0, |
298 | "default", | | 302 | "default", |
299 | 0, | | 303 | 0, |
300 | NULL, | | 304 | NULL, |
301 | VDESC_NO_OFFSET, | | 305 | VDESC_NO_OFFSET, |
302 | VDESC_NO_OFFSET, | | 306 | VDESC_NO_OFFSET, |
303 | VDESC_NO_OFFSET, | | 307 | VDESC_NO_OFFSET, |
304 | NULL, | | 308 | NULL, |
305 | }; | | 309 | }; |
306 | ' | | 310 | ' |
307 | | | 311 | |
308 | # Body stuff | | 312 | # Body stuff |
309 | sed -e "$sed_prep" $src | $awk -v rump=${rump} ' | | 313 | sed -e "$sed_prep" $src | $awk -v rump=${rump} -v lockdebug=${lockdebug} ' |
310 | function do_offset(typematch) { | | 314 | function do_offset(typematch) { |
311 | for (i=0; i<argc; i++) { | | 315 | for (i=0; i<argc; i++) { |
312 | if (argtype[i] == typematch) { | | 316 | if (argtype[i] == typematch) { |
313 | printf("\tVOPARG_OFFSETOF(struct %s_args, a_%s),\n", | | 317 | printf("\tVOPARG_OFFSETOF(struct %s_args, a_%s),\n", |
314 | name, argname[i]); | | 318 | name, argname[i]); |
315 | return i; | | 319 | return i; |
316 | }; | | 320 | }; |
317 | }; | | 321 | }; |
318 | print "\tVDESC_NO_OFFSET,"; | | 322 | print "\tVDESC_NO_OFFSET,"; |
319 | return -1; | | 323 | return -1; |
320 | } | | 324 | } |
321 | | | 325 | |
322 | function doit() { | | 326 | function doit() { |
323 | # Define offsets array | | 327 | # Define offsets array |
324 | printf("\nconst int %s_vp_offsets[] = {\n", name); | | 328 | printf("\nconst int %s_vp_offsets[] = {\n", name); |
325 | for (i=0; i<argc; i++) { | | 329 | for (i=0; i<argc; i++) { |
326 | if (argtype[i] == "struct vnode *") { | | 330 | if (argtype[i] == "struct vnode *") { |
327 | printf ("\tVOPARG_OFFSETOF(struct %s_args,a_%s),\n", | | 331 | printf ("\tVOPARG_OFFSETOF(struct %s_args,a_%s),\n", |
328 | name, argname[i]); | | 332 | name, argname[i]); |
329 | } | | 333 | } |
330 | } | | 334 | } |
331 | print "\tVDESC_NO_OFFSET"; | | 335 | print "\tVDESC_NO_OFFSET"; |
332 | print "};"; | | 336 | print "};"; |
333 | # Define F_desc | | 337 | # Define F_desc |
334 | printf("const struct vnodeop_desc %s_desc = {\n", name); | | 338 | printf("const struct vnodeop_desc %s_desc = {\n", name); |
335 | # offset | | 339 | # offset |
336 | printf ("\t%s_DESCOFFSET,\n", toupper(name)); | | 340 | printf ("\t%s_DESCOFFSET,\n", toupper(name)); |
337 | # printable name | | 341 | # printable name |
338 | printf ("\t\"%s\",\n", name); | | 342 | printf ("\t\"%s\",\n", name); |
339 | # flags | | 343 | # flags |
340 | printf("\t0"); | | 344 | printf("\t0"); |
341 | vpnum = 0; | | 345 | vpnum = 0; |
342 | for (i=0; i<argc; i++) { | | 346 | for (i=0; i<argc; i++) { |
343 | if (willrele[i]) { | | 347 | if (willrele[i]) { |
344 | if (willrele[i] == 2) { | | 348 | if (willrele[i] == 2) { |
345 | word = "UNLOCK"; | | 349 | word = "UNLOCK"; |
346 | } else if (willrele[i] == 3) { | | 350 | } else if (willrele[i] == 3) { |
347 | word = "PUT"; | | 351 | word = "PUT"; |
348 | } else { | | 352 | } else { |
349 | word = "RELE"; | | 353 | word = "RELE"; |
350 | } | | 354 | } |
351 | if (argdir[i] ~ /OUT/) { | | 355 | if (argdir[i] ~ /OUT/) { |
352 | printf(" | VDESC_VPP_WILL%s", word); | | 356 | printf(" | VDESC_VPP_WILL%s", word); |
353 | } else { | | 357 | } else { |
354 | printf(" | VDESC_VP%s_WILL%s", vpnum, word); | | 358 | printf(" | VDESC_VP%s_WILL%s", vpnum, word); |
355 | }; | | 359 | }; |
356 | vpnum++; | | 360 | vpnum++; |
357 | } | | 361 | } |
358 | } | | 362 | } |
359 | print ","; | | 363 | print ","; |
360 | # vp offsets | | 364 | # vp offsets |
361 | printf ("\t%s_vp_offsets,\n", name); | | 365 | printf ("\t%s_vp_offsets,\n", name); |
362 | # vpp (if any) | | 366 | # vpp (if any) |
363 | do_offset("struct vnode **"); | | 367 | do_offset("struct vnode **"); |
364 | # cred (if any) | | 368 | # cred (if any) |
365 | do_offset("kauth_cred_t"); | | 369 | do_offset("kauth_cred_t"); |
366 | # componentname | | 370 | # componentname |
367 | do_offset("struct componentname *"); | | 371 | do_offset("struct componentname *"); |
368 | # transport layer information | | 372 | # transport layer information |
369 | printf ("\tNULL,\n};\n"); | | 373 | printf ("\tNULL,\n};\n"); |
370 | | | 374 | |
371 | # Define function. | | 375 | # Define function. |
372 | printf("int\n%s(", toupper(name)); | | 376 | printf("int\n%s(", toupper(name)); |
373 | for (i=0; i<argc; i++) { | | 377 | for (i=0; i<argc; i++) { |
374 | printf("%s %s", argtype[i], argname[i]); | | 378 | printf("%s %s", argtype[i], argname[i]); |
375 | if (i < (argc-1)) printf(",\n "); | | 379 | if (i < (argc-1)) printf(",\n "); |
376 | } | | 380 | } |
377 | printf(")\n"); | | 381 | printf(")\n"); |
378 | printf("{\n\tint error;\n\tbool mpsafe;\n\tstruct %s_args a;\n", name); | | 382 | printf("{\n\tint error;\n\tbool mpsafe;\n\tstruct %s_args a;\n", name); |
379 | printf("#ifdef VNODE_LOCKDEBUG\n"); | | 383 | if (lockdebug) { |
380 | for (i=0; i<argc; i++) { | | 384 | printf("#ifdef VNODE_LOCKDEBUG\n"); |
381 | if (lockstate[i] != -1) | | 385 | for (i=0; i<argc; i++) { |
382 | printf("\tint islocked_%s;\n", argname[i]); | | 386 | if (lockstate[i] != -1) |
| | | 387 | printf("\tint islocked_%s;\n", argname[i]); |
| | | 388 | } |
| | | 389 | printf("#endif\n"); |
383 | } | | 390 | } |
384 | printf("#endif\n"); | | | |
385 | printf("\ta.a_desc = VDESC(%s);\n", name); | | 391 | printf("\ta.a_desc = VDESC(%s);\n", name); |
386 | for (i=0; i<argc; i++) { | | 392 | for (i=0; i<argc; i++) { |
387 | printf("\ta.a_%s = %s;\n", argname[i], argname[i]); | | 393 | printf("\ta.a_%s = %s;\n", argname[i], argname[i]); |
388 | if (lockstate[i] != -1) { | | 394 | if (lockdebug && lockstate[i] != -1) { |
389 | printf("#ifdef VNODE_LOCKDEBUG\n"); | | 395 | printf("#ifdef VNODE_LOCKDEBUG\n"); |
390 | printf("\tislocked_%s = (%s->v_vflag & VV_LOCKSWORK) ? (VOP_ISLOCKED(%s) == LK_EXCLUSIVE) : %d;\n", | | 396 | printf("\tislocked_%s = (%s->v_vflag & VV_LOCKSWORK) ? (VOP_ISLOCKED(%s) == LK_EXCLUSIVE) : %d;\n", |
391 | argname[i], argname[i], argname[i], lockstate[i]); | | 397 | argname[i], argname[i], argname[i], lockstate[i]); |
392 | printf("\tif (islocked_%s != %d)\n", argname[i], | | 398 | printf("\tif (islocked_%s != %d)\n", argname[i], |
393 | lockstate[i]); | | 399 | lockstate[i]); |
394 | printf("\t\tpanic(\"%s: %s: locked %%d, expected %%d\", islocked_%s, %d);\n", name, argname[i], argname[i], lockstate[i]); | | 400 | printf("\t\tpanic(\"%s: %s: locked %%d, expected %%d\", islocked_%s, %d);\n", name, argname[i], argname[i], lockstate[i]); |
395 | printf("#endif\n"); | | 401 | printf("#endif\n"); |
396 | } | | 402 | } |
397 | } | | 403 | } |
398 | printf("\tmpsafe = (%s%s->v_vflag & VV_MPSAFE);\n", argname[0], arg0special); | | 404 | printf("\tmpsafe = (%s%s->v_vflag & VV_MPSAFE);\n", argname[0], arg0special); |
399 | printf("\tif (!mpsafe) { KERNEL_LOCK(1, curlwp); }\n"); | | 405 | printf("\tif (!mpsafe) { KERNEL_LOCK(1, curlwp); }\n"); |
400 | printf("\terror = (VCALL(%s%s, VOFFSET(%s), &a));\n", | | 406 | printf("\terror = (VCALL(%s%s, VOFFSET(%s), &a));\n", |
401 | argname[0], arg0special, name); | | 407 | argname[0], arg0special, name); |
402 | printf("\tif (!mpsafe) { KERNEL_UNLOCK_ONE(curlwp); }\n"); | | 408 | printf("\tif (!mpsafe) { KERNEL_UNLOCK_ONE(curlwp); }\n"); |
403 | if (willmake != -1) { | | 409 | if (willmake != -1) { |
404 | printf("#ifdef DIAGNOSTIC\n"); | | 410 | printf("#ifdef DIAGNOSTIC\n"); |
405 | printf("\tif (error == 0)\n" \ | | 411 | printf("\tif (error == 0)\n" \ |
406 | "\t\tKASSERT((*%s)->v_size != VSIZENOTSET\n" \ | | 412 | "\t\tKASSERT((*%s)->v_size != VSIZENOTSET\n" \ |
407 | "\t\t && (*%s)->v_writesize != VSIZENOTSET);\n", | | 413 | "\t\t && (*%s)->v_writesize != VSIZENOTSET);\n", |
408 | argname[willmake], argname[willmake]); | | 414 | argname[willmake], argname[willmake]); |
409 | printf("#endif /* DIAGNOSTIC */\n"); | | 415 | printf("#endif /* DIAGNOSTIC */\n"); |
410 | } | | 416 | } |
411 | printf("\treturn error;\n}\n"); | | 417 | printf("\treturn error;\n}\n"); |
412 | } | | 418 | } |
413 | BEGIN { | | 419 | BEGIN { |
414 | printf("\n/* Special cases: */\n"); | | 420 | printf("\n/* Special cases: */\n"); |
415 | # start from 1 (vop_default is at 0) | | 421 | # start from 1 (vop_default is at 0) |
416 | argc=1; | | 422 | argc=1; |
417 | willmake=-1; | | 423 | willmake=-1; |
418 | argdir[0]="IN"; | | 424 | argdir[0]="IN"; |
419 | argtype[0]="struct buf *"; | | 425 | argtype[0]="struct buf *"; |
420 | argname[0]="bp"; | | 426 | argname[0]="bp"; |
421 | lockstate[0] = -1; | | 427 | lockstate[0] = -1; |
422 | arg0special="->b_vp"; | | 428 | arg0special="->b_vp"; |
423 | willrele[0]=0; | | 429 | willrele[0]=0; |
424 | name=rump "vop_bwrite"; | | 430 | name=rump "vop_bwrite"; |
425 | doit(); | | 431 | doit(); |
426 | printf("\n/* End of special cases */\n"); | | 432 | printf("\n/* End of special cases */\n"); |
427 | | | 433 | |
428 | arg0special=""; | | 434 | arg0special=""; |
429 | } | | 435 | } |
430 | '"$awk_parser" | sed -e "$anal_retentive" | | 436 | '"$awk_parser" | sed -e "$anal_retentive" |
431 | | | 437 | |
432 | # End stuff | | 438 | # End stuff |
433 | echo ' | | 439 | echo ' |
434 | /* End of special cases. */' | | 440 | /* End of special cases. */' |
435 | | | 441 | |
436 | # Add the vfs_op_descs array to the C file. | | 442 | # Add the vfs_op_descs array to the C file. |
437 | # Begin stuff | | 443 | # Begin stuff |
438 | echo " | | 444 | echo " |
439 | const struct vnodeop_desc * const ${rump}vfs_op_descs[] = { | | 445 | const struct vnodeop_desc * const ${rump}vfs_op_descs[] = { |
440 | &${rump}vop_default_desc, /* MUST BE FIRST */ | | 446 | &${rump}vop_default_desc, /* MUST BE FIRST */ |
441 | &${rump}vop_bwrite_desc, /* XXX: SPECIAL CASE */ | | 447 | &${rump}vop_bwrite_desc, /* XXX: SPECIAL CASE */ |
442 | " | | 448 | " |
443 | | | 449 | |
444 | # Body stuff | | 450 | # Body stuff |
445 | sed -e "$sed_prep" $src | $awk -v rump=${rump} ' | | 451 | sed -e "$sed_prep" $src | $awk -v rump=${rump} ' |
446 | function doit() { | | 452 | function doit() { |
447 | printf("\t&%s_desc,\n", name); | | 453 | printf("\t&%s_desc,\n", name); |
448 | } | | 454 | } |
449 | '"$awk_parser" | | 455 | '"$awk_parser" |
450 | | | 456 | |
451 | # End stuff | | 457 | # End stuff |
452 | echo ' NULL | | 458 | echo ' NULL |
453 | }; | | 459 | }; |
454 | ' | | 460 | ' |
455 | } | | 461 | } |
456 | do_cfile $out_c '' | | 462 | do_cfile $out_c '' |
457 | do_cfile $out_rumpc 'rump_' | | 463 | do_cfile $out_rumpc 'rump_' |
458 | | | 464 | |
459 | exit 0 | | 465 | exit 0 |
460 | | | 466 | |
461 | # Local Variables: | | 467 | # Local Variables: |
462 | # tab-width: 4 | | 468 | # tab-width: 4 |
463 | # End: | | 469 | # End: |