1REALPATH(3P)               POSIX Programmer's Manual              REALPATH(3P)
2
3
4

PROLOG

6       This  manual  page is part of the POSIX Programmer's Manual.  The Linux
7       implementation of this interface may differ (consult the  corresponding
8       Linux  manual page for details of Linux behavior), or the interface may
9       not be implemented on Linux.
10

NAME

12       realpath - resolve a pathname
13

SYNOPSIS

15       #include <stdlib.h>
16
17       char *realpath(const char *restrict file_name,
18              char *restrict resolved_name);
19
20

DESCRIPTION

22       The realpath() function shall derive, from the pathname pointed  to  by
23       file_name, an absolute pathname that names the same file, whose resolu‐
24       tion does not involve '.', '..', or symbolic links. The generated path‐
25       name  shall  be  stored as a null-terminated string, up to a maximum of
26       {PATH_MAX} bytes, in the buffer pointed to by resolved_name.
27
28       If resolved_name is a null  pointer,  the  behavior  of  realpath()  is
29       implementation-defined.
30

RETURN VALUE

32       Upon  successful  completion,  realpath() shall return a pointer to the
33       resolved name. Otherwise, realpath() shall return a  null  pointer  and
34       set errno to indicate the error, and the contents of the buffer pointed
35       to by resolved_name are undefined.
36

ERRORS

38       The realpath() function shall fail if:
39
40       EACCES Read  or  search  permission  was  denied  for  a  component  of
41              file_name.
42
43       EINVAL The file_name argument is a null pointer.
44
45       EIO    An error occurred while reading from the file system.
46
47       ELOOP  A loop exists in symbolic links encountered during resolution of
48              the path argument.
49
50       ENAMETOOLONG
51              The length of the file_name argument  exceeds  {PATH_MAX}  or  a
52              pathname component is longer than {NAME_MAX}.
53
54       ENOENT A  component  of  file_name  does  not  name an existing file or
55              file_name points to an empty string.
56
57       ENOTDIR
58              A component of the path prefix is not a directory.
59
60
61       The realpath() function may fail if:
62
63       ELOOP  More than {SYMLOOP_MAX} symbolic links were  encountered  during
64              resolution of the path argument.
65
66       ENAMETOOLONG
67              Pathname  resolution of a symbolic link produced an intermediate
68              result whose length exceeds {PATH_MAX}.
69
70       ENOMEM Insufficient storage space is available.
71
72
73       The following sections are informative.
74

EXAMPLES

76   Generating an Absolute Pathname
77       The following example generates an absolute pathname for the file iden‐
78       tified by the symlinkpath argument. The generated pathname is stored in
79       the actualpath array.
80
81
82              #include <stdlib.h>
83              ...
84              char *symlinkpath = "/tmp/symlink/file";
85              char actualpath [PATH_MAX+1];
86              char *ptr;
87
88
89              ptr = realpath(symlinkpath, actualpath);
90

APPLICATION USAGE

92       None.
93

RATIONALE

95       Since the maximum pathname length is  arbitrary  unless  {PATH_MAX}  is
96       defined,  an application generally cannot supply a resolved_name buffer
97       with size {{PATH_MAX}+1}.
98

FUTURE DIRECTIONS

100       In  the  future,  passing  a  null  pointer  to  realpath()   for   the
101       resolved_name argument may be defined to have realpath() allocate space
102       for the generated pathname.
103

SEE ALSO

105       getcwd(),    sysconf(),    the    Base    Definitions     volume     of
106       IEEE Std 1003.1-2001, <stdlib.h>
107
109       Portions  of  this text are reprinted and reproduced in electronic form
110       from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
111       --  Portable  Operating  System  Interface (POSIX), The Open Group Base
112       Specifications Issue 6, Copyright (C) 2001-2003  by  the  Institute  of
113       Electrical  and  Electronics  Engineers, Inc and The Open Group. In the
114       event of any discrepancy between this version and the original IEEE and
115       The  Open Group Standard, the original IEEE and The Open Group Standard
116       is the referee document. The original Standard can be  obtained  online
117       at http://www.opengroup.org/unix/online.html .
118
119
120
121IEEE/The Open Group                  2003                         REALPATH(3P)
Impressum