Messages in this thread | | | Date | Tue, 7 Mar 2000 03:05:52 +0100 | From | Guest section DW <> | Subject | Re: bug: mount on an open directory succeeds |
| |
Amit S. Kale" <akale@veritas.com> shows that overmounting . gives strange effects.
Indeed, # mkdir /tmp/tst # cd /tmp/tst # mount /dev/foo /tmp/tst # ls -l ls: lost+found: No such file or directory total 0 # ls lost+found # in other words, ls without explicit argument uses . but . now refers to the mounted filesystem instead of the working directory of this shell. But "ls bar" refers to "bar" in the current working directory (not .).
V Ganesh <ganesh@veritas.com> writes
> so it breaks the assumption that . == pwd.
and it does.
Let me try to contribute with ancient Unix semantics. There is nothing special with . and .. - they are just directory entries like all others, and the operation "chdir ." is in no way different from "chdir x". The directory entry with name . is found, and our new working directory is wherever that points. By some coincidence mkdir makes sure . and .. point the expected places, but that can be changed (say, by clri, or other surgery).
Next mount. The operation "mount device path" lets the inode of path be an alias for the inode of the root directory on device. Let me show what Unix6 did.
# chdir /mnt2 # mkdir a b a/c # /etc/mount /dev/rk3 /mnt2 mount: Mount device busy # chdir a # /etc/mount /dev/rk3 /mnt2 # ls c # ls .. as bc beg ...
Thus, the present Linux behaviour conforms to ancient Unix semantics, except that Unix6 did not allow overmounting of the cwd of a process.
Werner Almesberger <almesber@lrc.di.epfl.ch> writes:
# According to POSIX ANSI/IEEE Std 1003.1 (2nd ed., 1996-07-12): # # "If the pathname does not begin with a slash, the predecessor # of the first filename of the pathname is taken to be the # current working directory of the process" # # and # # "The special filename, dot, refers to the directory specified # by its predecessor."
This is a slightly different prescription. It requires that under all circumstances . refers to the current working directory. The present Linux behaviour violates this.
Alexander replies that this is outside of POSIX scope because mount is non-POSIX, and this is a mount-related thing. However, I probably disagree. The mount process creates our tree, and this tree must satisfy the POSIX requirements, regardless of how we got it. Thus, foo and ./foo must not be different files.
So, I think we have to change. But it would be strange to have . point at the old directory, and ./a/.. at the mounted filesystem. So, . must point at the mounted filesystem as well, precisely as we already do today. But then the best way to get rid of the fact that foo and ./foo may differ is to do like Unix6 did and return EBUSY if the mount point is the cwd of some process.
Andries
- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/
| |