frotz@dri.com (Frotz) (04/02/91)
Greeting Netters... 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. Here are the vitals: 4.3BSD 11/780 Ultrix 3.1 uVax 3100 Ultrix 4.1 uVax 3100 Oldest partition name: Newer partition name: Newest partition name: ---------------------- --------------------- ---------------------- /a (real) /a (ln -s) /graph (real) /a (ln -s) /graph (ln -s) /work2 (real) Requirement: provide a path for /a/graph/bin for hardwired code...;-( In the current situation we have: Real directories Symbolic links ---------------- -------------- /> @/a -> /work2 /work2> @graph -> /work2 /work2/bin> What we used to get: cd /a/graph/bin; pwd # returned /work2/bin What we get now: cd /a/graph/bin; pwd # returns /a/bin Why /a? Why not /work2 as before? What I have done? Any ideas? -- John "Frotz" Fa'atuai frotz@dri.com (email@domain) Digital Research, Inc. uunet!drivax!frotz (bang!email) c/o MIS Dept. (408) 647-6570 (vmail) 80 Garden Court, CompRm (408) 649-3896 (phone) Monterey, CA 93940 (408) 646-6248 (fax)
arons@ash.eecs.ucdavis.edu (Tom Arons) (04/03/91)
In article <C74Z93R@dri.com> 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