Path: utzoo!attcan!uunet!mcsun!hp4nl!phigate!ehviea!leo From: leo@ehviea.ine.philips.nl (Leo de Wit) Newsgroups: comp.unix.wizards Subject: Re: Hard links to directories: why not? Keywords: ln, directories, security... Message-ID: <835@ehviea.ine.philips.nl> Date: 19 Jul 90 12:45:24 GMT References: <5222@milton.u.washington.edu> <6940@eos.UUCP> Reply-To: leo@ehviea.UUCP (Leo de Wit) Organization: Philips I&E Eindhoven Lines: 31 In article <6940@eos.UUCP> jbm@eos.UUCP (Jeffrey Mulligan) writes: |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? | |What should be the output of the last command of this sequence? | |mkdir dir1 |mkdir dir2 |mkdir dir1/a_directory a_directory contains entries '.' and '..' that point to itself and its parent, dir1, respectively. |ln dir1/a_directroy dir2/directory_link |cd dir2/directory_link |cd .. |pwd If you shell is csh, it could perhaps tell you "dir2". That's because csh has 'pwd' builtin and keeps track of the current directory itself in $cwd; it is also confused by symbolic links *). But a proper pwd (try /bin/pwd) should always give you "dir1" (as absolute path, of course), since that is where '..' points at. Leo. *) This behaviour of C shell is corrected in more recent versions.