File: realpath.3

package info (click to toggle)
manpages-es 1.55-9
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 7,468 kB
  • ctags: 6
  • sloc: sh: 1,629; makefile: 64
file content (152 lines) | stat: -rw-r--r-- 4,839 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
.\" Copyright (C) 1999 Andries Brouwer (aeb@cwi.nl)
.\"
.\" Permission is granted to make and distribute verbatim copies of this
.\" manual provided the copyright notice and this permission notice are
.\" preserved on all copies.
.\"
.\" Permission is granted to copy and distribute modified versions of this
.\" manual under the conditions for verbatim copying, provided that the
.\" entire resulting derived work is distributed under the terms of a
.\" permission notice identical to this one
.\" 
.\" Since the Linux kernel and libraries are constantly changing, this
.\" manual page may be incorrect or out-of-date.  The author(s) assume no
.\" responsibility for errors or omissions, or for damages resulting from
.\" the use of the information contained herein.  The author(s) may not
.\" have taken the same level of care in the production of this manual,
.\" which is licensed free of charge, as they might when working
.\" professionally.
.\" 
.\" Formatted or processed versions of this manual, if unaccompanied by
.\" the source, must acknowledge the copyright and authors of this work.
.\"
.\" Rewritten old page, 990824, aeb@cwi.nl
.\"
.\" Translated into Spanish Thu Mar  5 18:33:18 CET 1998  by Gerardo
.\" Aburruzaga García  <gerardo.aburruzaga@uca.es> 
.\" Traducción revisada por Miguel Pérez Ibars <mpi79470@alu.um.es> el 10-febrero-2005
.\"
.TH REALPATH 3  "24 agosto 1999" "" "Manual del Progamador de Linux"
.SH NOMBRE
realpath \- devuelve el nombre de camino absoluto en forma canónica
.SH SINOPSIS
.nf
.B #include <limits.h>
.B #include <stdlib.h>
.sp
.BI "char *realpath(const char *" camino ", char *" camino_resuelto );
.SH DESCRIPCIÓN
.B realpath
expande todos los enlaces simbólicos y resuelve referencias a
.IR '/./' ", " '/../' 
y los caracteres extra
.I '/' 
en la cadena de caracteres terminada en cero especificada por
.IR camino ,
y guarda el camino absoluto en forma canónica en el búfer de tamaño
.B PATH_MAX
al que apunte
.IR camino_resuelto .
El camino resultante no tendrá enlaces simbólicos ni componentes
.I '/./'
o
.IR '/../' .
.SH "VALOR DEVUELTO"
Si no hay error, devuelve un puntero a
.IR camino_resuelto .

Si lo hay, devuelve un puntero NULL y el contenido del array
.I camino_resuelto  
queda indefinido. La variable global
.I errno 
toma un valor que indica el error.
.SH ERRORES
.TP
.B EACCES
Se ha denegado el permiso de lectura o búsqueda para un componente del
prefijo del camino.
.TP
.B EINVAL
O
.I camino
o
.I camino_resuelto
es NULL. (En libc5 esto simplemente provocaría una violación de segmento.)
.TP
.B EIO
Se ha producido un error de E/S al leer del sistema de ficheros.
.TP
.B ELOOP
Se han encontrado demasiandos enlaces simbólicos al traducir el camino.
.TP
.B ENAMETOOLONG
Un componente del camino ha excedido
.B NAME_MAX
caracteres o un camino completo ha excedido
.B PATH_MAX
caracteres
.TP
.B ENOENT
El fichero especificado no existe.
.TP
.B ENOTDIR
Un componente del prefijo del camino no es un directorio.
.SH FALLOS
Nunca use esta función. No funciona correctamente por cuestiones de diseño,
puesto que es imposible determinar un tamaño adecuado para el buffer de salida.
Según POSIX un buffer de tamaño PATH_MAX es suficiente, pero 
PATH_MAX no necesita ser una constante definida, y puede tener que
obtenerse usando
.IR pathconf() .
Y preguntar a
.I pathconf()
no ayuda mucho realmente, puesto que por una parte, POSIX advierte
que el resultado de
.I pathconf()
puede ser enorme e inapropiado para asignar memoria. Y por otra
parte
.I pathconf()
puede devolver \-1 para indicar que PATH_MAX no está limitado.
.LP
Las implementaciones de libc4 y libc5 contienen un desbordamiento de búfer
(`buffer overflow') (solucionado en libc-5.4.13). Por tanto, los programas
con el bit SETUID activo como mount necesitan una versión privada.
.SH HISTORIA
La función
.B realpath
apareció por primera vez en BSD 4.4, aportada por Jan-Simon Pendry. En
Linux, esta función aparece en libc 4.5.21.
.SH "CONFORME A"
En BSD 4.4 y Solaris el límite de la longitud del camino es MAXPATHLEN
(que se encuentra en <sys/param.h>). SUSv2 establece PATH_MAX y
NAME_MAX, como aparecen en <limits.h> o proporcionados por la función
.IR pathconf ().
Un fragmento típico de código fuente sería
.LP
.RS
.nf
#ifdef PATH_MAX
  path_max = PATH_MAX;
#else
  path_max = pathconf (path, _PC_PATH_MAX);
  if (path_max <= 0)
    path_max = 4096;
#endif
.fi
(Véase la sección FALLOS.)
.RE
.LP
Las versiones de BSD 4.4, Linux y SUSv2 siempre devuelven un nombre de ruta
absoluta. Solaris puede devolver un nombre de ruta relativa cuando el
argumento
.I camino
es relativo.
El prototipo de
.B realpath
viene dado en <unistd.h> en libc4 y libc5,
y en <stdlib.h> en cualquier otro sitio.
.SH "VÉASE TAMBIÉN"
.BR readlink (2),
.BR getcwd (3),
.BR pathconf (3),
.BR sysconf (3)