1*54646Smckusick#!/bin/sh - 2*54646Smckusick# 3*54646Smckusick# Copyright (c) 1992 The Regents of the University of California. 4*54646Smckusick# All rights reserved. 5*54646Smckusick# 6*54646Smckusick# %sccs.include.redist.sh% 7*54646Smckusick# 8*54646Smckusick# @(#)vnode_if.sh 7.1 (Berkeley) 07/03/92 9*54646Smckusick# 10*54646Smckusick 11*54646Smckusick# Script to produce VFS front-end sugar. 12*54646Smckusick 13*54646Smckusickcat << END_OF_LEADING_COMMENT 14*54646Smckusick/* 15*54646Smckusick * This file is produced by the script /sys/kern/vnode_if.sh. 16*54646Smckusick * Do not modify anything in here by hand. 17*54646Smckusick * 18*54646Smckusick * @(#)vnode_if.sh 7.1 (Berkeley) 07/03/92 19*54646Smckusick */ 20*54646Smckusickextern struct vnodeop_desc vop_default_desc; 21*54646SmckusickEND_OF_LEADING_COMMENT 22*54646Smckusick 23*54646Smckusick# Awk script to take vnode_if.src and turn it into vnode_if.h. 24*54646Smckusick# 25*54646Smckusick# This script is not particularly well written, it figures out the 26*54646Smckusick# same stuff repeatedly. Feel free to fix it. Note, it uses nawk 27*54646Smckusick# extensions. 28*54646Smckusick 29*54646Smckusickawk ' 30*54646Smckusick NF == 0 || $0 ~ "^#" { 31*54646Smckusick next; 32*54646Smckusick } 33*54646Smckusick { 34*54646Smckusick # get the function name 35*54646Smckusick name = $1; 36*54646Smckusick uname = toupper(name); 37*54646Smckusick 38*54646Smckusick # get the function arguments 39*54646Smckusick for (c1 = 0;; ++c1) { 40*54646Smckusick if (getline <= 0) 41*54646Smckusick exit 42*54646Smckusick if ($0 ~ "^};") 43*54646Smckusick break; 44*54646Smckusick a[c1] = $0; 45*54646Smckusick } 46*54646Smckusick 47*54646Smckusick # print out the vop_F_args structure 48*54646Smckusick printf("struct %s_args {\n\tstruct vnodeop_desc *a_desc;\n", 49*54646Smckusick name); 50*54646Smckusick for (c2 = 0; c2 < c1; ++c2) { 51*54646Smckusick c3 = split(a[c2], t); 52*54646Smckusick printf("\t"); 53*54646Smckusick for (c4 = 2; c4 < c3; ++c4) 54*54646Smckusick printf("%s ", t[c4]); 55*54646Smckusick beg = match(t[c3], "[^*]"); 56*54646Smckusick printf("%sa_%s\n", 57*54646Smckusick substr(t[c4], 0, beg - 1), substr(t[c4], beg)); 58*54646Smckusick } 59*54646Smckusick printf("};\n"); 60*54646Smckusick 61*54646Smckusick # print out extern declaration 62*54646Smckusick printf("extern struct vnodeop_desc %s_desc;\n", name); 63*54646Smckusick 64*54646Smckusick # print out inline struct 65*54646Smckusick printf("static inline int %s(", uname); 66*54646Smckusick sep = ", "; 67*54646Smckusick for (c2 = 0; c2 < c1; ++c2) { 68*54646Smckusick if (c2 == c1 - 1) 69*54646Smckusick sep = ")\n"; 70*54646Smckusick c3 = split(a[c2], t); 71*54646Smckusick beg = match(t[c3], "[^*]"); 72*54646Smckusick end = match(t[c3], ";"); 73*54646Smckusick printf("%s%s", substr(t[c3], beg, end - beg), sep); 74*54646Smckusick } 75*54646Smckusick for (c2 = 0; c2 < c1; ++c2) { 76*54646Smckusick c3 = split(a[c2], t); 77*54646Smckusick printf("\t"); 78*54646Smckusick for (c4 = 2; c4 < c3; ++c4) 79*54646Smckusick printf("%s ", t[c4]); 80*54646Smckusick beg = match(t[c3], "[^*]"); 81*54646Smckusick printf("%s%s\n", 82*54646Smckusick substr(t[c4], 0, beg - 1), substr(t[c4], beg)); 83*54646Smckusick } 84*54646Smckusick printf("{\n\tstruct %s_args a;\n\n", name); 85*54646Smckusick printf("\ta.a_desc = VDESC(%s);\n", name); 86*54646Smckusick for (c2 = 0; c2 < c1; ++c2) { 87*54646Smckusick c3 = split(a[c2], t); 88*54646Smckusick printf("\t"); 89*54646Smckusick beg = match(t[c3], "[^*]"); 90*54646Smckusick end = match(t[c3], ";"); 91*54646Smckusick printf("a.a_%s = %s\n", 92*54646Smckusick substr(t[c3], beg, end - beg), substr(t[c3], beg)); 93*54646Smckusick } 94*54646Smckusick c1 = split(a[0], t); 95*54646Smckusick beg = match(t[c1], "[^*]"); 96*54646Smckusick end = match(t[c1], ";"); 97*54646Smckusick printf("\treturn (VCALL(%s, VOFFSET(%s), &a));\n}\n", 98*54646Smckusick substr(t[c1], beg, end - beg), name); 99*54646Smckusick }' 100*54646Smckusick 101*54646Smckusick# THINGS THAT DON'T WORK RIGHT YET. 102*54646Smckusick# 103*54646Smckusick# Two existing BSD vnodeops (bwrite and strategy) don't take any vnodes as 104*54646Smckusick# arguments. This means that these operations can't function successfully 105*54646Smckusick# through a bypass routine. 106*54646Smckusick# 107*54646Smckusick# Bwrite and strategy will be replaced when the VM page/buffer cache 108*54646Smckusick# integration happens. 109*54646Smckusick# 110*54646Smckusick# To get around this problem for now we handle these ops as special cases. 111*54646Smckusick 112*54646Smckusickcat << END_OF_SPECIAL_CASES 113*54646Smckusick#include <sys/buf.h> 114*54646Smckusickstruct vop_strategy_args { 115*54646Smckusick struct vnodeop_desc *a_desc; 116*54646Smckusick struct buf *a_bp; 117*54646Smckusick}; 118*54646Smckusickextern struct vnodeop_desc vop_strategy_desc; 119*54646Smckusickstatic inline int VOP_STRATEGY(bp) 120*54646Smckusick struct buf *bp; 121*54646Smckusick{ 122*54646Smckusick struct vop_strategy_args a; 123*54646Smckusick 124*54646Smckusick a.a_desc = VDESC(vop_strategy); 125*54646Smckusick a.a_bp = bp; 126*54646Smckusick return (VCALL((bp)->b_vp, VOFFSET(vop_strategy), &a)); 127*54646Smckusick} 128*54646Smckusick 129*54646Smckusickstruct vop_bwrite_args { 130*54646Smckusick struct vnodeop_desc *a_desc; 131*54646Smckusick struct buf *a_bp; 132*54646Smckusick}; 133*54646Smckusickextern struct vnodeop_desc vop_bwrite_desc; 134*54646Smckusickstatic inline int VOP_BWRITE(bp) 135*54646Smckusick struct buf *bp; 136*54646Smckusick{ 137*54646Smckusick struct vop_bwrite_args a; 138*54646Smckusick 139*54646Smckusick a.a_desc = VDESC(vop_bwrite); 140*54646Smckusick a.a_bp = bp; 141*54646Smckusick return (VCALL((bp)->b_vp, VOFFSET(vop_bwrite), &a)); 142*54646Smckusick} 143*54646SmckusickEND_OF_SPECIAL_CASES 144