Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!elroy.jpl.nasa.gov!usc!zaphod.mps.ohio-state.edu!pacific.mps.ohio-state.edu!linac!att!ucbvax!ucdavis!arons From: arons@ash.eecs.ucdavis.edu (Tom Arons) Newsgroups: comp.unix.ultrix Subject: Re: Ultrix symbolic link strangeness... Message-ID: Date: 2 Apr 91 19:43:06 GMT References: Sender: usenet@ucdavis.ucdavis.edu Organization: University of California at Davis Lines: 31 In-reply-to: frotz@dri.com's message of 1 Apr 91 23:59:17 GMT In article frotz@dri.com (Frotz) writes: The following is a description of an annoyance bug. If you have any comments or workarounds, please speak up. Problem setup: % ln -s /symbolic_dir /dir1/real_dir % cd /symbolic_dir % pwd Problem: The output from pwd is "/symbolic_dir" not "/dir1/real_dir" as expected. This is caused by a call to stat() rather than lstat() in ultrix versions of getwd() which is what pwd uses. getwd() constructs a path name by working its way up to "/" stat'ing the current directory, then changing to the parent directory and stat'ing each directory entry looking for a matching inode number. When a match is found, that directory entry is prepended to the path name. Because stat is used instead of lstat there is no way to tell the difference between a sym link and the file it points to. You get the path name component of which ever directory entry readdir returns first. Because the "real" directory entry usually comes before a symlink in a directory you ususally don't see this behavior. You can force any order you like, and thus get the "real" name, by a combination of mkdir's, rmdir's and mv's in the directory that contains the objectionable sym link. Tom Arons Internet: arons@eecs.ucdavis.edu EE/CS Department Bitnet: tgarons@ucdavis University of California UUCP: {lll-crg, ucbvax}!ucdavis!iris!arons Davis, CA 95616 Phone: (916) 752-1750