summaryrefslogtreecommitdiff
path: root/TSRM
diff options
context:
space:
mode:
authorIlia Alshanetsky <iliaa@php.net>2003-08-07 15:32:18 +0000
committerIlia Alshanetsky <iliaa@php.net>2003-08-07 15:32:18 +0000
commit63fcd301e9f61fff27540d40169bca49fc4d676e (patch)
treec7ac9b5223267cecebf2101add4e00563a8b3651 /TSRM
parent296f6f3340bb23c91f0ad7ee163b8d5cc55fa8d2 (diff)
downloadphp-git-63fcd301e9f61fff27540d40169bca49fc4d676e.tar.gz
Fixed bug #21958 (workaround for unusual realpath() on AIX & Tru64).
Diffstat (limited to 'TSRM')
-rw-r--r--TSRM/tsrm_virtual_cwd.h27
1 files changed, 27 insertions, 0 deletions
diff --git a/TSRM/tsrm_virtual_cwd.h b/TSRM/tsrm_virtual_cwd.h
index cc8abb7f7b..999bfe247b 100644
--- a/TSRM/tsrm_virtual_cwd.h
+++ b/TSRM/tsrm_virtual_cwd.h
@@ -41,6 +41,10 @@
#include <unistd.h>
#endif
+#if defined(__osf__) || defined(_AIX)
+#include <errno.h>
+#endif
+
#ifdef TSRM_WIN32
#include "readdir.h"
#include <sys/utime.h>
@@ -167,6 +171,25 @@ CWD_API int virtual_access(const char *pathname, int mode TSRMLS_DC);
#endif
#endif
+/* On AIX & Tru64 when a file does not exist realpath() returns
+ * NULL, and sets errno to ENOENT. Unlike in other libc implementations
+ * the destination is not filled and remains undefined. Therefor, we
+ * must populate it manually using strcpy as done on systems with no
+ * realpath() function.
+ */
+#if defined(__osf__) || defined(_AIX)
+static char *php_realpath_hack(char *src, char *dest)
+{
+ char *ret;
+
+ if ((ret = realpath(src, dest)) == NULL && errno == ENOENT) {
+ return strcpy(dest, src);
+ } else {
+ return ret;
+ }
+}
+#endif
+
#if HAVE_UTIME
CWD_API int virtual_utime(const char *filename, struct utimbuf *buf TSRMLS_DC);
#endif
@@ -248,7 +271,11 @@ typedef struct _virtual_cwd_globals {
#endif
#ifdef HAVE_REALPATH
+#if defined(__osf__) || defined(_AIX)
+#define VCWD_REALPATH(path, real_path) php_realpath_hack(path, real_path)
+#else
#define VCWD_REALPATH(path, real_path) realpath(path, real_path)
+#endif
#else
#define VCWD_REALPATH(path, real_path) strcpy(real_path, path)
#endif