[net.unix] Symbolic links question - getwd

jdb@mordor.UUCP (John Bruner) (07/02/84)

There is a case in which "pwd" will use a soft link to a directory
in preference to a hard link.  This will occur if the symbolic link
resides in the same directory as the hard link, and the entry for
the symbolic link appears first in the parent directory.
For example, if "/" contains the entries

	/u -> /usr
	/usr

in that order, the command "cd /usr;pwd" will return "/u".

The actual work is done by the library routine getwd() (source
"/src/lib/libc/gen/getwd.c").  It is unable to distinguish the
soft link from the hard link because it uses stat().  Changing
all stat() calls to lstat() will force it to always return
the "real" pathname.
-- 
  John Bruner (S-1 Project, Lawrence Livermore National Laboratory)
  MILNET: jdb@mordor.ARPA [jdb@s1-c]	(415) 422-0758
  UUCP: ...!ucbvax!dual!mordor!jdb 	...!decvax!decwrl!mordor!jdb