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