version 1.36.2.1, 2005/08/14 22:08:44 |
version 1.38, 2005/07/05 02:56:12 |
|
|
realpath(const char *path, char *resolved) |
realpath(const char *path, char *resolved) |
{ |
{ |
struct stat sb; |
struct stat sb; |
int idx = 0, n, nlnk = 0; |
int idx = 0, n, nlnk = 0, serrno = errno; |
const char *q; |
const char *q; |
char *p, wbuf[2][MAXPATHLEN]; |
char *p, wbuf[2][MAXPATHLEN]; |
size_t len; |
size_t len; |
|
|
* target to unresolved path. |
* target to unresolved path. |
*/ |
*/ |
if (lstat(resolved, &sb) == -1) { |
if (lstat(resolved, &sb) == -1) { |
|
/* Allow nonexistent component if this is the last one. */ |
|
while (*q == '/') |
|
q++; |
|
if (*q == 0 && errno == ENOENT) { |
|
errno = serrno; |
|
return (resolved); |
|
} |
return (NULL); |
return (NULL); |
} |
} |
if (S_ISLNK(sb.st_mode)) { |
if (S_ISLNK(sb.st_mode)) { |