Module Name:    src
Committed By:   dholland
Date:           Mon Apr 11 02:16:07 UTC 2011

Modified Files:
        src/sys/kern: vfs_lookup.c

Log Message:
description:
In the test where we check if searchdir is NULL and fail if we needed
to return ni_dvp, also check if searchdir is on a different volume
from foundobj. I believe the NULL test was meant to encompass this
situation, but it definitely doesn't in some cases related to
emulroots. This appears to be a bug, and I'm pretty sure it's not one
I introduced.

(The search directory and result are on different volumes if we
crossed a mount point.)


To generate a diff of this commit:
cvs rdiff -u -r1.157 -r1.158 src/sys/kern/vfs_lookup.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/kern/vfs_lookup.c
diff -u src/sys/kern/vfs_lookup.c:1.157 src/sys/kern/vfs_lookup.c:1.158
--- src/sys/kern/vfs_lookup.c:1.157	Mon Apr 11 02:15:54 2011
+++ src/sys/kern/vfs_lookup.c	Mon Apr 11 02:16:07 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: vfs_lookup.c,v 1.157 2011/04/11 02:15:54 dholland Exp $	*/
+/*	$NetBSD: vfs_lookup.c,v 1.158 2011/04/11 02:16:07 dholland Exp $	*/
 
 /*
  * Copyright (c) 1982, 1986, 1989, 1993
@@ -37,7 +37,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vfs_lookup.c,v 1.157 2011/04/11 02:15:54 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_lookup.c,v 1.158 2011/04/11 02:16:07 dholland Exp $");
 
 #include "opt_magiclinks.h"
 
@@ -1246,12 +1246,14 @@
 		}
 
 		/*
-		 * If the caller requested the parent node
-		 * (i.e.  it's a CREATE, DELETE, or RENAME),
-		 * and we don't have one (because this is the
-		 * root directory), then we must fail.
+		 * If the caller requested the parent node (i.e. it's
+		 * a CREATE, DELETE, or RENAME), and we don't have one
+		 * (because this is the root directory, or we crossed
+		 * a mount point), then we must fail.
 		 */
-		if (searchdir == NULL && cnp->cn_nameiop != LOOKUP) {
+		if (cnp->cn_nameiop != LOOKUP &&
+		    (searchdir == NULL ||
+		     searchdir->v_mount != foundobj->v_mount)) {
 			switch (cnp->cn_nameiop) {
 			    case CREATE:
 				error = EEXIST;
@@ -1263,6 +1265,9 @@
 			    default:
 				KASSERT(0);
 			}
+			if (searchdir) {
+				vput(searchdir);
+			}
 			vput(foundobj);
 			foundobj = NULL;
 			KASSERT(ndp->ni_dvp == NULL);

Reply via email to