NFS and UFS Mounting on a non-empty directory

Brandon S. Allbery bsa at telotech.UUCP
Sat Jul 29 03:33:35 AEST 1989


In article <1989Jul23.194057.4247 at ctr.columbia.edu>, seth at ctr (Seth Robertson) writes:
+---------------
| In article <12921 at bloom-beacon.MIT.EDU> jik at 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.			      *



More information about the Comp.unix.wizards mailing list