16971e777SSascha Wildner.\" 2d8bda3d5SMatthew Dillon.\" Copyright (c) 2020 The DragonFly Project. All rights reserved. 3d8bda3d5SMatthew Dillon.\" 4d8bda3d5SMatthew Dillon.\" This code is derived from software contributed to The DragonFly Project 5d8bda3d5SMatthew Dillon.\" by Matthew Dillon <dillon@backplane.com> 6d8bda3d5SMatthew Dillon.\" 7d8bda3d5SMatthew Dillon.\" Redistribution and use in source and binary forms, with or without 8d8bda3d5SMatthew Dillon.\" modification, are permitted provided that the following conditions 9d8bda3d5SMatthew Dillon.\" are met: 10d8bda3d5SMatthew Dillon.\" 11d8bda3d5SMatthew Dillon.\" 1. Redistributions of source code must retain the above copyright 12d8bda3d5SMatthew Dillon.\" notice, this list of conditions and the following disclaimer. 13d8bda3d5SMatthew Dillon.\" 2. Redistributions in binary form must reproduce the above copyright 14d8bda3d5SMatthew Dillon.\" notice, this list of conditions and the following disclaimer in 15d8bda3d5SMatthew Dillon.\" the documentation and/or other materials provided with the 16d8bda3d5SMatthew Dillon.\" distribution. 17d8bda3d5SMatthew Dillon.\" 3. Neither the name of The DragonFly Project nor the names of its 18d8bda3d5SMatthew Dillon.\" contributors may be used to endorse or promote products derived 19d8bda3d5SMatthew Dillon.\" from this software without specific, prior written permission. 20d8bda3d5SMatthew Dillon.\" 21d8bda3d5SMatthew Dillon.\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22d8bda3d5SMatthew Dillon.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23d8bda3d5SMatthew Dillon.\" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 24d8bda3d5SMatthew Dillon.\" FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 25d8bda3d5SMatthew Dillon.\" COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 26d8bda3d5SMatthew Dillon.\" INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, 27d8bda3d5SMatthew Dillon.\" BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 28d8bda3d5SMatthew Dillon.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 29d8bda3d5SMatthew Dillon.\" AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 30d8bda3d5SMatthew Dillon.\" OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 31d8bda3d5SMatthew Dillon.\" OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 32d8bda3d5SMatthew Dillon.\" SUCH DAMAGE. 336971e777SSascha Wildner.\" 34d8bda3d5SMatthew Dillon.Dd February 2, 2020 35d8bda3d5SMatthew Dillon.Dt __REALPATH 2 36d8bda3d5SMatthew Dillon.Os 37d8bda3d5SMatthew Dillon.Sh NAME 38d8bda3d5SMatthew Dillon.Nm __realpath 39d8bda3d5SMatthew Dillon.Nd resolves the canonicalized absolute pathname 40d8bda3d5SMatthew Dillon.Sh LIBRARY 41d8bda3d5SMatthew Dillon.Lb libc 42d8bda3d5SMatthew Dillon.Sh SYNOPSIS 43d8bda3d5SMatthew Dillon.Ft "int" 44d8bda3d5SMatthew Dillon.Fn __realpath "const char * restrict pathname" "char * restrict resolved_path" "size_t len" 45d8bda3d5SMatthew Dillon.Sh DESCRIPTION 46d8bda3d5SMatthew DillonThe 47d8bda3d5SMatthew Dillon.Fn __realpath 48d8bda3d5SMatthew Dillonsystem call is used to support the libc 49d8bda3d5SMatthew Dillon.Fn realpath 50d8bda3d5SMatthew Dillonlibrary call. 51d8bda3d5SMatthew DillonIt basically does the same thing but with a lower-level system-call 52d8bda3d5SMatthew Dilloncompatible API. 53d8bda3d5SMatthew DillonThe system call differs from the libc function as follows: 54d8bda3d5SMatthew DillonIt requires that the target buffer and the size of the target 55d8bda3d5SMatthew Dillonbuffer be supplied, it does not (obviously) allocate a target buffer if NULL 56d8bda3d5SMatthew Dillonis supplied, and it returns the string length of the target buffer (not 57d8bda3d5SMatthew Dillonincluding the terminator) or -1. 58d8bda3d5SMatthew DillonIf a failure occurs, the target buffer will not be modified (whereas it is 59d8bda3d5SMatthew Dillonin the libc function). 60d8bda3d5SMatthew Dillon.Pp 61*9e4b1105SSascha WildnerThe system call resolves all symbolic links, extra 62d8bda3d5SMatthew Dillon.Dq / 63d8bda3d5SMatthew Dilloncharacters and references to 64d8bda3d5SMatthew Dillon.Pa /./ 65d8bda3d5SMatthew Dillonand 66d8bda3d5SMatthew Dillon.Pa /../ 67d8bda3d5SMatthew Dillonin 68d8bda3d5SMatthew Dillon.Fa pathname , 69d8bda3d5SMatthew Dillonand copies the resulting absolute pathname into 70d8bda3d5SMatthew Dillonthe memory pointed to by 71d8bda3d5SMatthew Dillon.Fa resolved_path . 72d8bda3d5SMatthew DillonThe 73d8bda3d5SMatthew Dillon.Fa resolved_path 74d8bda3d5SMatthew Dillonargument 75d8bda3d5SMatthew Dillon.Em must 76d8bda3d5SMatthew Dillonpoint to a buffer capable of storing at least 776971e777SSascha Wildner.Fa len 78d8bda3d5SMatthew Dilloncharacters, and may not be 79d8bda3d5SMatthew Dillon.Dv NULL . 80d8bda3d5SMatthew Dillon.Pp 81d8bda3d5SMatthew DillonThe 82d8bda3d5SMatthew Dillon.Fn __realpath 83d8bda3d5SMatthew Dillonfunction will resolve both absolute and relative paths 84d8bda3d5SMatthew Dillonand return the absolute pathname corresponding to 85d8bda3d5SMatthew Dillon.Fa pathname . 86d8bda3d5SMatthew DillonAll components of 87d8bda3d5SMatthew Dillon.Fa pathname 88d8bda3d5SMatthew Dillonmust exist when 89d8bda3d5SMatthew Dillon.Fn __realpath 90d8bda3d5SMatthew Dillonis called, and all but the last component must name either directories or 91d8bda3d5SMatthew Dillonsymlinks pointing to the directories. 92d8bda3d5SMatthew Dillon.Sh "RETURN VALUES" 93d8bda3d5SMatthew DillonThe 94d8bda3d5SMatthew Dillon.Fn realpath 95d8bda3d5SMatthew Dillonfunction returns 96d8bda3d5SMatthew Dillonthe string length of the path stored in the target buffer, not including 97d8bda3d5SMatthew Dillonthe terminator, or -1 on failure. 98d8bda3d5SMatthew Dillon.Sh ERRORS 99d8bda3d5SMatthew DillonThe function 100d8bda3d5SMatthew Dillonmay fail and set the external variable 101d8bda3d5SMatthew Dillon.Va errno 102d8bda3d5SMatthew Dillonfor any of the errors specified for the library function 103d8bda3d5SMatthew Dillon.Xr realpath 3 . 104d8bda3d5SMatthew Dillon.Sh SEE ALSO 105d8bda3d5SMatthew Dillon.Xr realpath 3 106d8bda3d5SMatthew Dillon.Sh HISTORY 107d8bda3d5SMatthew DillonThe 108d8bda3d5SMatthew Dillon.Fn __realpath 109d8bda3d5SMatthew Dillonfunction first appeared in 110d8bda3d5SMatthew Dillon.Dx 5.7 . 111d8bda3d5SMatthew Dillon.Sh CAVEATS 112d8bda3d5SMatthew DillonThis is the system call version of the libc 113d8bda3d5SMatthew Dillon.Fn realpath 114d8bda3d5SMatthew Dillonfunction, but is not a replacement for the libc function due to 115d8bda3d5SMatthew Dillonnecessary API differences. 116