Hard links to directories: why not?

Jonathan I. Kamens jik at pit-manager.mit.edu
Mon Jul 23 03:50:59 AEST 1990


In article <11070 at alice.UUCP> andrew at alice.UUCP (Andrew Hume) writes:

   on the other hand, links to files already do that to some extent.
   and symbolic links do it completely as you can symlink to directories.
   allowing hard links to dirs makes the problem no worse, really.

Actually, it makes it much worse.  Symbolic links can be quite easily
detected by any program that is concerned about circular filesystem
structures, since a symbolic link has a different file type from the
file to which it points.

However, there is no way for a program to easily detect, without
keeping lots of internal state showing which inodes have already been
visited, when it is reading a hard link.  Hard links are no different
from normal files.

For example, "find" has no trouble at all dealing with symbolic links,
but it can quite easily get into a looping state if it encounters a
hard-linked directory pointing higher up in the directory structure.

Jonathan Kamens			              USnail:
MIT Project Athena				11 Ashford Terrace
jik at Athena.MIT.EDU				Allston, MA  02134
Office: 617-253-8495			      Home: 617-782-0710



More information about the Comp.unix.wizards mailing list