Path: utzoo!attcan!uunet!cs.utexas.edu!rutgers!att!cbnewsm!lfd From: lfd@cbnewsm.att.com (leland.f.derbenwick) Newsgroups: comp.unix.wizards Subject: Re: Hard links to directories: why not? Summary: It's in the book... Keywords: ln, directories, security... Message-ID: <1990Jul18.220553.19736@cbnewsm.att.com> Date: 18 Jul 90 22:05:53 GMT References: <5222@milton.u.washington.edu> Organization: AT&T Bell Laboratories Lines: 40 In article <5222@milton.u.washington.edu>, wiml@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@cbnewsm.ATT.COM or !att!cbnewsm!lfd