change vop_symlink and vop_mknod to return vpp (the created node)

refed, so that the caller can actually use it.  update callers and
file systems that implement these vnode operations
This commit is contained in:
assar 2001-07-24 15:39:30 +00:00
parent 8dc13781cb
commit bec71dc090
12 changed files with 96 additions and 93 deletions

View File

@ -6,7 +6,7 @@ mkdir
rmdir
symlink
*/
/* $NetBSD: coda_vnops.c,v 1.25 2001/07/03 06:46:52 chs Exp $ */
/* $NetBSD: coda_vnops.c,v 1.26 2001/07/24 15:39:30 assar Exp $ */
/*
*
@ -1654,21 +1654,6 @@ coda_symlink(v)
*ap->a_vpp = nd.ni_vp;
}
/*
* Okay, now we have to drop locks on dvp. vpp is unlocked, but
* ref'd. It doesn't matter what happens in either symlink or
* lookup. Furthermore, there isn't any way for (dvp == *vpp), so
* we don't bother checking.
*/
/* vput(ap->a_dvp); released earlier */
if (*ap->a_vpp) {
VOP_UNLOCK(*ap->a_vpp, 0); /* this line is new!! It is necessary because lookup() calls
VOP_LOOKUP (coda_lookup) which returns vpp locked. cfs_nb_lookup
merged with coda_lookup() to become coda_lookup so UNLOCK is
necessary */
vrele(*ap->a_vpp);
}
/*
* Free the name buffer
*/

View File

