Newsgroups: comp.unix.sysv386 Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!think.com!snorkelwacker.mit.edu!world!steveo From: steveo@world.std.com (Steven W Orr) Subject: Need a getwd call. (Not getcwd). Message-ID: <1991Jun24.204808.22333@world.std.com> Organization: SysLang, Inc. Date: Mon, 24 Jun 1991 20:48:08 GMT Lines: 34 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 -- ----------Time flies like the wind. Fruit flies like bananas.------------------ Steven W. Orr steveo@world.std.com uunet!world!steveo ----------Everybody repeat after me: "We are all individuals."-----------------