From 2a42bccb40826ed973d45e55520bbfa7902651d6 Mon Sep 17 00:00:00 2001 From: "Tim J. Robbins" Date: Thu, 27 Feb 2003 08:26:17 +0000 Subject: [PATCH] Fix vnode corruption bug when trying to rename files across filesystems. Similar to the bug fixed in smbfs_vnops.c rev 1.33. --- sys/fs/nwfs/nwfs_vnops.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/sys/fs/nwfs/nwfs_vnops.c b/sys/fs/nwfs/nwfs_vnops.c index aae9ac0a97be..59dc234d7975 100644 --- a/sys/fs/nwfs/nwfs_vnops.c +++ b/sys/fs/nwfs/nwfs_vnops.c @@ -526,20 +526,22 @@ nwfs_rename(ap) error = EBUSY; goto out; } + if (fvp->v_type == VDIR) { + oldtype |= NW_TYPE_SUBDIR; + } else if (fvp->v_type == VREG) { + oldtype |= NW_TYPE_FILE; + } else { + error = EINVAL; + goto out; + } if (tvp && tvp != fvp) { error = ncp_DeleteNSEntry(nmp, VTONW(tdvp)->n_fid.f_id, tcnp->cn_namelen, tcnp->cn_nameptr, tcnp->cn_thread, tcnp->cn_cred); if (error == 0x899c) error = EACCES; if (error) - goto out; + goto out_cacherem; } - if (fvp->v_type == VDIR) { - oldtype |= NW_TYPE_SUBDIR; - } else if (fvp->v_type == VREG) { - oldtype |= NW_TYPE_FILE; - } else - return EINVAL; error = ncp_nsrename(NWFSTOCONN(nmp), nmp->n_volume, nmp->name_space, oldtype, &nmp->m.nls, VTONW(fdvp)->n_fid.f_id, fcnp->cn_nameptr, fcnp->cn_namelen, @@ -553,6 +555,10 @@ nwfs_rename(ap) cache_purge(tdvp); cache_purge(fdvp); } +out_cacherem: + nwfs_attr_cacheremove(fdvp); + nwfs_attr_cacheremove(tdvp); + nwfs_attr_cacheremove(fvp); out: if (tdvp == tvp) vrele(tdvp); @@ -562,9 +568,6 @@ nwfs_rename(ap) vput(tvp); vrele(fdvp); vrele(fvp); - nwfs_attr_cacheremove(fdvp); - nwfs_attr_cacheremove(tdvp); - nwfs_attr_cacheremove(fvp); if (tvp) nwfs_attr_cacheremove(tvp); /*