1.\" Copyright (c) 1994 2.\" The Regents of the University of California. All rights reserved. 3.\" 4.\" This code is derived from software contributed to Berkeley by 5.\" Jan-Simon Pendry. 6.\" 7.\" Redistribution and use in source and binary forms, with or without 8.\" modification, are permitted provided that the following conditions 9.\" are met: 10.\" 1. Redistributions of source code must retain the above copyright 11.\" notice, this list of conditions and the following disclaimer. 12.\" 2. Redistributions in binary form must reproduce the above copyright 13.\" notice, this list of conditions and the following disclaimer in the 14.\" documentation and/or other materials provided with the distribution. 15.\" 3. All advertising materials mentioning features or use of this software 16.\" must display the following acknowledgement: 17.\" This product includes software developed by the University of 18.\" California, Berkeley and its contributors. 19.\" 4. Neither the name of the University nor the names of its contributors 20.\" may be used to endorse or promote products derived from this software 21.\" without specific prior written permission. 22.\" 23.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 24.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 25.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 26.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 27.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 28.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 29.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 30.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 32.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 33.\" SUCH DAMAGE. 34.\" 35.\" $OpenBSD: realpath.3,v 1.8 2001/04/23 15:30:25 aaron Exp $ 36.\" 37.Dd February 16, 1994 38.Dt REALPATH 3 39.Os 40.Sh NAME 41.Nm realpath 42.Nd returns the canonicalized absolute pathname 43.Sh SYNOPSIS 44.Fd #include <sys/param.h> 45.Fd #include <stdlib.h> 46.Ft "char *" 47.Fn realpath "const char *pathname" "char resolvedname[MAXPATHLEN]" 48.Sh DESCRIPTION 49The 50.Fn realpath 51function resolves all symbolic links, extra 52.Dq / 53characters and references to 54.Pa /./ 55and 56.Pa /../ 57in 58.Fa pathname , 59and copies the resulting absolute pathname into the memory referenced by 60.Fa resolvedname . 61The 62.Fa resolvedname 63argument 64.Em must 65refer to a buffer capable of storing at least 66.Dv MAXPATHLEN 67characters. 68.Pp 69The 70.Fn realpath 71function will resolve both absolute and relative paths 72and return the absolute pathname corresponding to 73.Fa pathname . 74All but the last component of 75.Fa pathname 76must exist when 77.Fn realpath 78is called. 79.Sh "RETURN VALUES" 80The 81.Fn realpath 82function returns 83.Fa resolvedname 84on success. 85If an error occurs, 86.Fn realpath 87returns 88.Dv NULL , 89and 90.Fa resolvedname 91contains the pathname which caused the problem. 92.Sh ERRORS 93The function 94.Fn realpath 95may fail and set the external variable 96.Va errno 97for any of the errors specified for the library functions 98.Xr chdir 2 , 99.Xr close 2 , 100.Xr fchdir 2 , 101.Xr lstat 2 , 102.Xr open 2 , 103.Xr readlink 2 , 104and 105.Xr getcwd 3 . 106.Sh CAVEATS 107This implementation of 108.Fn realpath 109differs slightly from the Solaris implementation. 110The 111.Bx 4.4 112version always returns absolute pathnames, 113whereas the Solaris implementation will, 114under certain circumstances, return a relative 115.Fa resolvedname 116when given a relative 117.Fa pathname . 118.Sh SEE ALSO 119.Xr getcwd 3 120.Sh HISTORY 121The 122.Fn realpath 123function call first appeared in 124.Bx 4.4 . 125