Removed my special-case hack for VOP_LINK and fixed the problem with the

wrong vp's ops vector being used by changing the VOP_LINK's argument order.
The special-case hack doesn't go far enough and breaks the generic
bypass routine used in some non-leaf filesystems. Pointed out by Kirk
McKusick.
This commit is contained in:
David Greenman 1995-08-01 18:51:02 +00:00
parent 162efbb15c
commit 4777741358
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=9842
17 changed files with 53 additions and 173 deletions

View File

@ -1,4 +1,4 @@
/* $Id: msdosfs_vnops.c,v 1.17 1995/06/11 19:31:37 rgrimes Exp $ */
/* $Id: msdosfs_vnops.c,v 1.18 1995/06/28 07:06:48 davidg Exp $ */
/* $NetBSD: msdosfs_vnops.c,v 1.20 1994/08/21 18:44:13 ws Exp $ */
/*-
@ -903,8 +903,8 @@ msdosfs_remove(ap)
int
msdosfs_link(ap)
struct vop_link_args /* {
struct vnode *a_vp;
struct vnode *a_tdvp;
struct vnode *a_vp;
struct componentname *a_cnp;
} */ *ap;
{

View File

@ -35,7 +35,7 @@
* SUCH DAMAGE.
*
* @(#)union_vnops.c 8.6 (Berkeley) 2/17/94
* $Id: union_vnops.c,v 1.8 1994/11/04 14:41:46 davidg Exp $
* $Id: union_vnops.c,v 1.9 1995/06/28 07:06:46 davidg Exp $
*/
#include <sys/param.h>
@ -898,8 +898,8 @@ union_remove(ap)
int
union_link(ap)
struct vop_link_args /* {
struct vnode *a_vp;
struct vnode *a_tdvp;
struct vnode *a_vp;
struct componentname *a_cnp;
} */ *ap;
{
@ -919,7 +919,7 @@ union_link(ap)
VREF(vp);
vrele(ap->a_tdvp);
error = VOP_LINK(vp, dvp, ap->a_cnp);
error = VOP_LINK(dvp, vp, ap->a_cnp);
} else {
/*
* XXX: need to copy to upper layer

View File

@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* @(#)vfs_syscalls.c 8.13 (Berkeley) 4/15/94
* $Id: vfs_syscalls.c,v 1.28 1995/07/13 08:47:42 davidg Exp $
* $Id: vfs_syscalls.c,v 1.29 1995/07/31 00:35:47 bde Exp $
*/
#include <sys/param.h>
@ -839,15 +839,7 @@ link(p, uap, retval)
nd.ni_dirp = uap->link;
error = namei(&nd);
if (!error) {
if (nd.ni_vp != NULL)
error = EEXIST;
if (!error) {
LEASE_CHECK(nd.ni_dvp,
p, p->p_ucred, LEASE_WRITE);
LEASE_CHECK(vp,
p, p->p_ucred, LEASE_WRITE);
error = VOP_LINK(vp, nd.ni_dvp, &nd.ni_cnd);
} else {
if (nd.ni_vp != NULL) {
VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd);
if (nd.ni_dvp == nd.ni_vp)
vrele(nd.ni_dvp);
@ -855,6 +847,13 @@ link(p, uap, retval)
vput(nd.ni_dvp);
if (nd.ni_vp)
vrele(nd.ni_vp);
error = EEXIST;
} else {
LEASE_CHECK(nd.ni_dvp,
p, p->p_ucred, LEASE_WRITE);
LEASE_CHECK(vp,
p, p->p_ucred, LEASE_WRITE);
error = VOP_LINK(nd.ni_dvp, vp, &nd.ni_cnd);
}
}
}

View File

@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* @(#)vfs_syscalls.c 8.13 (Berkeley) 4/15/94
* $Id: vfs_syscalls.c,v 1.28 1995/07/13 08:47:42 davidg Exp $
* $Id: vfs_syscalls.c,v 1.29 1995/07/31 00:35:47 bde Exp $
*/
#include <sys/param.h>
@ -839,15 +839,7 @@ link(p, uap, retval)
nd.ni_dirp = uap->link;
error = namei(&nd);
if (!error) {
if (nd.ni_vp != NULL)
error = EEXIST;
if (!error) {
LEASE_CHECK(nd.ni_dvp,
p, p->p_ucred, LEASE_WRITE);
LEASE_CHECK(vp,
p, p->p_ucred, LEASE_WRITE);
error = VOP_LINK(vp, nd.ni_dvp, &nd.ni_cnd);
} else {
if (nd.ni_vp != NULL) {
VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd);
if (nd.ni_dvp == nd.ni_vp)
vrele(nd.ni_dvp);
@ -855,6 +847,13 @@ link(p, uap, retval)
vput(nd.ni_dvp);
if (nd.ni_vp)
vrele(nd.ni_vp);
error = EEXIST;
} else {
LEASE_CHECK(nd.ni_dvp,
p, p->p_ucred, LEASE_WRITE);
LEASE_CHECK(vp,
p, p->p_ucred, LEASE_WRITE);
error = VOP_LINK(nd.ni_dvp, vp, &nd.ni_cnd);
}
}
}

View File

@ -32,7 +32,7 @@
# SUCH DAMAGE.
#
# @(#)vnode_if.sh 8.1 (Berkeley) 6/10/93
# $Id: vnode_if.sh,v 1.2 1994/08/02 07:43:34 davidg Exp $
# $Id: vnode_if.sh,v 1.3 1995/07/07 13:41:27 davidg Exp $
#
# Script to produce VFS front-end sugar.
@ -372,27 +372,6 @@ static inline int VOP_BWRITE(bp)
a.a_bp = bp;
return (VCALL((bp)->b_vp, VOFFSET(vop_bwrite), &a));
}
struct vop_link_args {
struct vnodeop_desc *a_desc;
struct vnode *a_vp;
struct vnode *a_tdvp;
struct componentname *a_cnp;
};
extern struct vnodeop_desc vop_link_desc;
static inline int VOP_LINK(vp, tdvp, cnp)
struct vnode *vp;
struct vnode *tdvp;
struct componentname *cnp;
{
struct vop_link_args a;
a.a_desc = VDESC(vop_link);
a.a_vp = vp;
a.a_tdvp = tdvp;
a.a_cnp = cnp;
return (VCALL(tdvp, VOFFSET(vop_link), &a));
}
END_OF_SPECIAL_CASES
cat << END_OF_SPECIAL_CASES >> $CFILE
@ -424,22 +403,6 @@ struct vnodeop_desc vop_bwrite_desc = {
VDESC_NO_OFFSET,
NULL,
};
int vop_link_vp_offsets[] = {
VOPARG_OFFSETOF(struct vop_link_args,a_vp),
VOPARG_OFFSETOF(struct vop_link_args,a_tdvp),
VDESC_NO_OFFSET
};
struct vnodeop_desc vop_link_desc = {
0,
"vop_link",
VDESC_VP1_WILLRELE,
vop_link_vp_offsets,
VDESC_NO_OFFSET,
VDESC_NO_OFFSET,
VDESC_NO_OFFSET,
VOPARG_OFFSETOF(struct vop_link_args,a_cnp),
NULL,
};
END_OF_SPECIAL_CASES
# Add the vfs_op_descs array to the C file.
@ -449,7 +412,6 @@ $AWK '
printf("\t&vop_default_desc, /* MUST BE FIRST */\n");
printf("\t&vop_strategy_desc, /* XXX: SPECIAL CASE */\n");
printf("\t&vop_bwrite_desc, /* XXX: SPECIAL CASE */\n");
printf("\t&vop_link_desc, /* XXX: SPECIAL CASE */\n");
}
END {
printf("\tNULL\n};\n");

View File

@ -32,7 +32,7 @@
# SUCH DAMAGE.
#
# @(#)vnode_if.sh 8.1 (Berkeley) 6/10/93
# $Id: vnode_if.sh,v 1.2 1994/08/02 07:43:34 davidg Exp $
# $Id: vnode_if.sh,v 1.3 1995/07/07 13:41:27 davidg Exp $
#
# Script to produce VFS front-end sugar.
@ -372,27 +372,6 @@ static inline int VOP_BWRITE(bp)
a.a_bp = bp;
return (VCALL((bp)->b_vp, VOFFSET(vop_bwrite), &a));
}
struct vop_link_args {
struct vnodeop_desc *a_desc;
struct vnode *a_vp;
struct vnode *a_tdvp;
struct componentname *a_cnp;
};
extern struct vnodeop_desc vop_link_desc;
static inline int VOP_LINK(vp, tdvp, cnp)
struct vnode *vp;
struct vnode *tdvp;
struct componentname *cnp;
{
struct vop_link_args a;
a.a_desc = VDESC(vop_link);
a.a_vp = vp;
a.a_tdvp = tdvp;
a.a_cnp = cnp;
return (VCALL(tdvp, VOFFSET(vop_link), &a));
}
END_OF_SPECIAL_CASES
cat << END_OF_SPECIAL_CASES >> $CFILE
@ -424,22 +403,6 @@ struct vnodeop_desc vop_bwrite_desc = {
VDESC_NO_OFFSET,
NULL,
};
int vop_link_vp_offsets[] = {
VOPARG_OFFSETOF(struct vop_link_args,a_vp),
VOPARG_OFFSETOF(struct vop_link_args,a_tdvp),
VDESC_NO_OFFSET
};
struct vnodeop_desc vop_link_desc = {
0,
"vop_link",
VDESC_VP1_WILLRELE,
vop_link_vp_offsets,
VDESC_NO_OFFSET,
VDESC_NO_OFFSET,
VDESC_NO_OFFSET,
VOPARG_OFFSETOF(struct vop_link_args,a_cnp),
NULL,
};
END_OF_SPECIAL_CASES
# Add the vfs_op_descs array to the C file.
@ -449,7 +412,6 @@ $AWK '
printf("\t&vop_default_desc, /* MUST BE FIRST */\n");
printf("\t&vop_strategy_desc, /* XXX: SPECIAL CASE */\n");
printf("\t&vop_bwrite_desc, /* XXX: SPECIAL CASE */\n");
printf("\t&vop_link_desc, /* XXX: SPECIAL CASE */\n");
}
END {
printf("\tNULL\n};\n");

View File

@ -31,7 +31,7 @@
# SUCH DAMAGE.
#
# @(#)vnode_if.src 8.3 (Berkeley) 2/3/94
# $Id: vnode_if.src,v 1.4 1995/06/28 07:06:41 davidg Exp $
# $Id: vnode_if.src,v 1.5 1995/07/07 13:41:28 davidg Exp $
#
vop_lookup {
IN struct vnode *dvp;
@ -148,15 +148,11 @@ vop_remove {
IN struct componentname *cnp;
};
# Gack. The generated VCALL uses the first vp which might
# not be handled by the same FS as the directory (e.g. special
# device files)...so it's special-cased.
#
#vop_link {
# IN struct vnode *vp;
# IN WILLRELE struct vnode *tdvp;
# IN struct componentname *cnp;
#};
vop_link {
IN WILLRELE struct vnode *tdvp;
IN struct vnode *vp;
IN struct componentname *cnp;
};
vop_rename {
IN WILLRELE struct vnode *fdvp;

View File

@ -1,7 +1,7 @@
/*
* Written by Julian Elischer (julian@DIALix.oz.au)
*
* $Header: /home/ncvs/src/sys/miscfs/devfs/devfs_vnops.c,v 1.4 1995/05/03 23:04:26 julian Exp $
* $Header: /home/ncvs/src/sys/miscfs/devfs/devfs_vnops.c,v 1.5 1995/05/30 08:06:53 rgrimes Exp $
*
* symlinks can wait 'til later.
*/
@ -820,8 +820,8 @@ DBPRINT(("remove\n"));
*/
int devfs_link(ap)
struct vop_link_args /* {
struct vnode *a_vp;
struct vnode *a_tdvp;
struct vnode *a_vp;
struct componentname *a_cnp;
} */ *ap;
{

View File

@ -35,7 +35,7 @@
* SUCH DAMAGE.
*
* @(#)union_vnops.c 8.6 (Berkeley) 2/17/94
* $Id: union_vnops.c,v 1.8 1994/11/04 14:41:46 davidg Exp $
* $Id: union_vnops.c,v 1.9 1995/06/28 07:06:46 davidg Exp $
*/
#include <sys/param.h>
@ -898,8 +898,8 @@ union_remove(ap)
int
union_link(ap)
struct vop_link_args /* {
struct vnode *a_vp;
struct vnode *a_tdvp;
struct vnode *a_vp;
struct componentname *a_cnp;
} */ *ap;
{
@ -919,7 +919,7 @@ union_link(ap)
VREF(vp);
vrele(ap->a_tdvp);
error = VOP_LINK(vp, dvp, ap->a_cnp);
error = VOP_LINK(dvp, vp, ap->a_cnp);
} else {
/*
* XXX: need to copy to upper layer

View File

@ -1,4 +1,4 @@
/* $Id: msdosfs_vnops.c,v 1.17 1995/06/11 19:31:37 rgrimes Exp $ */
/* $Id: msdosfs_vnops.c,v 1.18 1995/06/28 07:06:48 davidg Exp $ */
/* $NetBSD: msdosfs_vnops.c,v 1.20 1994/08/21 18:44:13 ws Exp $ */
/*-
@ -903,8 +903,8 @@ msdosfs_remove(ap)
int
msdosfs_link(ap)
struct vop_link_args /* {
struct vnode *a_vp;
struct vnode *a_tdvp;
struct vnode *a_vp;
struct componentname *a_cnp;
} */ *ap;
{

View File

@ -34,7 +34,7 @@
* SUCH DAMAGE.
*
* @(#)nfs_serv.c 8.3 (Berkeley) 1/12/94
* $Id: nfs_serv.c,v 1.17 1995/06/28 07:06:50 davidg Exp $
* $Id: nfs_serv.c,v 1.18 1995/06/28 12:01:03 davidg Exp $
*/
/*
@ -2026,7 +2026,7 @@ out:
if (!error) {
nqsrv_getl(vp, ND_WRITE);
nqsrv_getl(xp, ND_WRITE);
#if defined(__NetBSD__)
#if defined(__NetBSD__) || defined(__FreeBSD__)
error = VOP_LINK(nd.ni_dvp, vp, &nd.ni_cnd);
#else
error = VOP_LINK(vp, nd.ni_dvp, &nd.ni_cnd);

View File

@ -34,7 +34,7 @@
* SUCH DAMAGE.
*
* @(#)nfs_vnops.c 8.5 (Berkeley) 2/13/94
* $Id: nfs_vnops.c,v 1.21 1995/07/24 12:50:49 dfr Exp $
* $Id: nfs_vnops.c,v 1.22 1995/07/24 16:38:05 dfr Exp $
*/
/*
@ -1646,14 +1646,14 @@ nfs_renamerpc(fdvp, fnameptr, fnamelen, tdvp, tnameptr, tnamelen, cred, proc)
int
nfs_link(ap)
struct vop_link_args /* {
struct vnode *a_vp;
struct vnode *a_tdvp;
struct vnode *a_vp;
struct componentname *a_cnp;
} */ *ap;
{
#if defined(__NetBSD__)
/*
* Since the args are reversed in the VOP_LINK() calls,
* Since the args are reversed in the VOP_LINK() calls,
* switch them back. Argh!
*/
register struct vnode *vp = ap->a_tdvp;

View File

@ -34,7 +34,7 @@
* SUCH DAMAGE.
*
* @(#)nfs_vnops.c 8.5 (Berkeley) 2/13/94
* $Id: nfs_vnops.c,v 1.21 1995/07/24 12:50:49 dfr Exp $
* $Id: nfs_vnops.c,v 1.22 1995/07/24 16:38:05 dfr Exp $
*/
/*
@ -1646,14 +1646,14 @@ nfs_renamerpc(fdvp, fnameptr, fnamelen, tdvp, tnameptr, tnamelen, cred, proc)
int
nfs_link(ap)
struct vop_link_args /* {
struct vnode *a_vp;
struct vnode *a_tdvp;
struct vnode *a_vp;
struct componentname *a_cnp;
} */ *ap;
{
#if defined(__NetBSD__)
/*
* Since the args are reversed in the VOP_LINK() calls,
* Since the args are reversed in the VOP_LINK() calls,
* switch them back. Argh!
*/
register struct vnode *vp = ap->a_tdvp;

View File

@ -34,7 +34,7 @@
* SUCH DAMAGE.
*
* @(#)nfs_serv.c 8.3 (Berkeley) 1/12/94
* $Id: nfs_serv.c,v 1.17 1995/06/28 07:06:50 davidg Exp $
* $Id: nfs_serv.c,v 1.18 1995/06/28 12:01:03 davidg Exp $
*/
/*
@ -2026,7 +2026,7 @@ out:
if (!error) {
nqsrv_getl(vp, ND_WRITE);
nqsrv_getl(xp, ND_WRITE);
#if defined(__NetBSD__)
#if defined(__NetBSD__) || defined(__FreeBSD__)
error = VOP_LINK(nd.ni_dvp, vp, &nd.ni_cnd);
#else
error = VOP_LINK(vp, nd.ni_dvp, &nd.ni_cnd);

View File

@ -32,7 +32,7 @@
# SUCH DAMAGE.
#
# @(#)vnode_if.sh 8.1 (Berkeley) 6/10/93
# $Id: vnode_if.sh,v 1.2 1994/08/02 07:43:34 davidg Exp $
# $Id: vnode_if.sh,v 1.3 1995/07/07 13:41:27 davidg Exp $
#
# Script to produce VFS front-end sugar.
@ -372,27 +372,6 @@ static inline int VOP_BWRITE(bp)
a.a_bp = bp;
return (VCALL((bp)->b_vp, VOFFSET(vop_bwrite), &a));
}
struct vop_link_args {
struct vnodeop_desc *a_desc;
struct vnode *a_vp;
struct vnode *a_tdvp;
struct componentname *a_cnp;
};
extern struct vnodeop_desc vop_link_desc;
static inline int VOP_LINK(vp, tdvp, cnp)
struct vnode *vp;
struct vnode *tdvp;
struct componentname *cnp;
{
struct vop_link_args a;
a.a_desc = VDESC(vop_link);
a.a_vp = vp;
a.a_tdvp = tdvp;
a.a_cnp = cnp;
return (VCALL(tdvp, VOFFSET(vop_link), &a));
}
END_OF_SPECIAL_CASES
cat << END_OF_SPECIAL_CASES >> $CFILE
@ -424,22 +403,6 @@ struct vnodeop_desc vop_bwrite_desc = {
VDESC_NO_OFFSET,
NULL,
};
int vop_link_vp_offsets[] = {
VOPARG_OFFSETOF(struct vop_link_args,a_vp),
VOPARG_OFFSETOF(struct vop_link_args,a_tdvp),
VDESC_NO_OFFSET
};
struct vnodeop_desc vop_link_desc = {
0,
"vop_link",
VDESC_VP1_WILLRELE,
vop_link_vp_offsets,
VDESC_NO_OFFSET,
VDESC_NO_OFFSET,
VDESC_NO_OFFSET,
VOPARG_OFFSETOF(struct vop_link_args,a_cnp),
NULL,
};
END_OF_SPECIAL_CASES
# Add the vfs_op_descs array to the C file.
@ -449,7 +412,6 @@ $AWK '
printf("\t&vop_default_desc, /* MUST BE FIRST */\n");
printf("\t&vop_strategy_desc, /* XXX: SPECIAL CASE */\n");
printf("\t&vop_bwrite_desc, /* XXX: SPECIAL CASE */\n");
printf("\t&vop_link_desc, /* XXX: SPECIAL CASE */\n");
}
END {
printf("\tNULL\n};\n");

View File

@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* @(#)lfs_vnops.c 8.5 (Berkeley) 12/30/93
* $Id: lfs_vnops.c,v 1.11 1995/06/28 12:01:10 davidg Exp $
* $Id: lfs_vnops.c,v 1.12 1995/07/13 08:48:07 davidg Exp $
*/
#include <sys/param.h>
@ -381,8 +381,8 @@ lfs_rmdir(ap)
int
lfs_link(ap)
struct vop_link_args /* {
struct vnode *a_vp;
struct vnode *a_tdvp;
struct vnode *a_vp;
struct componentname *a_cnp;
} */ *ap;
{

View File

@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* @(#)ufs_vnops.c 8.10 (Berkeley) 4/1/94
* $Id: ufs_vnops.c,v 1.24 1995/05/30 08:15:39 rgrimes Exp $
* $Id: ufs_vnops.c,v 1.25 1995/06/28 07:06:55 davidg Exp $
*/
#include <sys/param.h>
@ -666,8 +666,8 @@ out:
int
ufs_link(ap)
struct vop_link_args /* {
struct vnode *a_vp;
struct vnode *a_tdvp;
struct vnode *a_vp;
struct componentname *a_cnp;
} */ *ap;
{