|
|
1.1 ! root 1: #!/bin/sh - ! 2: copyright=' ! 3: /* ! 4: * Copyright (c) 1995 NeXT Computer, Inc. All Rights Reserved ! 5: * Copyright (c) 1992, 1993, 1994, 1995 ! 6: * The Regents of the University of California. All rights reserved. ! 7: * ! 8: # Redistribution and use in source and binary forms, with or without ! 9: # modification, are permitted provided that the following conditions ! 10: # are met: ! 11: # 1. Redistributions of source code must retain the above copyright ! 12: # notice, this list of conditions and the following disclaimer. ! 13: # 2. Redistributions in binary form must reproduce the above copyright ! 14: # notice, this list of conditions and the following disclaimer in the ! 15: # documentation and/or other materials provided with the distribution. ! 16: # 3. All advertising materials mentioning features or use of this software ! 17: # must display the following acknowledgement: ! 18: # This product includes software developed by the University of ! 19: # California, Berkeley and its contributors. ! 20: # 4. Neither the name of the University nor the names of its contributors ! 21: # may be used to endorse or promote products derived from this software ! 22: # without specific prior written permission. ! 23: # ! 24: # THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ! 25: # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE ! 26: # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ! 27: # ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE ! 28: # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL ! 29: # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS ! 30: # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ! 31: # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT ! 32: # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY ! 33: # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF ! 34: # SUCH DAMAGE. ! 35: * ! 36: * from: NetBSD: vnode_if.sh,v 1.7 1994/08/25 03:04:28 cgd Exp $ ! 37: */ ! 38: ' ! 39: SCRIPT_ID='@(#)vnode_if.sh 8.7 (Berkeley) 5/11/95' ! 40: ! 41: # Script to produce VFS front-end sugar. ! 42: # ! 43: # usage: vnode_if.sh srcfile ! 44: # (where srcfile is currently /sys/kern/vnode_if.src) ! 45: # ! 46: ! 47: if [ $# -ne 1 ] ; then ! 48: echo 'usage: vnode_if.sh srcfile' ! 49: exit 1 ! 50: fi ! 51: ! 52: # Name of the source file. ! 53: src=$1 ! 54: ! 55: # Names of the created files. ! 56: out_c=vnode_if.c ! 57: out_h=vnode_if.h ! 58: ! 59: # Awk program (must support nawk extensions) ! 60: # Use "awk" at Berkeley, "nawk" or "gawk" elsewhere. ! 61: #awk=${AWK:-awk} ! 62: awk=${AWK:-gawk} ! 63: ! 64: # Does this awk have a "toupper" function? (i.e. is it GNU awk) ! 65: isgawk=`$awk 'BEGIN { print toupper("true"); exit; }' 2>/dev/null` ! 66: ! 67: # If this awk does not define "toupper" then define our own. ! 68: if [ "$isgawk" = TRUE ] ; then ! 69: # GNU awk provides it. ! 70: toupper= ! 71: else ! 72: # Provide our own toupper() ! 73: toupper=' ! 74: function toupper(str) { ! 75: _toupper_cmd = "echo "str" |tr a-z A-Z" ! 76: _toupper_cmd | getline _toupper_str; ! 77: close(_toupper_cmd); ! 78: return _toupper_str; ! 79: }' ! 80: fi ! 81: ! 82: # ! 83: # This is the common part of all awk programs that read $src ! 84: # This parses the input for one function into the arrays: ! 85: # argdir, argtype, argname, willrele ! 86: # and calls "doit()" to generate output for the function. ! 87: # ! 88: # Input to this parser is pre-processed slightly by sed ! 89: # so this awk parser doesn't have to work so hard. The ! 90: # changes done by the sed pre-processing step are: ! 91: # insert a space beween * and pointer name ! 92: # replace semicolons with spaces ! 93: # ! 94: sed_prep='s:\*\([^\*/]\):\* \1:g ! 95: s/;/ /' ! 96: awk_parser=' ! 97: # Comment line ! 98: /^#/ { next; } ! 99: # First line of description ! 100: /^vop_/ { ! 101: name=$1; ! 102: argc=0; ! 103: next; ! 104: } ! 105: # Last line of description ! 106: /^}/ { ! 107: doit(); ! 108: next; ! 109: } ! 110: # Middle lines of description ! 111: { ! 112: argdir[argc] = $1; i=2; ! 113: if ($2 == "WILLRELE") { ! 114: willrele[argc] = 1; ! 115: i++; ! 116: } else ! 117: willrele[argc] = 0; ! 118: argtype[argc] = $i; i++; ! 119: while (i < NF) { ! 120: argtype[argc] = argtype[argc]" "$i; ! 121: i++; ! 122: } ! 123: argname[argc] = $i; ! 124: argc++; ! 125: next; ! 126: } ! 127: ' ! 128: ! 129: # This is put after the copyright on each generated file. ! 130: warning=" ! 131: /* ! 132: * Warning: This file is generated automatically. ! 133: * (Modifications made here may easily be lost!) ! 134: * ! 135: * Created by the script: ! 136: * ${SCRIPT_ID} ! 137: */ ! 138: " ! 139: ! 140: # Get rid of ugly spaces ! 141: space_elim='s:\([^/]\*\) :\1:g' ! 142: ! 143: # ! 144: # Redirect stdout to the H file. ! 145: # ! 146: echo "$0: Creating $out_h" 1>&2 ! 147: exec > $out_h ! 148: ! 149: # Begin stuff ! 150: echo "$copyright" ! 151: echo "$warning" ! 152: echo ' ! 153: extern struct vnodeop_desc vop_default_desc; ! 154: ' ! 155: ! 156: # Body stuff ! 157: # This awk program needs toupper() so define it if necessary. ! 158: sed -e "$sed_prep" $src | $awk "$toupper"' ! 159: function doit() { ! 160: # Declare arg struct, descriptor. ! 161: printf("\nstruct %s_args {\n", name); ! 162: printf("\tstruct vnodeop_desc * a_desc;\n"); ! 163: for (i=0; i<argc; i++) { ! 164: printf("\t%s a_%s;\n", argtype[i], argname[i]); ! 165: } ! 166: printf("};\n"); ! 167: printf("extern struct vnodeop_desc %s_desc;\n", name); ! 168: # Define inline function. ! 169: printf("#define %s(", toupper(name)); ! 170: for (i=0; i<argc; i++) { ! 171: printf("%s", argname[i]); ! 172: if (i < (argc-1)) printf(", "); ! 173: } ! 174: printf(") _%s(", toupper(name)); ! 175: for (i=0; i<argc; i++) { ! 176: printf("%s", argname[i]); ! 177: if (i < (argc-1)) printf(", "); ! 178: } ! 179: printf(")\n"); ! 180: printf("static __inline int _%s(", toupper(name)); ! 181: for (i=0; i<argc; i++) { ! 182: printf("%s", argname[i]); ! 183: if (i < (argc-1)) printf(", "); ! 184: } ! 185: printf(")\n"); ! 186: for (i=0; i<argc; i++) { ! 187: printf("\t%s %s;\n", argtype[i], argname[i]); ! 188: } ! 189: printf("{\n\tstruct %s_args a;\n", name); ! 190: printf("\ta.a_desc = VDESC(%s);\n", name); ! 191: for (i=0; i<argc; i++) { ! 192: printf("\ta.a_%s = %s;\n", argname[i], argname[i]); ! 193: } ! 194: printf("\treturn (VCALL(%s%s, VOFFSET(%s), &a));\n}\n", ! 195: argname[0], arg0special, name); ! 196: } ! 197: BEGIN { ! 198: arg0special=""; ! 199: } ! 200: END { ! 201: printf("\n/* Special cases: */\n#include <sys/buf.h>\n#include <sys/vm.h>\n"); ! 202: argc=1; ! 203: argtype[0]="struct buf *"; ! 204: argname[0]="bp"; ! 205: arg0special="->b_vp"; ! 206: name="vop_strategy"; ! 207: doit(); ! 208: name="vop_bwrite"; ! 209: doit(); ! 210: } ! 211: '"$awk_parser" | sed -e "$space_elim" ! 212: ! 213: # End stuff ! 214: echo ' ! 215: /* End of special cases. */' ! 216: ! 217: ! 218: # ! 219: # Redirect stdout to the C file. ! 220: # ! 221: echo "$0: Creating $out_c" 1>&2 ! 222: exec > $out_c ! 223: ! 224: # Begin stuff ! 225: echo "$copyright" ! 226: echo "$warning" ! 227: echo ' ! 228: #include <sys/param.h> ! 229: #include <sys/mount.h> ! 230: #include <sys/vm.h> ! 231: #include <sys/vnode.h> ! 232: ! 233: struct vnodeop_desc vop_default_desc = { ! 234: 0, ! 235: "default", ! 236: 0, ! 237: NULL, ! 238: VDESC_NO_OFFSET, ! 239: VDESC_NO_OFFSET, ! 240: VDESC_NO_OFFSET, ! 241: VDESC_NO_OFFSET, ! 242: NULL, ! 243: }; ! 244: ' ! 245: ! 246: # Body stuff ! 247: sed -e "$sed_prep" $src | $awk ' ! 248: function do_offset(typematch) { ! 249: for (i=0; i<argc; i++) { ! 250: if (argtype[i] == typematch) { ! 251: printf("\tVOPARG_OFFSETOF(struct %s_args, a_%s),\n", ! 252: name, argname[i]); ! 253: return i; ! 254: }; ! 255: }; ! 256: print "\tVDESC_NO_OFFSET,"; ! 257: return -1; ! 258: } ! 259: ! 260: function doit() { ! 261: # Define offsets array ! 262: printf("\nint %s_vp_offsets[] = {\n", name); ! 263: for (i=0; i<argc; i++) { ! 264: if (argtype[i] == "struct vnode *") { ! 265: printf ("\tVOPARG_OFFSETOF(struct %s_args,a_%s),\n", ! 266: name, argname[i]); ! 267: } ! 268: } ! 269: print "\tVDESC_NO_OFFSET"; ! 270: print "};"; ! 271: # Define F_desc ! 272: printf("struct vnodeop_desc %s_desc = {\n", name); ! 273: # offset ! 274: printf ("\t0,\n"); ! 275: # printable name ! 276: printf ("\t\"%s\",\n", name); ! 277: # flags ! 278: printf("\t0"); ! 279: vpnum = 0; ! 280: for (i=0; i<argc; i++) { ! 281: if (willrele[i]) { ! 282: if (argdir[i] ~ /OUT/) { ! 283: printf(" | VDESC_VPP_WILLRELE"); ! 284: } else { ! 285: printf(" | VDESC_VP%s_WILLRELE", vpnum); ! 286: }; ! 287: vpnum++; ! 288: } ! 289: } ! 290: print ","; ! 291: # vp offsets ! 292: printf ("\t%s_vp_offsets,\n", name); ! 293: # vpp (if any) ! 294: do_offset("struct vnode **"); ! 295: # cred (if any) ! 296: do_offset("struct ucred *"); ! 297: # proc (if any) ! 298: do_offset("struct proc *"); ! 299: # componentname ! 300: do_offset("struct componentname *"); ! 301: # transport layer information ! 302: printf ("\tNULL,\n};\n"); ! 303: } ! 304: END { ! 305: printf("\n/* Special cases: */\n"); ! 306: argc=1; ! 307: argdir[0]="IN"; ! 308: argtype[0]="struct buf *"; ! 309: argname[0]="bp"; ! 310: willrele[0]=0; ! 311: name="vop_strategy"; ! 312: doit(); ! 313: name="vop_bwrite"; ! 314: doit(); ! 315: } ! 316: '"$awk_parser" | sed -e "$space_elim" ! 317: ! 318: # End stuff ! 319: echo ' ! 320: /* End of special cases. */' ! 321: ! 322: # Add the vfs_op_descs array to the C file. ! 323: # Begin stuff ! 324: echo ' ! 325: struct vnodeop_desc *vfs_op_descs[] = { ! 326: &vop_default_desc, /* MUST BE FIRST */ ! 327: &vop_strategy_desc, /* XXX: SPECIAL CASE */ ! 328: &vop_bwrite_desc, /* XXX: SPECIAL CASE */ ! 329: ' ! 330: ! 331: # Body stuff ! 332: sed -e "$sed_prep" $src | $awk ' ! 333: function doit() { ! 334: printf("\t&%s_desc,\n", name); ! 335: } ! 336: '"$awk_parser" ! 337: ! 338: # End stuff ! 339: echo ' NULL ! 340: }; ! 341: ' ! 342: ! 343: exit 0 ! 344: ! 345: # Local Variables: ! 346: # tab-width: 4 ! 347: # End:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.