version 1.37, 2005/07/04 20:44:47 |
version 1.38, 2005/07/05 02:56:12 |
|
|
*/ |
*/ |
if (lstat(resolved, &sb) == -1) { |
if (lstat(resolved, &sb) == -1) { |
/* Allow nonexistent component if this is the last one. */ |
/* Allow nonexistent component if this is the last one. */ |
if ((*q == 0 || (*q == '/' && *(q + 1) == 0)) |
while (*q == '/') |
&& errno == ENOENT) { |
q++; |
|
if (*q == 0 && errno == ENOENT) { |
errno = serrno; |
errno = serrno; |
return (resolved); |
return (resolved); |
} |
} |
return (NULL); |
return (NULL); |
} |
} |
if (*q == '/' && !S_ISDIR(sb.st_mode)) { |
|
errno = ENOTDIR; |
|
return (NULL); |
|
} |
|
if (S_ISLNK(sb.st_mode)) { |
if (S_ISLNK(sb.st_mode)) { |
if (nlnk++ >= MAXSYMLINKS) { |
if (nlnk++ >= MAXSYMLINKS) { |
errno = ELOOP; |
errno = ELOOP; |
|
|
p = resolved; |
p = resolved; |
goto loop; |
goto loop; |
} |
} |
|
if (*q == '/' && !S_ISDIR(sb.st_mode)) { |
|
errno = ENOTDIR; |
|
return (NULL); |
|
} |
|
|
/* Advance both resolved and unresolved path. */ |
/* Advance both resolved and unresolved path. */ |
p += 1 + q - path; |
p += 1 + q - path; |