On 2013-11-03 22:57, Sverre Froyen wrote:
On 2013-11-03, at 11:47, Hubert Feyrer <[email protected]> wrote:
On Sat, 2 Nov 2013, David Holland wrote:
I think "not sensible" is not a good enough reason to prohibit
something.
Yeah yeah, but still nowadays we don't allow adding hard links to
directories. So while that's a valid premise, it's not universal.
FWIW, the idea not allowing hard links to directories is that ".." wouldn't be
unique any more. I don't see such a thing with a symlink pointing to “".
On Unix System V, the link command would allow hard-linking directories when
used as root. A quick test shows that NetBSD does not allow this. Was the
feature removed from NetBSD (or BSD) at some point or was it an addition to
Bell Labs Unix after Berkeley received the Bell Labs sources? Perhaps a feature
unique to the v7 file system.
Hard links to directories do exist. Any subdirectory will create a
hardlink to its parent, and the parent will have a hardlink to the child.
The problem with additional random hard links is that there are
assumptions in Unix that become violated, which are difficult to solve.
.. is assumed to point to the parent. However, if you have two
directories with a hardlink to a subdirectory, where should .. point to?
Also, rmdir works by unlinking ., .., and the entry for the directory in ..
With another hard link from a parent, rmdir will actually not remove the
directory anymore, but . and .. will still disappear, as well as one
parent link, leaving a directory which looks very broken, and which
rmdir cannot remove.
I "accidentally" created a hard link to a directory in SunOS 4 as root
once. I had to run an fsck in the end to repair the file system.
So, how should the system behave if you allow random hard links to
directories? You cannot have multiple .. entries.
Should you have .. just point to one entry, and if removed from there,
should you scan the whole file system for another parent? Or should
rmdir remove all parent entries? Or should .. be changed in some more
fundamental way? And figuring out your path becomes "weird" if you can
have several paths to a directory. You can no longer traverse .. upwards
to find the actual path you might be on. And travelling some paths might
end up with access denied, while others will work.
Johnny
--
Johnny Billquist || "I'm on a bus
|| on a psychedelic trip
email: [email protected] || Reading murder books
pdp is alive! || tryin' to stay hip" - B. Idol