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