166117Sbostic.\" Copyright (c) 1994 266117Sbostic.\" The Regents of the University of California. All rights reserved. 366117Sbostic.\" 466117Sbostic.\" This code is derived from software contributed to Berkeley by 566117Sbostic.\" Jan-Simon Pendry. 666117Sbostic.\" 766117Sbostic.\" %sccs.include.redist.roff% 866117Sbostic.\" 9*66122Spendry.\" @(#)realpath.3 8.2 (Berkeley) 02/16/94 1066117Sbostic.\" 1166117Sbostic.Dd "" 1266117Sbostic.Dt REALPATH 3 1366117Sbostic.Os 1466117Sbostic.Sh NAME 1566117Sbostic.Nm realpath 1666117Sbostic.Nd returns the canonicalized absolute pathname 1766117Sbostic.Sh SYNOPSIS 1866117Sbostic.Fd #include <sys/param.h> 1966117Sbostic.Fd #include <stdlib.h> 2066117Sbostic.Ft "char *" 2166117Sbostic.Fn realpath "const char *pathname" "char resolvedname[MAXPATHLEN]" 2266117Sbostic.Sh DESCRIPTION 2366117SbosticThe 2466117Sbostic.Fn realpath 2566117Sbosticfunction resolves all symbolic links, extra 2666117Sbostic.Dq / 2766117Sbosticcharacters and references to 2866117Sbostic.Pa /./ 2966117Sbosticand 3066117Sbostic.Pa /../ 3166117Sbosticin 3266117Sbostic.Fa pathname , 3366117Sbosticand copies the resulting absolute pathname into 3466117Sbosticthe memory referenced by 3566117Sbostic.Fa resolvedname . 3666117SbosticThe 3766117Sbostic.Fa resolvedname 3866117Sbosticargument 3966117Sbostic.Em must 4066117Sbosticrefer to a buffer capable of storing at least 4166117Sbostic.Dv MAXPATHLEN 4266117Sbosticcharacters. 4366117Sbostic.Pp 4466117SbosticThe 4566117Sbostic.Fn realpath 4666117Sbosticfunction will resolve both absolute and relative paths 4766117Sbosticand return the absolute pathname corresponding to 4866117Sbostic.Fa pathname . 4966117SbosticAll but the last component of 5066117Sbostic.Fa pathname 5166117Sbosticmust exist when 5266117Sbostic.Fn realpath 5366117Sbosticis called. 5466117Sbostic.Sh "RETURN VALUES" 5566117SbosticThe 5666117Sbostic.Fn realpath 5766117Sbosticfunction returns 5866117Sbostic.Fa resolved_name 5966117Sbosticon success. 6066117SbosticIf an error occurs, 6166117Sbostic.Fn realpath 6266117Sbosticreturns 6366117Sbostic.Dv NULL , 6466117Sbosticand 6566117Sbostic.Fa resolved_name 6666117Sbosticcontains the pathname which caused the problem. 6766117Sbostic.Sh ERRORS 6866117SbosticThe function 6966117Sbostic.Fn realpath 7066117Sbosticmay fail and set the external variable 7166117Sbostic.Va errno 7266117Sbosticfor any of the errors specified for the library functions 7366117Sbostic.Xr chdir 2 , 7466117Sbostic.Xr close 2 , 7566117Sbostic.Xr fchdir 2 , 7666117Sbostic.Xr lstat 2 , 7766117Sbostic.Xr open 2 , 7866117Sbostic.Xr readlink 2 7966117Sbosticand 8066117Sbostic.Xr getcwd 3 . 8166117Sbostic.Sh CAVEATS 8266117SbosticThis implementation of 8366117Sbostic.Fn realpath 8466117Sbosticdiffers slightly from the Solaris implementation. 8566117SbosticThe 8666117Sbostic.Bx 4.4 8766117Sbosticversion always returns absolute pathnames, 8866117Sbosticwhereas the Solaris implementation will, 8966117Sbosticunder certain circumstances, return a relative 9066117Sbostic.Fa resolved_path 9166117Sbosticwhen given a relative 9266117Sbostic.Fa pathname . 9366117Sbostic.Sh "SEE ALSO" 9466117Sbostic.Xr getcwd 3 9566117Sbostic.Sh HISTORY 9666117SbosticThe 9766117Sbostic.Fn realpath 9866117Sbosticfunction call first appeared in 99*66122Spendry.Bx 4.4 . 100