projects
/
oweals
/
musl.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
61c2cf8
)
fix get_current_dir_name behavior
author
Rich Felker
<dalias@aerifal.cx>
Sat, 18 Feb 2012 04:56:28 +0000
(23:56 -0500)
committer
Rich Felker
<dalias@aerifal.cx>
Sat, 18 Feb 2012 04:56:28 +0000
(23:56 -0500)
src/misc/get_current_dir_name.c
patch
|
blob
|
history
diff --git
a/src/misc/get_current_dir_name.c
b/src/misc/get_current_dir_name.c
index 212edf3169143b0196dce39bad562753c7b6acc1..e0f463b5caa21b2702dd9b4ba25994a6ab177c66 100644
(file)
--- a/
src/misc/get_current_dir_name.c
+++ b/
src/misc/get_current_dir_name.c
@@
-2,11
+2,15
@@
#include <string.h>
#include <limits.h>
#include <unistd.h>
+#include <sys/stat.h>
char *get_current_dir_name(void) {
+ struct stat a, b;
char buf[PATH_MAX];
- char* res = getenv("PWD");
- if(res && *res) return strdup(res);
+ char *res = getenv("PWD");
+ if (res && *res && !stat(res, &a) && !stat(".", &b)
+ && (a.st_dev == b.st_dev) && (a.st_ino == b.st_ino))
+ return strdup(res);
if(!getcwd(buf, sizeof(buf))) return NULL;
return strdup(buf);
}