Path: utzoo!attcan!uunet!virtech!cpcahil From: cpcahil@virtech.UUCP (Conor P. Cahill) Newsgroups: comp.unix.wizards Subject: Re: Inside PWD Message-ID: <1281@virtech.UUCP> Date: 16 Oct 89 00:39:48 GMT References: <166@volvo.vd.volvo.se> Distribution: comp Organization: Virtual Technologies Inc Lines: 28 In article <166@volvo.vd.volvo.se>, peter@vd.volvo.se (Peter Hkansson) writes: > not by doing 'system pwd' or something like that but by a system call. > To use a library call would mean to use a system call en the end > (all library routines uses system calls in the end ??),so that would > not answer my question. If I understand your question, you want to determine your present working directory from within a program. The only mechanism you can use is to get the inode of the current directory (.) and look up that inode in the current directories parent (..) and so on and so forth, properly handling the crossing of mount points and stopping at the root of all evil. The system V solution is to call the getcwd (i think) library function which calls the pwd program and saves the output in a string, a pointer to which is returned to the calling function. The bsd solution is to write the routine into the library call and to have the program call the library call. BTW - there is no system call to do this because the system doesn't know where you are (other than the inode of your current directory). -- +-----------------------------------------------------------------------+ | Conor P. Cahill uunet!virtech!cpcahil 703-430-9247 ! | Virtual Technologies Inc., P. O. Box 876, Sterling, VA 22170 | +-----------------------------------------------------------------------+