Subject: Re: pwd returning duplicate directory in path
To: enami tsugutomo <enami@sm.sony.co.jp>
From: Manuel Bouyer <bouyer@antioche.eu.org>
List: tech-kern
Date: 02/19/2004 22:33:13
--PNTmBPCT7hxwcZjr
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

On Tue, Feb 17, 2004 at 10:57:27AM +0900, enami tsugutomo wrote:
> "Erik E. Fair" <fair@netbsd.org> writes:
> 
> > If that patch works, it should be pulled up to 1.6 and 1.5 too.
> 
> I did following test on -current and committed it (rev. 1.22).  Could
> someone test similar test against on 1.6 and/or 1.5 branch?

Hi,
I tested against 1.6.2/alpha and it behaves as expected (see attached diff).
I'm going to patch my servers using the attached (second) patch.

Thanks for looking at this !

-- 
Manuel Bouyer <bouyer@antioche.eu.org>
     NetBSD: 26 ans d'experience feront toujours la difference
--

--PNTmBPCT7hxwcZjr
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="getcwd-debug.diff"

Index: vfs_getcwd.c
===================================================================
RCS file: /cvsroot/src/sys/kern/vfs_getcwd.c,v
retrieving revision 1.15
diff -u -r1.15 vfs_getcwd.c
--- vfs_getcwd.c	2001/11/12 15:25:37	1.15
+++ vfs_getcwd.c	2004/02/19 21:30:57
@@ -56,6 +56,7 @@
 
 #include <sys/syscallargs.h>
 
+int getcwdbug, getcwdfix;
 static int
 getcwd_scandir __P((struct vnode **, struct vnode **,
     char **, char *, struct proc *));
@@ -310,6 +311,7 @@
 	char *bufp;
 {
 	struct vnode *lvp, *uvp = NULL;
+	char *obp = *bpp;
 	int error;
 	int vpid;
 	
@@ -345,7 +347,9 @@
 	 * Verify that vget succeeded, and check that vnode capability
 	 * didn't change while we were waiting for the lock.
 	 */
-	if (error || (vpid != uvp->v_id)) {
+	if (error || (vpid != uvp->v_id) || getcwdbug) {
+		if (getcwdfix)
+			*bpp = obp;
 		/*
 		 * Oops, we missed.  If the vget failed, or the
 		 * capability changed, try to get our lock back; if

--PNTmBPCT7hxwcZjr
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="getcwd.diff"

Index: vfs_getcwd.c
===================================================================
RCS file: /cvsroot/src/sys/kern/vfs_getcwd.c,v
retrieving revision 1.15
diff -u -r1.15 vfs_getcwd.c
--- vfs_getcwd.c	2001/11/12 15:25:37	1.15
+++ vfs_getcwd.c	2004/02/19 21:31:41
@@ -310,6 +310,7 @@
 	char *bufp;
 {
 	struct vnode *lvp, *uvp = NULL;
+	char *obp = *bpp;
 	int error;
 	int vpid;
 	
@@ -346,6 +347,7 @@
 	 * didn't change while we were waiting for the lock.
 	 */
 	if (error || (vpid != uvp->v_id)) {
+		*bpp = obp;
 		/*
 		 * Oops, we missed.  If the vget failed, or the
 		 * capability changed, try to get our lock back; if

--PNTmBPCT7hxwcZjr--