hard links to directories
Posted Sep 14, 2007 3:13 UTC (Fri) by
Duncan (guest, #6647)
In reply to:
hard links to directories by gw666
Parent article:
The many faces of fsck
> So if a directory has a link count > 1, this must be an error.
What are all the (normally hidden) . (me) and .. (my parent) links if not
hard links?
Your assumption that additional links are not allowed doesn't necessarily
hold for all filesystem types, either. Looking it up, the GNU coreutils
info entry for ln has the following:
> On all existing implementations, you cannot
> make a hard link to a directory, and hard links
> cannot cross file system boundaries. (These
> restrictions are not mandated by POSIX, however.)
Thus multiple named directory links are apparently not only possible, but
not restricted by POSIX either, so an implementing filesystem could indeed
allow such things, it's simply that few (none known to the info entry
author quoted above at the time the statement was written) have done so.
Hmm... That leads to two questions.
1) What does creating a subdir do if it doesn't create a hardlink entry in
the form of .. back to the parent? Does the above only refer to directly
created named (not . and ..) links?
2) The no crossing filesystem boundaries is interesting. The kernel must
fix that up by creating a logical .. link in the root dir of a mounted
filesystem, since it self-evidently couldn't be a hard-link, given that
the filesystem could be arbitrarily mounted anywhere. Likewise, the
kernel must remove the .. entries from chroots.
So maybe those . and .. entries aren't hard links after all, which begs
the question (avoids the question, begs that it be asked and answered,
whatever [1], I'm a literal constructionist in this case) I asked at the
beginning, what /are/ they, then? However, that's out of my league.
Perhaps Val can trivially answer.
[1] http://www.onelook.com/?w=beg+the+question
Duncan
(
Log in to post comments)