Subject: Re: pwd returning duplicate directory in path
To: Erik E. Fair <fair@netbsd.org>
From: enami tsugutomo <enami@sm.sony.co.jp>
List: tech-kern
Date: 02/17/2004 10:57:27
"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?
enami.
enami@net4801% /bin/pwd
/home/enami
enami@net4801% su
Password:
net4801# gdb -q /netbsd
(no debugging symbols found)...(gdb)
(gdb) set wr
(gdb) target kcore /dev/mem
#0 0xc02ecf00 in lwp0 ()
(gdb) set getcwdbug = 1
(gdb)
Suspended
net4801# /bin/pwd
/homehome/enamienami
net4801# fg
gdb -q /netbsd
set getcwdfix = 1
(gdb)
Suspended
net4801# /bin/pwd
/home/enami
net4801# fg
gdb -q /netbsd
quit
net4801#
net4801# exit
Index: vfs_getcwd.c
===================================================================
RCS file: /cvsroot/src/sys/kern/vfs_getcwd.c,v
retrieving revision 1.21
diff -u -r1.21 vfs_getcwd.c
--- vfs_getcwd.c 30 Jul 2003 12:10:57 -0000 1.21
+++ vfs_getcwd.c 17 Feb 2004 00:57:17 -0000
@@ -57,6 +57,7 @@
#include <sys/sa.h>
#include <sys/syscallargs.h>
+int getcwdbug, getcwdfix;
static int
getcwd_scandir __P((struct vnode **, struct vnode **,
char **, char *, struct proc *));
@@ -308,6 +309,7 @@
char *bufp;
{
struct vnode *lvp, *uvp = NULL;
+ char *obp = *bpp;
int error;
lvp = *lvpp;
@@ -341,7 +343,10 @@
* Verify that vget succeeded, and check that vnode capability
* didn't change while we were waiting for the lock.
*/
- if (error) {
+ if (error || getcwdbug) {
+ if (getcwdfix)
+ *bpp = obp;
+
/*
* Oops, we missed. If the vget failed, or the
* capability changed, try to get our lock back; if