On Sun 10 Aug 1997, Todd Larason wrote: > On Sat, Aug 09, 1997 at 05:11:53AM +0000, Geoff Wing wrote: > > John M. Harres <harres@xxxxxxxx> typed: > > > Does anyone know under what circumstances zsh will change directory on > > > startup? I was in root under sh, ran zsh, and zappo, switched directories, > > > and not to root's home directory. Both home directories are automounted. > I saw this on a similar setup - Solaris 2.4, home directories automounted, > zsh 3.0 betas I think. I no longer have access to this system, so I can't > double check the details, but they're not terribly important. > > The problem was an assumption made in zgetcwd(), which didn't hold with > the automounted home dirs. I don't seem to have the patch I made, and I'm > going on foggy memory here I'm afraid. > > Anything that caused a zgetcwd() would end up *changing* the current > directory. > > Looking at zgetcwd, I'm thinking that the false assumption was that only > one mountpoint could have the same device number ("if (sbuf.st_dev == dev) > goto match;" around lines 178-179 in 3.0.4:compat.c). With sun's > automounter, with multiple directories from the same device mounted into > the same directory, this wasn't true. I assume my fix was to check the > inode too. Trying to look into this further, I'm getting further confused. zgetcwd() appears to do some checks, then opens '..' scanning for the directory we are (were since there's a chdir()) in. If that is not found, it then scans '.', but since we did a chdir("..") after opendir(".."), the second opendir should be opening the same directory as the first. The second directory scan does not have the inode check, as you mentioned, but if it's there, the two loops look like they should either both succeed or fail, thus the second adds nothing. What is the second loop intended to do? I also don't understand when the first loop would fail. It simply looks for the dev & ino that match "." in the dirent's for "..". What conditions will is that trying to catch? Sorry for my lack of understanding. It's my first dive into the zsh source. John
Attachment:
pgpnjeIrke173.pgp
Description: PGP signature