| version 1.24, 2000/01/22 22:19:10 |
version 1.24.6.3, 2002/12/10 06:25:48 |
| Line 95 realpath(path, resolved) |
|
| Line 95 realpath(path, resolved) |
|
| |
|
| /* Save the starting point. */ |
/* Save the starting point. */ |
| if ((fd = open(".", O_RDONLY)) < 0) { |
if ((fd = open(".", O_RDONLY)) < 0) { |
| (void)strcpy(resolved, "."); |
(void)strlcpy(resolved, ".", MAXPATHLEN); |
| return (NULL); |
return (NULL); |
| } |
} |
| |
|
| Line 107 realpath(path, resolved) |
|
| Line 107 realpath(path, resolved) |
|
| * if it is a directory, then change to that directory. |
* if it is a directory, then change to that directory. |
| * get the current directory name and append the basename. |
* get the current directory name and append the basename. |
| */ |
*/ |
| (void)strncpy(resolved, path, MAXPATHLEN - 1); |
(void)strlcpy(resolved, path, MAXPATHLEN); |
| resolved[MAXPATHLEN - 1] = '\0'; |
|
| loop: |
loop: |
| q = strrchr(resolved, '/'); |
q = strrchr(resolved, '/'); |
| if (q != NULL) { |
if (q != NULL) { |
|
|
| errno = ELOOP; |
errno = ELOOP; |
| goto err1; |
goto err1; |
| } |
} |
| n = readlink(p, resolved, MAXPATHLEN); |
n = readlink(p, resolved, MAXPATHLEN-1); |
| if (n < 0) |
if (n < 0) |
| goto err1; |
goto err1; |
| resolved[n] = '\0'; |
resolved[n] = '\0'; |
|
|
| * Save the last component name and get the full pathname of |
* Save the last component name and get the full pathname of |
| * the current directory. |
* the current directory. |
| */ |
*/ |
| (void)strncpy(wbuf, p, (sizeof(wbuf) - 1)); |
(void)strlcpy(wbuf, p, sizeof(wbuf)); |
| |
|
| /* |
/* |
| * Call the inernal internal version of getcwd which |
* Call the inernal internal version of getcwd which |