getcwd() and friends.

Eduardo Krell ekrell at hector.UUCP
Fri Apr 7 03:19:10 AEST 1989


In article <8136 at chinet.chi.il.us> les at chinet.chi.il.us (Leslie Mikesell) writes:

>Better yet would be a per-process *name* of the current working
>directory stored somewhere, built according the the way you
>happened to get there.

This is what ksh does (it stores it in $PWD). pwd is a ksh builtin
which just prints $PWD. It's harder to do in the kernel because pathnames
can be very long and you don't want to increase the size of the process
structure by that much.

>as a side effect, it would make ".." mean something unsuprising in the
>presence of linked directories.  Is there some reason this isn't done?

You would have to convince the powers to be (BSD and System V folks)
that this is the way ".." should behave. We went through this ".." war
a while ago and there were people on both sides.

We actually changed the meaning of ".." to work the way you want it to.
We also changed getwd() and getcwd() so that instead of opening and
closing ".." until it reaches the root, it looks up in the namei()
cache which holds the component names for all current and root directories
of all processes (thus, you can always look in the cache for the name
of the current working directory by just following a linked list back
to the root). Needless to say, this is much faster than opening and
closing directories.
    
Eduardo Krell                   AT&T Bell Laboratories, Murray Hill, NJ

UUCP: {att,decvax,ucbvax}!ulysses!ekrell  Internet: ekrell at ulysses.att.com



More information about the Comp.unix.wizards mailing list