diff --git a/sys/kern/vfs_init.c b/sys/kern/vfs_init.c index 5754b629c8a7..b52b08b3b8e3 100644 --- a/sys/kern/vfs_init.c +++ b/sys/kern/vfs_init.c @@ -36,7 +36,7 @@ * SUCH DAMAGE. * * @(#)vfs_init.c 8.3 (Berkeley) 1/4/94 - * $Id: vfs_init.c,v 1.25 1997/03/02 11:06:21 bde Exp $ + * $Id: vfs_init.c,v 1.26 1997/08/02 14:31:44 bde Exp $ */ @@ -70,13 +70,6 @@ extern struct linker_set vfs_set; extern struct vnodeop_desc *vfs_op_descs[]; /* and the operations they perform */ -/* - * This code doesn't work if the defn is **vnodop_defns with cc. - * The problem is because of the compiler sometimes putting in an - * extra level of indirection for arrays. It's an interesting - * "feature" of C. - */ -static int vfs_opv_numops; /* * A miscellaneous routine. @@ -104,6 +97,12 @@ vn_default_error() * listing those new operations Ficus adds to NFS, all without modifying the * NFS code. (Of couse, the OTW NFS protocol still needs to be munged, but * that is a(whole)nother story.) This is a feature. + * + * Without an explicit reserve area, however, you must replace vnode_if.c + * and vnode_if.h when you do this, or you will be derefrencing of the + * end of vfs_op_descs[]. This is a flaw in the use of a structure + * pointer array rather than an agregate to define vfs_op_descs. So + * it's not a very dynamic "feature". */ void vfs_opv_init(struct vnodeopv_desc **them) @@ -197,20 +196,24 @@ vfs_op_init() int i; DODEBUG(printf("Vnode_interface_init.\n")); + DODEBUG(printf ("vfs_opv_numops=%d\n", vfs_opv_numops)); /* * Set all vnode vectors to a well known value. */ for (i = 0; vfs_opv_descs[i]; i++) *(vfs_opv_descs[i]->opv_desc_vector_p) = NULL; /* - * Figure out how many ops there are by counting the table, - * and assign each its offset. + * assign each op to its offset + * + * XXX This should not be needed, but is because the per + * XXX FS ops tables are not sorted according to the + * XXX vnodeop_desc's offset in vfs_op_descs. This + * XXX is the same reason we have to take the hit for + * XXX the static inline function calls instead of using + * XXX simple macro references. */ - for (vfs_opv_numops = 0, i = 0; vfs_op_descs[i]; i++) { - vfs_op_descs[i]->vdesc_offset = vfs_opv_numops; - vfs_opv_numops++; - } - DODEBUG(printf ("vfs_opv_numops=%d\n", vfs_opv_numops)); + for (i = 0; i < vfs_opv_numops; i++) + vfs_op_descs[i]->vdesc_offset = i; } /* diff --git a/sys/kern/vnode_if.pl b/sys/kern/vnode_if.pl index 75f49a763041..d351d8e64537 100644 --- a/sys/kern/vnode_if.pl +++ b/sys/kern/vnode_if.pl @@ -32,7 +32,7 @@ # SUCH DAMAGE. # # @(#)vnode_if.sh 8.1 (Berkeley) 6/10/93 -# $Id$ +# $Id: vnode_if.sh,v 1.11 1997/02/22 09:39:36 peter Exp $ # # Script to produce VFS front-end sugar. @@ -397,6 +397,8 @@ static inline int VOP_BWRITE(bp) a.a_bp = bp; return (VCALL((bp)->b_vp, VOFFSET(vop_bwrite), &a)); } + +extern int vfs_opv_numops; END_OF_SPECIAL_CASES cat << END_OF_SPECIAL_CASES >> $CFILE @@ -457,3 +459,11 @@ $AWK ' } }' < $SRC >> $CFILE +cat << END_OF_NUMOPS_CODE >> $CFILE + +/* + * the -1 is to account for the NULL + * XXX is the NULL still necessary? I don't think so... + */ +int vfs_opv_numops = (sizeof(vfs_op_descs)/sizeof(struct vnodeop_desc *)) - 1; +END_OF_NUMOPS_CODE diff --git a/sys/kern/vnode_if.sh b/sys/kern/vnode_if.sh index 75f49a763041..d351d8e64537 100644 --- a/sys/kern/vnode_if.sh +++ b/sys/kern/vnode_if.sh @@ -32,7 +32,7 @@ # SUCH DAMAGE. # # @(#)vnode_if.sh 8.1 (Berkeley) 6/10/93 -# $Id$ +# $Id: vnode_if.sh,v 1.11 1997/02/22 09:39:36 peter Exp $ # # Script to produce VFS front-end sugar. @@ -397,6 +397,8 @@ static inline int VOP_BWRITE(bp) a.a_bp = bp; return (VCALL((bp)->b_vp, VOFFSET(vop_bwrite), &a)); } + +extern int vfs_opv_numops; END_OF_SPECIAL_CASES cat << END_OF_SPECIAL_CASES >> $CFILE @@ -457,3 +459,11 @@ $AWK ' } }' < $SRC >> $CFILE +cat << END_OF_NUMOPS_CODE >> $CFILE + +/* + * the -1 is to account for the NULL + * XXX is the NULL still necessary? I don't think so... + */ +int vfs_opv_numops = (sizeof(vfs_op_descs)/sizeof(struct vnodeop_desc *)) - 1; +END_OF_NUMOPS_CODE diff --git a/sys/tools/vnode_if.awk b/sys/tools/vnode_if.awk index 75f49a763041..d351d8e64537 100644 --- a/sys/tools/vnode_if.awk +++ b/sys/tools/vnode_if.awk @@ -32,7 +32,7 @@ # SUCH DAMAGE. # # @(#)vnode_if.sh 8.1 (Berkeley) 6/10/93 -# $Id$ +# $Id: vnode_if.sh,v 1.11 1997/02/22 09:39:36 peter Exp $ # # Script to produce VFS front-end sugar. @@ -397,6 +397,8 @@ static inline int VOP_BWRITE(bp) a.a_bp = bp; return (VCALL((bp)->b_vp, VOFFSET(vop_bwrite), &a)); } + +extern int vfs_opv_numops; END_OF_SPECIAL_CASES cat << END_OF_SPECIAL_CASES >> $CFILE @@ -457,3 +459,11 @@ $AWK ' } }' < $SRC >> $CFILE +cat << END_OF_NUMOPS_CODE >> $CFILE + +/* + * the -1 is to account for the NULL + * XXX is the NULL still necessary? I don't think so... + */ +int vfs_opv_numops = (sizeof(vfs_op_descs)/sizeof(struct vnodeop_desc *)) - 1; +END_OF_NUMOPS_CODE