|
|
| version 1.19, 2006/06/07 04:29:01 | version 1.20, 2007/09/11 04:08:29 |
|---|---|
| Line 314 int __do_set(const char *file, const str | Line 314 int __do_set(const char *file, const str |
| char *resolve_symlinks(const char *file) | char *resolve_symlinks(const char *file) |
| { | { |
| static char buffer[4096]; | static char buffer[4096]; |
| struct stat stat; | |
| char *path = NULL; | char *path = NULL; |
| ssize_t len; | |
| len = readlink(file, buffer, sizeof(buffer)-1); | if (lstat(file, &stat) == -1) |
| if (len < 0) { | return path; |
| if (errno == EINVAL) /* not a symlink, use given path */ | |
| path = (char *)file; | if (S_ISLNK(stat.st_mode) && !opt_walk_physical) |
| } else { | path = realpath(file, buffer); |
| buffer[len+1] = '\0'; | else |
| path = buffer; | path = (char *)file; /* not a symlink, use given path */ |
| } | |
| return path; | return path; |
| } | } |