Re: chdir on linux does not work

Adrian Ho <[email protected]> Thu, 25 May 2006 11:55:18 +0800
Newsgroups org.kernel.vger.linux-assembly
Message-ID <[email protected]>
On Wed, May 24, 2006 at 02:49:24AM -0400, Frank Kotler wrote:
> Adding a call to sys_getcwd (__NR_ 183) (why is this man 3, not man 2 
> ???)

Are you talking about sys_getcwd(3) (which I've never seen or known to
exist) or getcwd(3)?  If the latter, there's a Linux-specific extension
that uses malloc() -- perhaps that's the reason why:

 As an extension to the POSIX.1 standard, Linux (libc4, libc5, glibc)
 getcwd() allocates the buffer dynamically using malloc() if buf is NULL
 on call. In this case, the allocated buffer has the length size unless
 size is zero, when buf is allocated as big as necessary. It is possi-
 ble (and, indeed, advisable) to free() the buffers if they have been
 obtained this way.

- Adrian