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/nfs | |
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/nfs')
-rw-r--r-- | sys/nfs/nfs_serv.c | 45 | ||||
-rw-r--r-- | sys/nfs/nfs_vnops.c | 30 |
2 files changed, 31 insertions, 44 deletions
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); } |