.. in the root of a filesystem

guy at rlgvax.UUCP guy at rlgvax.UUCP
Tue Sep 11 16:13:56 AEST 1984


> In namei, when checking to see if it should scan
> the mount table for a link backwards across
> a file system, it does the following...
> Note that it only looks at the second character in the file name.
> This leads to weird results if you just happen to have a directory
> in the root of a mounted file system with a . in the second position,
> and you also just happen to have a directory of the same name in
> the directory you are mounted on.
> 
> Does anybody depend on it only looking at the second character?
> Any idea why they did it this way?

Note that the inumber of the directory entry whose second character is
'.' must be ROOTINO, which is the inumber of a root directory (2 on V7 and
all post-V7 systems) for "namei" to decide that it should use the entry
in the mounted-on directory.  In a "normal" file system, this shouldn't
happen, as the only directory entries that refer to the root inode should
be the "." entry in the root directory, the ".." entry in that directory,
and the ".." entries in directories immediately under the root; the test
of dp->d_ino eliminates the third category, and a test of the second
character of the directory entry suffices to eliminate the first.
I presume it was done because it works unless something is
wierd and is a cheap quick test, as opposed to a full-blown "strcmp"
against "..".

	Guy Harris
	{seismo,ihnp4,allegra}!rlgvax!guy



More information about the Comp.unix.wizards mailing list