Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watmath!clyde!cbosgd!ucbvax!ulysses!dgk From: dgk@ulysses.UUCP Newsgroups: comp.unix.wizards Subject: symbolic links are a botch Message-ID: <2629@ulysses.homer.nj.att.com> Date: Thu, 4-Jun-87 14:31:07 EDT Article-I.D.: ulysses.2629 Posted: Thu Jun 4 14:31:07 1987 Date-Received: Sat, 6-Jun-87 09:39:16 EDT Organization: AT&T Bell Laboratories, Murray Hill Lines: 88 Keywords: file system, file name resolution If you type cd /usr/include/sys echo cwd=$cwd /bin/pwd cd .. echo cwd=$cwd /bin/pwd from csh with BSD 4.3 running on our vax you get: cwd=usr/include/sys /usr/sys/h cwd=/sys /usr/sys If you do the equivalent cd /usr/include/sys /bin/pwd echo cwd=$PWD cd .. echo cwd=$PWD /bin/pwd from the Korn shell with BSD 4.3 running on our vax you get: cwd=/usr/include/sys /usr/include/sys cwd=/usr/include /usr/include If you do the nearly equivalent cd /usr/include/sys pwd /bin/pwd cd .. pwd /bin/pwd from the 4.3 Bourne shell you get: usr/include/sys usr/include/sys /usr/sys/h /sys I think that the reason for this discrepancy is that the implementation of symbolic links on BSD Unix is a botch. In order to use a system with symbolic links without being surprised, you have to be aware of all symbolic links to directories. The reason is that the kernel does not keep track of the device-inodes as you descend the file tree, so it does not know how to walk back up. For example, if I add a directory of include files named /usr/include/local and one of my include files includes ""../stat.h", it will not work on BSD but will work on Sys V. Can you imagine what Unix would have been like if .. were not handled specially at mount points? You would have to know where each of the mount points were. Two systems could be compatible only if they had identical mount points. I recently added symbolic links to my version of System V Release 3 kernel. I made sure that .. was always handled like an operator that moves you up one level. The changes were not complex and I have not run into any problems at all. The user again sees the file system as a tree structure which preserves the original simplicity of the Unix model. By the way, I did modify find so that you can specify a virtual walk or a physical walk. I virtual walk follows symbolic links. The virtual walk keeps track of device-inodes so that I never descend through the same physical directory more than once. Therefore, a symbolic line to / poses no problem. ( Now some guru might say that . and .. are just names that have i-nodes associated with them just like any other name and therefore, the i-node should be followed. If this were true, then as root I should be able to edit my directory and change the inode of . to change its meaning. What do you think really happens?) I am conducting a poll on this issue and I am interested in hearing your views. I will post the results to this newsgroup on the net. What would be the best semantics for ..? Do you think that BSD has done it right or have I done it right? What code would break if .. were always treated as an operator? Disclaimer: I am not affiliated with the System V product, I am involved in research only and these are my own. They do not imply any direction for future releases of System V. David Korn {ihnp4,decvax}ulysses!dgk