Module Name: src Committed By: snj Date: Wed Apr 8 23:08:07 UTC 2009
Modified Files: src/sys/fs/tmpfs [netbsd-5]: tmpfs_vnops.c Log Message: Pull up following revision(s) (requested by tron in ticket #680): sys/fs/tmpfs/tmpfs_vnops.c: revision 1.55 Fix yet another recent crashy bug in tmpfs rename: since the source dirent is no longer cached in lookup and we do the lookup ourselves in rename, we are most definitely not allowed to assert that it matches the source vnode passed as an argument. In case the source node does not exist or has been replaced, punt with ENOENT. Also, nuke some misleading prehistoric comments which haven't been valid in over a year. Fixes PR kern/41128 by Nicolas Joly To generate a diff of this commit: cvs rdiff -u -r1.51.6.2 -r1.51.6.3 src/sys/fs/tmpfs/tmpfs_vnops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/fs/tmpfs/tmpfs_vnops.c diff -u src/sys/fs/tmpfs/tmpfs_vnops.c:1.51.6.2 src/sys/fs/tmpfs/tmpfs_vnops.c:1.51.6.3 --- src/sys/fs/tmpfs/tmpfs_vnops.c:1.51.6.2 Tue Mar 24 20:22:44 2009 +++ src/sys/fs/tmpfs/tmpfs_vnops.c Wed Apr 8 23:08:07 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: tmpfs_vnops.c,v 1.51.6.2 2009/03/24 20:22:44 snj Exp $ */ +/* $NetBSD: tmpfs_vnops.c,v 1.51.6.3 2009/04/08 23:08:07 snj Exp $ */ /* * Copyright (c) 2005, 2006, 2007 The NetBSD Foundation, Inc. @@ -35,7 +35,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: tmpfs_vnops.c,v 1.51.6.2 2009/03/24 20:22:44 snj Exp $"); +__KERNEL_RCSID(0, "$NetBSD: tmpfs_vnops.c,v 1.51.6.3 2009/04/08 23:08:07 snj Exp $"); #include <sys/param.h> #include <sys/dirent.h> @@ -833,12 +833,14 @@ goto out_unlocked; } + /* + * If the node we were renaming has scarpered, just give up. + */ de = tmpfs_dir_lookup(fdnode, fcnp); - if (de == NULL) { + if (de == NULL || de->td_node != fnode) { error = ENOENT; goto out; } - KASSERT(de->td_node == fnode); /* If source and target are the same file, there is nothing to do. */ if (fvp == tvp) { @@ -846,14 +848,6 @@ goto out; } - /* Avoid manipulating '.' and '..' entries. */ - if (de == NULL) { - KASSERT(fvp->v_type == VDIR); - error = EINVAL; - goto out; - } - KASSERT(de->td_node == fnode); - /* If replacing an existing entry, ensure we can do the operation. */ if (tvp != NULL) { KASSERT(tnode != NULL);