[comp.unix.wizards] Recursive directory descent

rcodi@yabbie.rmit.oz (Ian Donaldson) (01/05/88)

in article <10895@brl-adm.ARPA>, ted@braggvax.arpa says:
> 		cd /tmp
> 		tar cf /dev/rmt8 /usr
> 
> tar: cannot change back?: /tmp//usr: No such file or directory

tar (and many other utilities that recursively descend directory
hierarchies) depend on the value of ".." to be correct when
ascending.

If your fs is scrambled, or has ".." inconsitencies, then
the command will mess up royally (and usually print some undecipherable
garbage as a diagnostic to boot!)

I tend to think that these commands shouldn't depend on ".." for
safety reasons when ascending; rather they should re-use the path
minus the last directory name that they used to descend.  Granted,
it might be a bit slower, but a lot safer.

Who knows... what if on a slow system somebody moves a directory
that find is descending; and then find uses a 'cd ..' to a different
point in the hierarchy.  The original hierarchy may not be entierly
traversed.  When using find from cron to clean up files, this
might possibly be a disaster!

(there was even a race condition in a 4.2bsd mv(1) that sometimes allowed 
creation of a bogus ".." -- du went bananas!)

Another side-effect of chdir'ing programs is the problem of locating
the core dump :-)

Ian D