[net.unix-wizards] .. in the root of a filesystem

tim@callan.UUCP (Tim Smith) (09/08/84)

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:

	if( u.u_dent.d_ino == ROOTINO )
	if( dp->i_number == ROOTINO )
	if( u.u_dent.d_name[1] == '.' )
		/*
		 * scan the mount table.  if we find that
		 * this directory is mounted on something, we
		 * continue the search in the directory we
		 * are mounted on
		 */

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?
-- 
"Take your time, think a lot, why, think of everything you've got,
 for you will still be here tomorrow, but your dreams may not."

					Tim Smith
			ihnp4!wlbr!callan!tim or ihnp4!cithep!tim

guy@rlgvax.UUCP (09/11/84)

> 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