Hard links to directories: why not?

leland.f.derbenwick lfd at cbnewsm.att.com
Thu Jul 19 08:05:53 AEST 1990


In article <5222 at milton.u.washington.edu>, wiml at milton.u.washington.edu (William Lewis) writes:
> 
>    In the man entry for ln(1) (and for link(2)),  it says that
> hard links may not be made to directories, unless the linker is
> the super-user (in order to make '.' and '..', I suppose). My 
> question is: why not? [ ... ]

According to Ritchie and Thompson [1]:

  The directory structure is constrained to have the form of a
  rooted tree.  Except for the special entries "." and "..",
  each directory must appear as an entry in exactly one other
  directory, which is its parent.  The reason for this is to
  simplify the writing of programs that visit subtrees of the
  directory structure, and more important, to avoid the
  separation of portions of the hierarchy.  If arbitrary links
  to directories were permitted, it would be quite difficult
  to detect when the last connection from the root to a
  directory was severed.

And according to Thompson [2]:

  The file system structure allows an arbitrary, directed graph
  of directories with regular files linked in at arbitrary places
  in this graph.  In fact, very early UNIX systems used such a
  structure.  Administration of such a structure became so
  chaotic that later systems were restricted to a directory tree.

Both references are from the _Bell System Technical Journal_,
Vol. 57, No. 6, Part 2 (July-August 1978), special issue:
"UNIX Time-Sharing System."

[1] D. M. Ritchie and K. Thompson, "The UNIX Time-Sharing System."
    Page 1909.

[2] K. Thompson, "UNIX Implementation."  Page 1942.

 -- Speaking strictly for myself,
 --   Lee Derbenwick, AT&T Bell Laboratories, Warren, NJ
 --   lfd at cbnewsm.ATT.COM  or  <wherever>!att!cbnewsm!lfd



More information about the Comp.unix.wizards mailing list