From: Ilia Alshanetsky Date: Thu, 7 Aug 2003 15:32:37 +0000 (+0000) Subject: MFH: Fixed bug #21958 (workaround for unusual realpath() on AIX & Tru64). X-Git-Tag: php-4.3.3RC3~8 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=69322ae43bb610ed519ee399e7cfe1e5860a49e3;p=php MFH: Fixed bug #21958 (workaround for unusual realpath() on AIX & Tru64). --- diff --git a/TSRM/tsrm_virtual_cwd.h b/TSRM/tsrm_virtual_cwd.h index 4d5ba24f1b..7c5f1c6925 100644 --- a/TSRM/tsrm_virtual_cwd.h +++ b/TSRM/tsrm_virtual_cwd.h @@ -41,6 +41,10 @@ #include #endif +#if defined(__osf__) || defined(_AIX) +#include +#endif + #ifdef TSRM_WIN32 #include "readdir.h" #include @@ -155,6 +159,25 @@ CWD_API FILE *virtual_popen(const char *command, const char *type TSRMLS_DC); CWD_API int virtual_access(const char *pathname, int mode TSRMLS_DC); #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 @@ -232,7 +255,11 @@ typedef struct _virtual_cwd_globals { #define VCWD_ACCESS(pathname, mode) access(pathname, mode) #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