On Wed, 9 Dec 1998, Mitch Chapman wrote:
Sorry, I'm not running Linux on my PC at the moment. But under Solaris:
ERRORS getcwd() will fail if one or more of the following are true:
EACCES A parent directory cannot be read to get its name. ... That is so, because of the way getcwd() is (was orginally?) implemented: It basically works by looking recursivly on the parent directory, reading it, and comparing inode numbers.
So let's say, I'm in cwd with inum=10050, than cwd starts by reading .., and notices that ``andreas'' happens to have inum 10050, so getcwd() just learned that the last component is andreas. And it goes so one till it finds ``/''. That's why in bash, there is a difference between the cwd as displayed by bash, and say by ``sh -c pwd'', because bash tracks cd commands, which make it remember symbolic links, and the standalone pwd does the recursive thing ;) And for the recursive reading stuff you need read rights in all directories leading to the current directory, ... Andreas -- Win95: n., A huge annoying boot virus that causes random spontaneous system crashes, usually just before saving a massive project. Easily cured by UNIX. See also MS-DOS, IBM-DOS, DR-DOS, Win 3.x, Win98.