@ -1,4 +1,4 @@
/* $NetBSD: vfs_syscalls.c,v 1.167 2001/06/28 08:04:18 jdolecek Exp $ */
/* $NetBSD: vfs_syscalls.c,v 1.168 2001/07/24 15:39:31 assar Exp $ */
/*
* Copyright (c) 1989, 1993
@ -1381,6 +1381,8 @@ sys_mknod(p, v, retval)
} else {
error = VOP_MKNOD(nd.ni_dvp, &nd.ni_vp,
&nd.ni_cnd, &vattr);
if (error == 0)
vput(nd.ni_vp);
}
} else {
VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd);
@ -1428,7 +1430,10 @@ sys_mkfifo(p, v, retval)
vattr.va_type = VFIFO;
vattr.va_mode = (SCARG(uap, mode) & ALLPERMS) &~ p->p_cwdi->cwdi_cmask;
VOP_LEASE(nd.ni_dvp, p, p->p_ucred, LEASE_WRITE);
return (VOP_MKNOD(nd.ni_dvp, &nd.ni_vp, &nd.ni_cnd, &vattr));
error = VOP_MKNOD(nd.ni_dvp, &nd.ni_vp, &nd.ni_cnd, &vattr);
if (error == 0)
vput(nd.ni_vp);
return (error);
}
/*
@ -1514,6 +1519,8 @@ sys_symlink(p, v, retval)
vattr.va_mode = ACCESSPERMS &~ p->p_cwdi->cwdi_cmask;
VOP_LEASE(nd.ni_dvp, p, p->p_ucred, LEASE_WRITE);
error = VOP_SYMLINK(nd.ni_dvp, &nd.ni_vp, &nd.ni_cnd, &vattr, path);
if (error == 0)
vput(nd.ni_vp);
out:
PNBUF_PUT(path);
return (error);

View File

@ -1,4 +1,4 @@
/* $NetBSD: vnode_if.c,v 1.36 2001/05/26 21:34:04 chs Exp $ */
/* $NetBSD: vnode_if.c,v 1.37 2001/07/24 15:39:31 assar Exp $ */
/*
* Warning: This file is generated automatically.
@ -198,7 +198,7 @@ const int vop_mknod_vp_offsets[] = {
const struct vnodeop_desc vop_mknod_desc = {
5,
"vop_mknod",
0 | VDESC_VP0_WILLPUT | VDESC_VPP_WILLRELE,
0 | VDESC_VP0_WILLPUT,
vop_mknod_vp_offsets,
VOPARG_OFFSETOF(struct vop_mknod_args, a_vpp),
VDESC_NO_OFFSET,
@ -868,7 +868,7 @@ const int vop_symlink_vp_offsets[] = {
const struct vnodeop_desc vop_symlink_desc = {
25,
"vop_symlink",
0 | VDESC_VP0_WILLPUT | VDESC_VPP_WILLRELE,
0 | VDESC_VP0_WILLPUT,
vop_symlink_vp_offsets,
VOPARG_OFFSETOF(struct vop_symlink_args, a_vpp),
VDESC_NO_OFFSET,

View File

@ -1,4 +1,4 @@
# $NetBSD: vnode_if.src,v 1.28 2001/05/26 21:33:11 chs Exp $
# $NetBSD: vnode_if.src,v 1.29 2001/07/24 15:39:31 assar Exp $
#
# Copyright (c) 1992, 1993
# The Regents of the University of California. All rights reserved.
@ -113,13 +113,13 @@ vop_create {
#
#% mknod dvp L U U
#% mknod vpp - X -
#% mknod vpp - L -
#
#! mknod cnp CREATE, LOCKPARENT
#
vop_mknod {
IN WILLPUT struct vnode *dvp;
OUT WILLRELE struct vnode **vpp;
OUT struct vnode **vpp;
IN struct componentname *cnp;
IN struct vattr *vap;
};
@ -338,17 +338,13 @@ vop_rmdir {
#
#% symlink dvp L U U
#% symlink vpp - U -
#% symlink vpp - L -
#
#! symlink cnp CREATE, LOCKPARENT
#
# XXX - note that the return vnode has already been VRELE'ed
# by the filesystem layer. To use it you must use vget,
# possibly with a further namei.
#
vop_symlink {
IN WILLPUT struct vnode *dvp;
OUT WILLRELE struct vnode **vpp;
OUT struct vnode **vpp;
IN struct componentname *cnp;
IN struct vattr *vap;
IN char *target;

View File

@ -1,4 +1,4 @@
/* $NetBSD: mln_ipl.c,v 1.24 2001/02/05 10:42:42 chs Exp $ */
/* $NetBSD: mln_ipl.c,v 1.25 2001/07/24 15:39:32 assar Exp $ */
/*
* Copyright (C) 1993-2000 by Darren Reed.
@ -253,6 +253,7 @@ static int ipl_load()
error = VOP_MKNOD(nd.ni_dvp, &nd.ni_vp, &nd.ni_cnd, &vattr);
if (error)
return error;
vput(nd.ni_vp);
}
return error;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: layer_vnops.c,v 1.6 2001/06/07 13:32:47 wiz Exp $ */
/* $NetBSD: layer_vnops.c,v 1.7 2001/07/24 15:39:32 assar Exp $ */
/*
* Copyright (c) 1999 National Aeronautics & Space Administration
@ -71,7 +71,7 @@
*
* Ancestors:
* @(#)lofs_vnops.c 1.2 (Berkeley) 6/18/92
* $Id: layer_vnops.c,v 1.6 2001/06/07 13:32:47 wiz Exp $
* $Id: layer_vnops.c,v 1.7 2001/07/24 15:39:32 assar Exp $
* ...and...
* @(#)null_vnodeops.c 1.20 92/07/07 UCLA Ficus project
*/
@ -393,8 +393,7 @@ layer_bypass(v)
descp->vdesc_vpp_offset,ap);
/*
* Only vop_lookup, vop_create, vop_makedir, vop_bmap,
* vop_mknod, and vop_symlink return vpp's. The latter
* two are VPP_WILLRELE, so we won't get here, and vop_bmap
* vop_mknod, and vop_symlink return vpp's. vop_bmap
* doesn't call bypass as the lower vpp is fine (we're just
* going to do i/o on it). vop_loookup doesn't call bypass
* as a lookup on "." would generate a locking error.

View File

@ -1,4 +1,4 @@
/* $NetBSD: union_vnops.c,v 1.53 2001/07/04 21:38:00 chs Exp $ */
/* $NetBSD: union_vnops.c,v 1.54 2001/07/24 15:39:32 assar Exp $ */
/*
* Copyright (c) 1992, 1993, 1994, 1995 Jan-Simon Pendry.
@ -610,12 +610,10 @@ union_mknod(v)
if (error)
return (error);
if (vp != NULLVP) {
error = union_allocvp(ap->a_vpp, mp, NULLVP, NULLVP,
cnp, vp, NULLVP, 1);
if (error)
vput(vp);
}
error = union_allocvp(ap->a_vpp, mp, NULLVP, NULLVP,
cnp, vp, NULLVP, 1);
if (error)
vput(vp);
return (error);
}
@ -1527,14 +1525,13 @@ union_symlink(v)
if (dvp != NULLVP) {
int error;
struct vnode *vp;
FIXUP(un);
VREF(dvp);
un->un_flags |= UN_KLOCK;
vput(ap->a_dvp);
error = VOP_SYMLINK(dvp, &vp, cnp, ap->a_vap, ap->a_target);
*ap->a_vpp = NULLVP;
error = VOP_SYMLINK(dvp, ap->a_vpp, cnp, ap->a_vap,
ap->a_target);
return (error);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: nfs_serv.c,v 1.59 2000/11/27 08:39:49 chs Exp $ */
/* $NetBSD: nfs_serv.c,v 1.60 2001/07/24 15:39:33 assar Exp $ */
/*
* Copyright (c) 1989, 1993
@ -1417,14 +1417,6 @@ nfsrv_create(nfsd, slp, procp, mrq)
vrele(nd.ni_startdir);
nfsm_reply(0);
}
nd.ni_cnd.cn_nameiop = LOOKUP;
nd.ni_cnd.cn_flags &= ~(LOCKPARENT | SAVESTART);
nd.ni_cnd.cn_proc = procp;
nd.ni_cnd.cn_cred = cred;
if ((error = lookup(&nd)) != 0) {
PNBUF_PUT(nd.ni_cnd.cn_pnbuf);
nfsm_reply(0);
}
PNBUF_PUT(nd.ni_cnd.cn_pnbuf);
if (nd.ni_cnd.cn_flags & ISSYMLINK) {
vrele(nd.ni_dvp);
@ -1618,11 +1610,6 @@ nfsrv_mknod(nfsd, slp, procp, mrq)
vrele(nd.ni_startdir);
goto out;
}
nd.ni_cnd.cn_nameiop = LOOKUP;
nd.ni_cnd.cn_flags &= ~(LOCKPARENT | SAVESTART);
nd.ni_cnd.cn_proc = procp;
nd.ni_cnd.cn_cred = procp->p_ucred;
error = lookup(&nd);
PNBUF_PUT(nd.ni_cnd.cn_pnbuf);
if (error)
goto out;
@ -2146,23 +2133,17 @@ nfsrv_symlink(nfsd, slp, procp, mrq)
vrele(nd.ni_startdir);
else {
if (v3) {
nd.ni_cnd.cn_nameiop = LOOKUP;
nd.ni_cnd.cn_flags &= ~(LOCKPARENT | SAVESTART | FOLLOW);
nd.ni_cnd.cn_flags |= (NOFOLLOW | LOCKLEAF);
nd.ni_cnd.cn_proc = procp;
nd.ni_cnd.cn_cred = cred;
error = lookup(&nd);
if (!error) {
memset((caddr_t)fhp, 0, sizeof(nfh));
fhp->fh_fsid = nd.ni_vp->v_mount->mnt_stat.f_fsid;
error = VFS_VPTOFH(nd.ni_vp, &fhp->fh_fid);
if (!error)
error = VOP_GETATTR(nd.ni_vp, &va, cred,
memset((caddr_t)fhp, 0, sizeof(nfh));
fhp->fh_fsid = nd.ni_vp->v_mount->mnt_stat.f_fsid;
error = VFS_VPTOFH(nd.ni_vp, &fhp->fh_fid);
if (!error)
error = VOP_GETATTR(nd.ni_vp, &va, cred,
procp);
vput(nd.ni_vp);
}
} else
vput(nd.ni_vp);
} else {
vrele(nd.ni_startdir);
vput(nd.ni_vp);
}
PNBUF_PUT(nd.ni_cnd.cn_pnbuf);
}
out:

View File

@ -1,4 +1,4 @@
/* $NetBSD: nfs_vnops.c,v 1.134 2001/06/07 01:04:40 lukem Exp $ */
/* $NetBSD: nfs_vnops.c,v 1.135 2001/07/24 15:39:33 assar Exp $ */
/*
* Copyright (c) 1989, 1993
@ -1407,8 +1407,6 @@ nfs_mknod(v)
int error;
error = nfs_mknodrpc(ap->a_dvp, &newvp, ap->a_cnp, ap->a_vap);
if (!error)
vput(newvp);
return (error);
}
@ -1869,6 +1867,7 @@ nfs_symlink(v)
struct vnode *newvp = (struct vnode *)0;
const int v3 = NFS_ISV3(dvp);
*ap->a_vpp = NULL;
nfsstats.rpccnt[NFSPROC_SYMLINK]++;
slen = strlen(ap->a_target);
nfsm_reqhead(dvp, NFSPROC_SYMLINK, NFSX_FH(v3) + 2*NFSX_UNSIGNED +
@ -1894,18 +1893,30 @@ nfs_symlink(v)
nfsm_wcc_data(dvp, wccflag);
}
nfsm_reqdone;
if (newvp)
vput(newvp);
PNBUF_PUT(cnp->cn_pnbuf);
VTONFS(dvp)->n_flag |= NMODIFIED;
if (!wccflag)
VTONFS(dvp)->n_attrstamp = 0;
vput(dvp);
/*
* Kludge: Map EEXIST => 0 assuming that it is a reply to a retry.
*/
if (error == EEXIST)
error = 0;
if (error == 0 && newvp == NULL) {
struct nfsnode *np = NULL;
error = nfs_lookitup(dvp, cnp->cn_nameptr, cnp->cn_namelen,
cnp->cn_cred, cnp->cn_proc, &np);
if (error == 0)
newvp = NFSTOV(np);
}
if (error) {
if (newvp != NULL)
vput(newvp);
} else {
*ap->a_vpp = newvp;
}
PNBUF_PUT(cnp->cn_pnbuf);
VTONFS(dvp)->n_flag |= NMODIFIED;
if (!wccflag)
VTONFS(dvp)->n_attrstamp = 0;
vput(dvp);
return (error);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: ext2fs_vnops.c,v 1.33 2001/03/23 21:11:08 fvdl Exp $ */
/* $NetBSD: ext2fs_vnops.c,v 1.34 2001/07/24 15:39:34 assar Exp $ */
/*
* Copyright (c) 1997 Manuel Bouyer.
@ -132,11 +132,15 @@ ext2fs_mknod(v)
struct vnode **vpp = ap->a_vpp;
struct inode *ip;
int error;
struct mount *mp;
ino_t ino;
if ((error = ext2fs_makeinode(MAKEIMODE(vap->va_type, vap->va_mode),
ap->a_dvp, vpp, ap->a_cnp)) != 0)
return (error);
ip = VTOI(*vpp);
mp = (*vpp)->v_mount;
ino = ip->i_number;
ip->i_flag |= IN_ACCESS | IN_CHANGE | IN_UPDATE;
if (vap->va_rdev != VNOVAL) {
/*
@ -153,7 +157,11 @@ ext2fs_mknod(v)
vput(*vpp);
(*vpp)->v_type = VNON;
vgone(*vpp);
*vpp = 0;
error = VFS_VGET(mp, ino, vpp);
if (error != 0) {
*vpp = NULL;
return (error);
}
return (0);
}
@ -1206,7 +1214,8 @@ ext2fs_symlink(v)
error = vn_rdwr(UIO_WRITE, vp, ap->a_target, len, (off_t)0,
UIO_SYSSPACE, IO_NODELOCKED, ap->a_cnp->cn_cred,
(size_t *)0, (struct proc *)0);
vput(vp);
if (error)
vput(vp);
return (error);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: lfs_vnops.c,v 1.51 2001/07/13 20:30:25 perseant Exp $ */
/* $NetBSD: lfs_vnops.c,v 1.52 2001/07/24 15:39:34 assar Exp $ */
/*-
* Copyright (c) 1999, 2000 The NetBSD Foundation, Inc.
@ -450,6 +450,8 @@ lfs_mknod(void *v)
struct vnode **vpp = ap->a_vpp;
struct inode *ip;
int error;
struct mount *mp;
ino_t ino;
if ((error = SET_DIROP(ap->a_dvp)) != 0) {
vput(ap->a_dvp);
@ -469,6 +471,8 @@ lfs_mknod(void *v)
return (error);
ip = VTOI(*vpp);
mp = (*vpp)->v_mount;
ino = ip->i_number;
ip->i_flag |= IN_ACCESS | IN_CHANGE | IN_UPDATE;
if (vap->va_rdev != VNOVAL) {
/*
@ -505,7 +509,11 @@ lfs_mknod(void *v)
lfs_vunref(*vpp);
(*vpp)->v_type = VNON;
vgone(*vpp);
*vpp = 0;
error = VFS_VGET(mp, ino, vpp);
if (error != 0) {
*vpp = NULL;
return (error);
}
return (0);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: ufs_vnops.c,v 1.78 2001/05/28 02:50:53 chs Exp $ */
/* $NetBSD: ufs_vnops.c,v 1.79 2001/07/24 15:39:35 assar Exp $ */
/*
* Copyright (c) 1982, 1986, 1989, 1993, 1995
@ -138,6 +138,8 @@ ufs_mknod(void *v)
struct vnode **vpp;
struct inode *ip;
int error;
struct mount *mp;
ino_t ino;
vap = ap->a_vap;
vpp = ap->a_vpp;
@ -146,6 +148,8 @@ ufs_mknod(void *v)
ap->a_dvp, vpp, ap->a_cnp)) != 0)
return (error);
ip = VTOI(*vpp);
mp = (*vpp)->v_mount;
ino = ip->i_number;
ip->i_flag |= IN_ACCESS | IN_CHANGE | IN_UPDATE;
if (vap->va_rdev != VNOVAL) {
/*
@ -153,7 +157,7 @@ ufs_mknod(void *v)
* inodes, so don't truncate the dev number.
*/
ip->i_ffs_rdev = ufs_rw32(vap->va_rdev,
UFS_MPNEEDSWAP((*vpp)->v_mount));
UFS_MPNEEDSWAP(mp));
}
/*
* Remove inode so that it will be reloaded by VFS_VGET and
@ -163,7 +167,11 @@ ufs_mknod(void *v)
vput(*vpp);
(*vpp)->v_type = VNON;
vgone(*vpp);
*vpp = 0;
error = VFS_VGET(mp, ino, vpp);
if (error != 0) {
*vpp = NULL;
return (error);
}
return (0);
}
@ -1450,7 +1458,8 @@ ufs_symlink(void *v)
error = vn_rdwr(UIO_WRITE, vp, ap->a_target, len, (off_t)0,
UIO_SYSSPACE, IO_NODELOCKED, ap->a_cnp->cn_cred, NULL,
(struct proc *)0);
vput(vp);
if (error)
vput(vp);
return (error);
}