Hard links to directories: why not?
Leo de Wit
leo at ehviea.ine.philips.nl
Thu Jul 19 22:45:24 AEST 1990
In article <6940 at eos.UUCP> jbm at eos.UUCP (Jeffrey Mulligan) writes:
|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?
|
|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.
More information about the Comp.unix.wizards
mailing list