Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sun-barr!lll-winken!uunet!bu.edu!nntp-read!jbw From: jbw@bucsf.bu.edu (Joe Wells) Newsgroups: comp.unix.programmer Subject: Why does getpwd() have to chdir()? Message-ID: Date: 16 Oct 90 21:54:41 GMT References: <1977@sixhub.UUCP> <1990Oct7.001518.14216@diku.dk> <1990Oct11.012643.11274@diku.dk> <11478@alice.att.com> <3554@skye.ed.ac.uk> Sender: news@bu.edu.bu.edu Organization: Boston University Computer Science Department Lines: 12 In-reply-to: richard@aiai.ed.ac.uk's message of 15 Oct 90 17:30:09 GMT In article <3554@skye.ed.ac.uk> richard@aiai.ed.ac.uk (Richard Tobin) writes: Why does getpwd() have to chdir()? In most Unixes, there's a kernel limit of 1024 characters in a pathname. If your current directory were located deep enough in the filesystem, getcwd() couldn't make it all the way up to the root without chdir()-ing. Of course, you understand how unlikely this is, but it is necessary for the algorithm to be correct. -- Joe Wells