diff options
author | assar <assar@cvs.openbsd.org> | 2001-07-26 02:10:42 +0000 |
---|---|---|
committer | assar <assar@cvs.openbsd.org> | 2001-07-26 02:10:42 +0000 |
commit | 9d3aef2f8343f433bc39e01bd86f02e3a4815af3 (patch) | |
tree | 5767d4e31c87272afaf2ef7a4c68622da92a9866 /sys | |
parent | 884823bfdf5ae3686d10cc854ad323da4e92734e (diff) |
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
ok'd by art
Diffstat (limited to 'sys')
-rw-r--r-- | sys/kern/vfs_syscalls.c | 11 | ||||
-rw-r--r-- | sys/kern/vnode_if.c | 4 | ||||
-rw-r--r-- | sys/kern/vnode_if.src | 14 | ||||
-rw-r--r-- | sys/miscfs/union/union_vnops.c | 30 | ||||
-rw-r--r-- | sys/nfs/nfs_serv.c | 45 | ||||
-rw-r--r-- | sys/nfs/nfs_vnops.c | 30 | ||||
-rw-r--r-- | sys/ufs/ext2fs/ext2fs_vnops.c | 12 | ||||
-rw-r--r-- | sys/ufs/ufs/ufs_vnops.c | 13 |
8 files changed, 80 insertions, 79 deletions
diff --git a/sys/kern/vfs_syscalls.c b/sys/kern/vfs_syscalls.c index 9fabe83751d..a8db38f7ece 100644 --- a/sys/kern/vfs_syscalls.c +++ b/sys/kern/vfs_syscalls.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vfs_syscalls.c,v 1.78 2001/06/27 04:49:48 art Exp $ */ +/* $OpenBSD: vfs_syscalls.c,v 1.79 2001/07/26 02:10:41 assar Exp $ */ /* $NetBSD: vfs_syscalls.c,v 1.71 1996/04/23 10:29:02 mycroft Exp $ */ /* @@ -1249,6 +1249,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); @@ -1299,7 +1301,10 @@ sys_mkfifo(p, v, retval) vattr.va_type = VFIFO; vattr.va_mode = (SCARG(uap, mode) & ALLPERMS) &~ p->p_fd->fd_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); #endif /* FIFO */ } @@ -1393,6 +1398,8 @@ sys_symlink(p, v, retval) vattr.va_mode = ACCESSPERMS &~ p->p_fd->fd_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: FREE(path, M_NAMEI); return (error); diff --git a/sys/kern/vnode_if.c b/sys/kern/vnode_if.c index 1f30d85c507..f5f698b6c13 100644 --- a/sys/kern/vnode_if.c +++ b/sys/kern/vnode_if.c @@ -154,7 +154,7 @@ int vop_mknod_vp_offsets[] = { struct vnodeop_desc vop_mknod_desc = { 0, "vop_mknod", - 0 | VDESC_VP0_WILLRELE | VDESC_VPP_WILLRELE, + 0 | VDESC_VP0_WILLRELE, vop_mknod_vp_offsets, VOPARG_OFFSETOF(struct vop_mknod_args, a_vpp), VDESC_NO_OFFSET, @@ -797,7 +797,7 @@ int vop_symlink_vp_offsets[] = { struct vnodeop_desc vop_symlink_desc = { 0, "vop_symlink", - 0 | VDESC_VP0_WILLRELE | VDESC_VPP_WILLRELE, + 0 | VDESC_VP0_WILLRELE, vop_symlink_vp_offsets, VOPARG_OFFSETOF(struct vop_symlink_args, a_vpp), VDESC_NO_OFFSET, diff --git a/sys/kern/vnode_if.src b/sys/kern/vnode_if.src index 91de785496f..e75c931d1a8 100644 --- a/sys/kern/vnode_if.src +++ b/sys/kern/vnode_if.src @@ -1,4 +1,4 @@ -# $OpenBSD: vnode_if.src,v 1.11 2001/06/23 02:21:05 csapuntz Exp $ +# $OpenBSD: vnode_if.src,v 1.12 2001/07/26 02:10:41 assar Exp $ # $NetBSD: vnode_if.src,v 1.10 1996/05/11 18:26:27 mycroft Exp $ # # Copyright (c) 1992, 1993 @@ -102,12 +102,12 @@ vop_create { # #% mknod dvp L U U -#% mknod vpp - X - +#% mknod vpp - L - # vop_mknod { IN SHOULDBELOCKED WILLRELE struct vnode *dvp; - OUT WILLRELE struct vnode **vpp; + OUT struct vnode **vpp; IN struct componentname *cnp; IN struct vattr *vap; }; @@ -314,16 +314,12 @@ vop_rmdir { # #% symlink dvp L U U -#% symlink vpp - U - -# -# 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. +#% symlink vpp - L - # vop_symlink { IN SHOULDBELOCKED WILLRELE struct vnode *dvp; - OUT WILLRELE struct vnode **vpp; + OUT struct vnode **vpp; IN struct componentname *cnp; IN struct vattr *vap; IN char *target; diff --git a/sys/miscfs/union/union_vnops.c b/sys/miscfs/union/union_vnops.c index 240c1b70c44..cd5016d027a 100644 --- a/sys/miscfs/union/union_vnops.c +++ b/sys/miscfs/union/union_vnops.c @@ -1,4 +1,4 @@ -/* $OpenBSD: union_vnops.c,v 1.13 2001/06/23 02:14:26 csapuntz Exp $ */ +/* $OpenBSD: union_vnops.c,v 1.14 2001/07/26 02:10:41 assar Exp $ */ /* $NetBSD: union_vnops.c,v 1.30.4.1 1996/05/25 22:10:14 jtc Exp $ */ /* @@ -592,19 +592,17 @@ union_mknod(v) if (error) return (error); - if (vp != NULLVP) { - error = union_allocvp( - ap->a_vpp, - mp, - NULLVP, - NULLVP, - ap->a_cnp, - vp, - NULLVP, - 1); - if (error) - vput(vp); - } + error = union_allocvp( + ap->a_vpp, + mp, + NULLVP, + NULLVP, + ap->a_cnp, + vp, + NULLVP, + 1); + if (error) + vput(vp); return (error); } @@ -1398,15 +1396,13 @@ union_symlink(v) if (dvp != NULLVP) { int error; - struct vnode *vp; FIXUP(un, p); VREF(dvp); un->un_flags |= UN_KLOCK; vput(ap->a_dvp); - error = VOP_SYMLINK(dvp, &vp, ap->a_cnp, + error = VOP_SYMLINK(dvp, ap->a_vpp, ap->a_cnp, ap->a_vap, ap->a_target); - *ap->a_vpp = NULLVP; return (error); } diff --git a/sys/nfs/nfs_serv.c b/sys/nfs/nfs_serv.c index 95c6b87bc19..efd9972dd9c 100644 --- a/sys/nfs/nfs_serv.c +++ b/sys/nfs/nfs_serv.c @@ -1,4 +1,4 @@ -/* $OpenBSD: nfs_serv.c,v 1.24 2001/07/06 21:51:13 niklas Exp $ */ +/* $OpenBSD: nfs_serv.c,v 1.25 2001/07/26 02:10:41 assar Exp $ */ /* $NetBSD: nfs_serv.c,v 1.34 1997/05/12 23:37:12 fvdl Exp $ */ /* @@ -1362,16 +1362,6 @@ nfsrv_create(nfsd, slp, procp, mrq) nfsm_reply(0); return (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) { - free(nd.ni_cnd.cn_pnbuf, M_NAMEI); - nfsm_reply(0); - return (0); - } - FREE(nd.ni_cnd.cn_pnbuf, M_NAMEI); if (nd.ni_cnd.cn_flags & ISSYMLINK) { vrele(nd.ni_dvp); @@ -1554,14 +1544,7 @@ 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); FREE(nd.ni_cnd.cn_pnbuf, M_NAMEI); - if (error) - goto out; if (nd.ni_cnd.cn_flags & ISSYMLINK) { vrele(nd.ni_dvp); vput(nd.ni_vp); @@ -2052,23 +2035,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) { - bzero((caddr_t)fhp, 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 + bzero((caddr_t)fhp, 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 { vrele(nd.ni_startdir); + vput(nd.ni_vp); + } FREE(nd.ni_cnd.cn_pnbuf, M_NAMEI); } out: diff --git a/sys/nfs/nfs_vnops.c b/sys/nfs/nfs_vnops.c index a1fccab3408..c1bee0c45fb 100644 --- a/sys/nfs/nfs_vnops.c +++ b/sys/nfs/nfs_vnops.c @@ -1,4 +1,4 @@ -/* $OpenBSD: nfs_vnops.c,v 1.35 2001/07/03 01:55:13 csapuntz Exp $ */ +/* $OpenBSD: nfs_vnops.c,v 1.36 2001/07/26 02:10:41 assar Exp $ */ /* $NetBSD: nfs_vnops.c,v 1.62.4.1 1996/07/08 20:26:52 jtc Exp $ */ /* @@ -1155,8 +1155,6 @@ nfs_mknod(v) int error; error = nfs_mknodrpc(ap->a_dvp, &newvp, ap->a_cnp, ap->a_vap); - if (!error) - vrele(newvp); return (error); } @@ -1633,18 +1631,30 @@ nfs_symlink(v) nfsm_wcc_data(dvp, wccflag); } nfsm_reqdone; - if (newvp) - vrele(newvp); - FREE(cnp->cn_pnbuf, M_NAMEI); - VTONFS(dvp)->n_flag |= NMODIFIED; - if (!wccflag) - VTONFS(dvp)->n_attrstamp = 0; - vrele(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; + } + FREE(cnp->cn_pnbuf, M_NAMEI); + VTONFS(dvp)->n_flag |= NMODIFIED; + if (!wccflag) + VTONFS(dvp)->n_attrstamp = 0; + vrele(dvp); return (error); } diff --git a/sys/ufs/ext2fs/ext2fs_vnops.c b/sys/ufs/ext2fs/ext2fs_vnops.c index ddc13044d71..0414ab59077 100644 --- a/sys/ufs/ext2fs/ext2fs_vnops.c +++ b/sys/ufs/ext2fs/ext2fs_vnops.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ext2fs_vnops.c,v 1.14 2001/06/27 04:58:47 art Exp $ */ +/* $OpenBSD: ext2fs_vnops.c,v 1.15 2001/07/26 02:10:41 assar Exp $ */ /* $NetBSD: ext2fs_vnops.c,v 1.1 1997/06/11 09:34:09 bouyer Exp $ */ /* @@ -134,6 +134,8 @@ ext2fs_mknod(v) register struct vattr *vap = ap->a_vap; register struct vnode **vpp = ap->a_vpp; register struct inode *ip; + struct mount *mp; + ino_t ino; int error; if ((error = @@ -158,6 +160,11 @@ ext2fs_mknod(v) (*vpp)->v_type = VNON; vgone(*vpp); *vpp = 0; + error = VFS_VGET(mp, ino, vpp); + if (error != 0) { + *vpp = NULL; + return (error); + } return (0); } @@ -1192,7 +1199,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, NULL, (struct proc *)0); - vput(vp); + if (error) + vput(vp); return (error); } diff --git a/sys/ufs/ufs/ufs_vnops.c b/sys/ufs/ufs/ufs_vnops.c index 57bf5dc81c3..a2983450f9a 100644 --- a/sys/ufs/ufs/ufs_vnops.c +++ b/sys/ufs/ufs/ufs_vnops.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ufs_vnops.c,v 1.34 2001/06/27 04:58:49 art Exp $ */ +/* $OpenBSD: ufs_vnops.c,v 1.35 2001/07/26 02:10:41 assar Exp $ */ /* $NetBSD: ufs_vnops.c,v 1.18 1996/05/11 18:28:04 mycroft Exp $ */ /* @@ -152,6 +152,8 @@ ufs_mknod(v) } */ *ap = v; struct vattr *vap = ap->a_vap; struct vnode **vpp = ap->a_vpp; + struct mount *mp; + ino_t ino; struct inode *ip; int error; @@ -177,7 +179,11 @@ ufs_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); } @@ -1568,7 +1574,8 @@ ufs_symlink(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); } |