From owner-freebsd-current Wed Mar 8 0: 7: 3 2000 Delivered-To: freebsd-current@freebsd.org Received: from gidora.zeta.org.au (gidora.zeta.org.au [203.26.10.25]) by hub.freebsd.org (Postfix) with SMTP id EF37037BA70 for ; Wed, 8 Mar 2000 00:06:58 -0800 (PST) (envelope-from bde@zeta.org.au) Received: (qmail 19327 invoked from network); 8 Mar 2000 08:06:55 -0000 Received: from bde.zeta.org.au (203.2.228.102) by gidora.zeta.org.au with SMTP; 8 Mar 2000 08:06:55 -0000 Date: Wed, 8 Mar 2000 19:06:45 +1100 (EST) From: Bruce Evans X-Sender: bde@alphplex.bde.org To: Dan Potter Cc: freebsd-current@FreeBSD.ORG Subject: Re: Problems with 'pwd' and unionfs In-Reply-To: <20000304215058.A7124@industrial-strength.net> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG On Sat, 4 Mar 2000, Dan Potter wrote: > ... > In libc there is a non-kernel version of getcwd that runs lstat() on each > directory and then searching its parent, trying to divine which sub-tree > is '.' at the time. I dumped a copy of that into a copy of pwd.c to trace > through it and see what happens. Basically for optimization purposes it > looks like it just uses the inode value from readdir() until it thinks > that it's changed volumes, and then it runs lstat() on each entry to make This is supposed to work. (st_dev, st_ino) pairs returned by lstat() and stat() are supposed to be unique. > sure which one it is. Well, this breaks unionfs mounts because the device > inode is the same, but the inode numbers are different since it's a mount > point. What a subtle problem! st_dev for a mount on non-device is normally copied from the fsid for the mount. See kern/vfs_vnops.c:vn_stat(). This works for nfs mounts. Unfortunately, for union mounts, VOP_GETTATTR() normally finds a non-VNOVAL va_fsid by going to the leaf filesystem, and st_dev is set to this. I think the fsid should be used in all cases (change f_fsid.val[0] for mounts on real devices if necessary). Bruce To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message