Need a getwd call. (Not getcwd).
Steven W Orr
steveo at world.std.com
Tue Jun 25 06:48:08 AEST 1991
Does anyone have source code for a routine that will return my
current working directory without calling getcwd? The problem is that
getcwd calls fork, and my calling process is huge. The whole thing
has to swap out just to get from the fork to the exec. (Or for that
matter, is there a callable function provided by any of the libraries
in my SCO ODT 1.1 system?)
Just to start stimulating the discussion, I have heard that there are
two ways to do this and I don't know which one is better/more
appropriate.
1. Do {
read . and find out what our current inode is.
chdir to .. and search . to find last inode. That yields
the rightmost filename of the starting point.
} until current_inode == 0
Keep precatenating (is that a word?) until we get to the root
directory. Then chdir back to where we started from.
2. Read the user area and utilize
struct inode *u_cdir; /* current directory */
struct inode *u_rdir; /* root directory */
caddr_t u_dirp; /* pathname pointer */
struct direct u_dent; /* current directory entry */
struct inode *u_pdir; /* inode of parent directory */
/* of dirp */
from <sys/user.h>
--
----------Time flies like the wind. Fruit flies like bananas.------------------
Steven W. Orr steveo at world.std.com uunet!world!steveo
----------Everybody repeat after me: "We are all individuals."-----------------
More information about the Comp.unix.sysv386
mailing list