Hard links to directories: why not?

Mark Warren mwarren at mips2.cr.bull.com
Thu Jul 19 21:56:22 AEST 1990


In article <6940 at eos.UUCP> jbm at eos.UUCP (Jeffrey Mulligan) writes:
>
>What should be the output of the last command of this sequence?
>
>mkdir dir1
>mkdir dir2
>mkdir dir1/a_directory
>ln dir1/a_directroy dir2/directory_link
>cd dir2/directory_link
>cd ..
>pwd
>

This sounds more mysterious than it is.  When a_directory is created,
its parent is dir1, and it stays there.  When directory_link is
created, all that happens is that the directory dir2 gets a new entry
that names the same inode as a_directory.  The a_directory inode is NOT
changed (except that its reference count increases), so its parent is
still dir1.  So,

	pwd == dir1

in any unix I know of.
-- 

 == Mark Warren                      Bull HN Information Systems Inc. ==
 == (508) 294-3171 (FAX 671-3020)    300 Concord Road     MS820A      ==
 == mwarren at granite.cr.bull.com      Billerica, MA 01821              ==



More information about the Comp.unix.wizards mailing list