cvs: php4 /ext/standard link.c TSRM tsrm_virtual_cwd.c tsrm_virtual_cwd.h

From: Date: Mon, 04 Nov 2002 23:24:15 +0000
Subject: cvs: php4 /ext/standard link.c TSRM tsrm_virtual_cwd.c tsrm_virtual_cwd.h
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-15804@lists.php.net to get a copy of this message
iliaa Mon Nov 4 18:24:15 2002 EDT Modified files: /TSRM tsrm_virtual_cwd.c tsrm_virtual_cwd.h /php4/ext/standard link.c Log: Revert virtual_link() patch. Index: TSRM/tsrm_virtual_cwd.c diff -u TSRM/tsrm_virtual_cwd.c:1.38 TSRM/tsrm_virtual_cwd.c:1.39 --- TSRM/tsrm_virtual_cwd.c:1.38 Mon Nov 4 15:45:28 2002 +++ TSRM/tsrm_virtual_cwd.c Mon Nov 4 18:24:15 2002 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: tsrm_virtual_cwd.c,v 1.38 2002/11/04 20:45:28 andi Exp $ */ +/* $Id: tsrm_virtual_cwd.c,v 1.39 2002/11/04 23:24:15 iliaa Exp $ */ #include <sys/types.h> #include <sys/stat.h> @@ -282,29 +282,6 @@ return buf; } -CWD_API char *virtual_link(char *buf, size_t size TSRMLS_DC) -{ - char *p; - char tmp_path[MAXPATHLEN * 2]; - char resolved_path[MAXPATHLEN]; - - if (IS_ABSOLUTE_PATH(buf, size)) { - p = resolved_path; - memcpy(p, buf, size); - p[size] = '\0'; - } else { - virtual_getcwd(tmp_path, MAXPATHLEN TSRMLS_CC); - p = tmp_path + strlen(tmp_path); - *p++ = '/'; - memcpy(p, buf, size); - *(p + size) = '\0'; - - p = tmp_path; - } - - return p; -} - /* Resolve path relatively to state and put the real path into state */ /* returns 0 for ok, 1 for error */ CWD_API int virtual_file_ex(cwd_state *state, const char *path, verify_path_func verify_path) @@ -709,24 +686,30 @@ #if !defined(TSRM_WIN32) && !defined(NETWARE) CWD_API int virtual_lstat(const char *path, struct stat *buf TSRMLS_DC) { + cwd_state new_state; int retval; - char *p; - p = virtual_link((char *)path, strlen(path) TSRMLS_CC); - retval = lstat(p, buf); + CWD_STATE_COPY(&new_state, &CWDG(cwd)); + virtual_file_ex(&new_state, path, NULL); + + retval = lstat(new_state.cwd, buf); + CWD_STATE_FREE(&new_state); return retval; } #endif CWD_API int virtual_unlink(const char *path TSRMLS_DC) { + cwd_state new_state; int retval; - char *resolved_path; - resolved_path = virtual_link((char *)path, strlen(path) TSRMLS_CC); - retval = unlink(resolved_path); + CWD_STATE_COPY(&new_state, &CWDG(cwd)); + virtual_file_ex(&new_state, path, NULL); + retval = unlink(new_state.cwd); + + CWD_STATE_FREE(&new_state); return retval; } Index: TSRM/tsrm_virtual_cwd.h diff -u TSRM/tsrm_virtual_cwd.h:1.22 TSRM/tsrm_virtual_cwd.h:1.23 --- TSRM/tsrm_virtual_cwd.h:1.22 Mon Nov 4 15:45:28 2002 +++ TSRM/tsrm_virtual_cwd.h Mon Nov 4 18:24:15 2002 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: tsrm_virtual_cwd.h,v 1.22 2002/11/04 20:45:28 andi Exp $ */ +/* $Id: tsrm_virtual_cwd.h,v 1.23 2002/11/04 23:24:15 iliaa Exp $ */ #ifndef VIRTUAL_CWD_H #define VIRTUAL_CWD_H @@ -54,7 +54,7 @@ (*(c) == '\\' && !IsDBCSLeadByte(*(c-1)))) /* COPY_WHEN_ABSOLUTE also takes path as argument because netware needs it -/* to account for volume name that is unique to NetWare absolute paths + * to account for volume name that is unique to NetWare absolute paths */ #define COPY_WHEN_ABSOLUTE(path) 2 #define IS_ABSOLUTE_PATH(path, len) \ @@ -144,7 +144,6 @@ #endif #if !defined(TSRM_WIN32) && !defined(NETWARE) CWD_API int virtual_lstat(const char *path, struct stat *buf TSRMLS_DC); -CWD_API char *virtual_link(char *buf, size_t size TSRMLS_DC); #endif CWD_API int virtual_unlink(const char *path TSRMLS_DC); CWD_API int virtual_mkdir(const char *pathname, mode_t mode TSRMLS_DC); Index: php4/ext/standard/link.c diff -u php4/ext/standard/link.c:1.41 php4/ext/standard/link.c:1.42 --- php4/ext/standard/link.c:1.41 Mon Oct 21 19:35:29 2002 +++ php4/ext/standard/link.c Mon Nov 4 18:24:15 2002 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: link.c,v 1.41 2002/10/21 23:35:29 iliaa Exp $ */ +/* $Id: link.c,v 1.42 2002/11/04 23:24:15 iliaa Exp $ */ #include "php.h" #include "php_filestat.h" @@ -58,24 +58,22 @@ { zval **filename; char buff[MAXPATHLEN]; - char *p; int ret; - + if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &filename) == FAILURE) { WRONG_PARAM_COUNT; } convert_to_string_ex(filename); - p = virtual_link(Z_STRVAL_PP(filename), Z_STRLEN_PP(filename) TSRMLS_CC); + ret = readlink(Z_STRVAL_PP(filename), buff, MAXPATHLEN-1); - ret = readlink(p, buff, MAXPATHLEN-1); if (ret == -1) { php_error(E_WARNING, "readlink failed (%s)", strerror(errno)); RETURN_FALSE; } /* Append NULL to the end of the string */ buff[ret] = '\0'; - + RETURN_STRING(buff, 1); } /* }}} */

« previous php.cvs (#15804) next »