1*66117Sbostic.\" Copyright (c) 1994 2*66117Sbostic.\" The Regents of the University of California. All rights reserved. 3*66117Sbostic.\" 4*66117Sbostic.\" This code is derived from software contributed to Berkeley by 5*66117Sbostic.\" Jan-Simon Pendry. 6*66117Sbostic.\" 7*66117Sbostic.\" %sccs.include.redist.roff% 8*66117Sbostic.\" 9*66117Sbostic.\" @(#)realpath.3 8.1 (Berkeley) 02/16/94 10*66117Sbostic.\" 11*66117Sbostic.Dd "" 12*66117Sbostic.Dt REALPATH 3 13*66117Sbostic.Os 14*66117Sbostic.Sh NAME 15*66117Sbostic.Nm realpath 16*66117Sbostic.Nd returns the canonicalized absolute pathname 17*66117Sbostic.Sh SYNOPSIS 18*66117Sbostic.Fd #include <sys/param.h> 19*66117Sbostic.Fd #include <stdlib.h> 20*66117Sbostic.Ft "char *" 21*66117Sbostic.Fn realpath "const char *pathname" "char resolvedname[MAXPATHLEN]" 22*66117Sbostic.Sh DESCRIPTION 23*66117SbosticThe 24*66117Sbostic.Fn realpath 25*66117Sbosticfunction resolves all symbolic links, extra 26*66117Sbostic.Dq / 27*66117Sbosticcharacters and references to 28*66117Sbostic.Pa /./ 29*66117Sbosticand 30*66117Sbostic.Pa /../ 31*66117Sbosticin 32*66117Sbostic.Fa pathname , 33*66117Sbosticand copies the resulting absolute pathname into 34*66117Sbosticthe memory referenced by 35*66117Sbostic.Fa resolvedname . 36*66117SbosticThe 37*66117Sbostic.Fa resolvedname 38*66117Sbosticargument 39*66117Sbostic.Em must 40*66117Sbosticrefer to a buffer capable of storing at least 41*66117Sbostic.Dv MAXPATHLEN 42*66117Sbosticcharacters. 43*66117Sbostic.Pp 44*66117SbosticThe 45*66117Sbostic.Fn realpath 46*66117Sbosticfunction will resolve both absolute and relative paths 47*66117Sbosticand return the absolute pathname corresponding to 48*66117Sbostic.Fa pathname . 49*66117SbosticAll but the last component of 50*66117Sbostic.Fa pathname 51*66117Sbosticmust exist when 52*66117Sbostic.Fn realpath 53*66117Sbosticis called. 54*66117Sbostic.Sh "RETURN VALUES" 55*66117SbosticThe 56*66117Sbostic.Fn realpath 57*66117Sbosticfunction returns 58*66117Sbostic.Fa resolved_name 59*66117Sbosticon success. 60*66117SbosticIf an error occurs, 61*66117Sbostic.Fn realpath 62*66117Sbosticreturns 63*66117Sbostic.Dv NULL , 64*66117Sbosticand 65*66117Sbostic.Fa resolved_name 66*66117Sbosticcontains the pathname which caused the problem. 67*66117Sbostic.Sh ERRORS 68*66117SbosticThe function 69*66117Sbostic.Fn realpath 70*66117Sbosticmay fail and set the external variable 71*66117Sbostic.Va errno 72*66117Sbosticfor any of the errors specified for the library functions 73*66117Sbostic.Xr chdir 2 , 74*66117Sbostic.Xr close 2 , 75*66117Sbostic.Xr fchdir 2 , 76*66117Sbostic.Xr lstat 2 , 77*66117Sbostic.Xr open 2 , 78*66117Sbostic.Xr readlink 2 79*66117Sbosticand 80*66117Sbostic.Xr getcwd 3 . 81*66117Sbostic.Sh CAVEATS 82*66117SbosticThis implementation of 83*66117Sbostic.Fn realpath 84*66117Sbosticdiffers slightly from the Solaris implementation. 85*66117SbosticThe 86*66117Sbostic.Bx 4.4 87*66117Sbosticversion always returns absolute pathnames, 88*66117Sbosticwhereas the Solaris implementation will, 89*66117Sbosticunder certain circumstances, return a relative 90*66117Sbostic.Fa resolved_path 91*66117Sbosticwhen given a relative 92*66117Sbostic.Fa pathname . 93*66117Sbostic.Sh "SEE ALSO" 94*66117Sbostic.Xr getcwd 3 95*66117Sbostic.Sh HISTORY 96*66117SbosticThe 97*66117Sbostic.Fn realpath 98*66117Sbosticfunction call first appeared in 99*66117Sbostic.Bx 4.4 -Lite. 100