.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
-.\" 3. All advertising materials mentioning features or use of this software
-.\" must display the following acknowledgement:
-.\" This product includes software developed by the University of
-.\" California, Berkeley and its contributors.
.\" 4. Neither the name of the University nor the names of its contributors
.\" may be used to endorse or promote products derived from this software
.\" without specific prior written permission.
.\" SUCH DAMAGE.
.\"
.\" @(#)getcwd.3 8.2 (Berkeley) 12/11/93
-.\" $FreeBSD: src/lib/libc/gen/getcwd.3,v 1.15 2001/10/01 16:08:51 ru Exp $
+.\" $FreeBSD$
.\"
-.Dd November 24, 1997
+.Dd April 17, 2010
.Dt GETCWD 3
.Os
.Sh NAME
.Fa buf
is
.Dv NULL ,
-space is allocated as necessary to store the pathname.
+space is allocated as necessary to store the pathname and
+.Fa size
+is ignored.
This space may later be
.Xr free 3 Ns 'd .
.Pp
.Dv MAXPATHLEN
(as defined in the include
file
-.Aq Pa sys/param.h ) .
+.In sys/param.h ) .
Obviously,
.Fa buf
should be at least
function
will fail if:
.Bl -tag -width Er
-.It Bq Er EACCES
-Read or search permission was denied for a component of the pathname.
.It Bq Er EINVAL
The
.Fa size
argument is greater than zero but smaller than the length of the pathname
plus 1.
.El
+.Pp
+The
+.Fn getcwd
+function
+may fail if:
+.Bl -tag -width Er
+.It Bq Er EACCES
+Read or search permission was denied for a component of the pathname.
+This is only checked in limited cases, depending on implementation details.
+.El
.Sh SEE ALSO
.Xr chdir 2 ,
.Xr fchdir 2 ,