Path: utzoo!utgpu!watmath!att!tut.cis.ohio-state.edu!cwjcc!hal!ncoast!telotech!bsa From: bsa@telotech.UUCP (Brandon S. Allbery) Newsgroups: comp.unix.wizards Subject: Re: NFS and UFS Mounting on a non-empty directory Keywords: Frustration, Yellow Pages Message-ID: <1989Jul28.173335.1815@telotech.uucp> Date: 28 Jul 89 17:33:35 GMT References: <2339@orion.cf.uci.edu> <12921@bloom-beacon.MIT.EDU> <1989Jul23.194057.4247@ctr.columbia.edu> Sender: bsa@telotech.uucp (Brandon S. Allbery) Reply-To: bsa@telotech.UUCP (Brandon S. Allbery) Distribution: na Organization: _ telotech, inc. - Beachwood, OH Lines: 43 In-reply-to: seth@ctr.columbia.edu (Seth Robertson) In article <1989Jul23.194057.4247@ctr.columbia.edu>, seth@ctr (Seth Robertson) writes: +--------------- | In article <12921@bloom-beacon.MIT.EDU> jik@athena.mit.edu (Jonathan I. Kamens) writes: | >Yes, the concept of mounting over a non-empty directory is | >well-defined | >> Its | >> old contents are inaccessible while the file system is | >> mounted. | | The concept may be well defined, but the implementation bytes the big one. | | In SunOS 4.0.3 | seth elara> cd /mnt | seth elara> ls | testfile | seth elara> cat testfile | This is a test. | seth elara> mount leda:/image /mnt | seth elara> ls | lost+found not found +--------------- This is correct, and happens even for local mounts. The mount(2) system call changes the mapping used to go from a pathname to an inode. In the case of the current directory, the inode is already known, so mount(2) won't affect it; if your current directory is the directory you mounted on, you'll continue to see the same contents after the mount until you explicitly "cd" back to it, at which time the pathname-to-inode mapping will discover that "/mnt" is a different inode. "Fixing" this (I don't consider it a bug, so I don't advocate fixing it) would require replacing u.u_cdir (inode of current directory) with a pathname, and requiring namei() to always start from root and parse the pathname from the ublock first in the case of a relative filename. This would be slow and ugly, IMHO. ++Brandon -- Brandon S. Allbery @ telotech, inc. (I do not speak for telotech. Ever.) *This article may only be redistributed if all articles listed in the header's* * References: field, and all articles listing this one in their References: * * fields, are also redistributed. *