]>
git.saurik.com Git - apple/xnu.git/blob - bsd/vfs/vnode_if.sh
1125a6ca3d954f789f4189d86aa22750d1a7ae90
4 * Copyright (c) 2006 Apple Computer, Inc. All Rights Reserved.
6 * @APPLE_LICENSE_OSREFERENCE_HEADER_START@
8 * This file contains Original Code and/or Modifications of Original Code
9 * as defined in and that are subject to the Apple Public Source License
10 * Version 2.0 (the 'License
'). You may not use this file except in
11 * compliance with the License. The rights granted to you under the
12 * License may not be used to create, or enable the creation or
13 * redistribution of, unlawful or unlicensed copies of an Apple operating
14 * system, or to circumvent, violate, or enable the circumvention or
15 * violation of, any terms of an Apple operating system software license
18 * Please obtain a copy of the License at
19 * http://www.opensource.apple.com/apsl/ and read it before using this
22 * The Original Code and all software distributed under the License are
23 * distributed on an 'AS IS
' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
24 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
25 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
26 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
27 * Please see the License for the specific language governing rights and
28 * limitations under the License.
30 * @APPLE_LICENSE_OSREFERENCE_HEADER_END@
33 * Copyright (c) 1995 NeXT Computer, Inc. All Rights Reserved
34 * Copyright (c) 1992, 1993, 1994, 1995
35 * The Regents of the University of California. All rights reserved.
37 * Redistribution and use in source and binary forms, with or without
38 * modification, are permitted provided that the following conditions
40 * 1. Redistributions of source code must retain the above copyright
41 * notice, this list of conditions and the following disclaimer.
42 * 2. Redistributions in binary form must reproduce the above copyright
43 * notice, this list of conditions and the following disclaimer in the
44 * documentation and/or other materials provided with the distribution.
45 * 3. All advertising materials mentioning features or use of this software
46 * must display the following acknowledgement:
47 * This product includes software developed by the University of
48 * California, Berkeley and its contributors.
49 * 4. Neither the name of the University nor the names of its contributors
50 * may be used to endorse or promote products derived from this software
51 * without specific prior written permission.
53 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
54 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
55 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
56 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
57 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
58 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
59 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
60 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
61 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
62 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
66 SCRIPT_ID
='@(#)vnode_if.sh 8.7 (Berkeley) 5/11/95'
68 # Script to produce VFS front-end sugar.
70 # usage: vnode_if.sh srcfile
71 # (where srcfile is currently bsd/vfs/vnode_if.src)
74 if [ $# -ne 1 ] ; then
75 echo 'usage: vnode_if.sh srcfile'
79 # Name of the source file.
82 # Names of the created files.
86 # Awk program (must support nawk extensions)
87 # Use "awk" at Berkeley, "nawk" or "gawk" elsewhere.
91 # Does this awk have a "toupper" function? (i.e. is it GNU awk)
92 isgawk
=`$awk 'BEGIN { print toupper("true"); exit; }' 2>/dev/null`
94 # If this awk does not define "toupper" then define our own.
95 if [ "$isgawk" = TRUE
] ; then
96 # GNU awk provides it.
99 # Provide our own toupper()
101 function toupper(str) {
102 _toupper_cmd = "echo "str" |tr a-z A-Z"
103 _toupper_cmd | getline _toupper_str;
110 # This is the common part of all awk programs that read $src
111 # This parses the input for one function into the arrays:
112 # argdir, argtype, argname, willrele
113 # and calls "doit()" to generate output for the function.
115 # Input to this parser is pre-processed slightly by sed
116 # so this awk parser doesn't have to work so hard. The
117 # changes done by the sed pre-processing step are:
118 # insert a space beween * and pointer name
119 # replace semicolons with spaces
121 sed_prep
='s:\*\([^\*/]\):\* \1:g
126 # First line of description
133 # Last line of description
138 # Middle lines of description
140 argdir[argc] = $1; i=2;
141 if ($2 == "WILLRELE") {
146 argtype[argc] = $i; i++;
148 argtype[argc] = argtype[argc]" "$i;
157 # This is put after the copyright on each generated file.
160 * Warning: This file is generated automatically.
161 * (Modifications made here may easily be lost!)
163 * Created by the script:
168 # Get rid of ugly spaces
169 space_elim
='s:\([^/]\*\) :\1:g'
172 # Redirect stdout to the H file.
174 echo "$0: Creating $out_h" 1>&2
181 #ifndef _SYS_VNODE_IF_H_
182 #define _SYS_VNODE_IF_H_
184 #include <sys/appleapiopts.h>
187 #ifdef __APPLE_API_UNSTABLE
188 extern struct vnodeop_desc vop_default_desc;
192 # This awk program needs toupper() so define it if necessary.
193 sed -e "$sed_prep" $src | $awk "$toupper"'
195 # Declare arg struct, descriptor.
196 printf("\nstruct %s_args {\n", name);
197 printf("\tstruct vnodeop_desc * a_desc;\n");
198 for (i=0; i<argc; i++) {
199 printf("\t%s a_%s;\n", argtype[i], argname[i]);
202 printf("extern struct vnodeop_desc %s_desc;\n", name);
203 # Define inline function.
204 printf("#define %s(", toupper(name));
205 for (i=0; i<argc; i++) {
206 printf("%s", argname[i]);
207 if (i < (argc-1)) printf(", ");
209 printf(") _%s(", toupper(name));
210 for (i=0; i<argc; i++) {
211 printf("%s", argname[i]);
212 if (i < (argc-1)) printf(", ");
215 printf("static __inline int _%s(", toupper(name));
216 for (i=0; i<argc; i++) {
217 # generate ANSI protoypes now, hurrah!
218 printf("%s _%s", argtype[i], argname[i]);
219 if (i < (argc-1)) printf(", ");
222 printf("{\n\tstruct %s_args a;\n", name);
223 printf("\ta.a_desc = VDESC(%s);\n", name);
224 for (i=0; i<argc; i++) {
225 printf("\ta.a_%s = _%s;\n", argname[i], argname[i]);
227 if (toupper(ubc) == "UBC") {
230 "_err = VCALL(_%s%s, VOFFSET(%s), &a);\n\t\t" \
231 "return (_err);\n\t}\n}\n",
232 argname[0], argname[0], arg0special, name, argname[0]);
234 printf("\treturn (VCALL(_%s%s, VOFFSET(%s), &a));\n}\n",
235 argname[0], arg0special, name);
242 printf("\n/* Special cases: */\n#include <sys/buf.h>\n#include <sys/vm.h>\n");
244 argtype[0]="struct buf *";
246 arg0special="->b_vp";
252 '"$awk_parser" | sed -e "$space_elim"
256 /* End of special cases. */
258 #endif /* __APPLE_API_UNSTABLE */
259 #endif /* !_SYS_VNODE_IF_H_ */'
262 # Redirect stdout to the C file.
264 echo "$0: Creating $out_c" 1>&2
271 #include <sys/param.h>
272 #include <sys/mount.h>
274 #include <sys/vnode.h>
276 struct vnodeop_desc vop_default_desc = {
290 sed -e "$sed_prep" $src | $awk '
291 function do_offset(typematch) {
292 for (i=0; i<argc; i++) {
293 if (argtype[i] == typematch) {
294 printf("\tVOPARG_OFFSETOF(struct %s_args, a_%s),\n",
299 print "\tVDESC_NO_OFFSET,";
304 # Define offsets array
305 printf("\nint %s_vp_offsets[] = {\n", name);
306 for (i=0; i<argc; i++) {
307 if (argtype[i] == "struct vnode *") {
308 printf ("\tVOPARG_OFFSETOF(struct %s_args,a_%s),\n",
312 print "\tVDESC_NO_OFFSET";
315 printf("struct vnodeop_desc %s_desc = {\n", name);
319 printf ("\t\"%s\",\n", name);
323 for (i=0; i<argc; i++) {
324 if (match(argtype[i], "struct vnode *") == 1) {
326 if (argdir[i] ~ /OUT/) {
327 printf(" | VDESC_VPP_WILLRELE");
329 printf(" | VDESC_VP%s_WILLRELE", vpnum);
337 printf ("\t%s_vp_offsets,\n", name);
339 do_offset("struct vnode **");
341 do_offset("kauth_credential_t");
343 do_offset("struct proc *");
345 do_offset("struct componentname *");
346 # transport layer information
347 printf ("\tNULL,\n};\n");
350 printf("\n/* Special cases: */\n");
353 argtype[0]="struct buf *";
361 '"$awk_parser" | sed -e "$space_elim"
365 /* End of special cases. */'
367 # Add the vfs_op_descs array to the C file.
370 struct vnodeop_desc *vfs_op_descs[] = {
371 &vop_default_desc, /* MUST BE FIRST */
372 &vop_strategy_desc, /* XXX: SPECIAL CASE */
373 &VNOP_BWRITE_desc, /* XXX: SPECIAL CASE */
377 sed -e "$sed_prep" $src | $awk '
379 printf("\t&%s_desc,\n", name);