--- TSRM/tsrm_virtual_cwd.c.orig Sat Nov 4 00:56:05 2006 +++ TSRM/tsrm_virtual_cwd.c Sat Nov 4 02:53:13 2006 @@ -361,6 +361,23 @@ } +CWD_API int realpath_cache_delete(const char *path, int path_len) { + unsigned long key = realpath_cache_key(path, path_len); + unsigned long n = key % (sizeof(CWDG(realpath_cache)) / sizeof(CWDG(realpath_cache)[0])); + realpath_cache_bucket **bucket = &CWDG(realpath_cache)[n]; + + while (*bucket != NULL) { + if (key == (*bucket)->key && path_len == (*bucket)->path_len && + memcmp(path, (*bucket)->path, path_len) == 0) { + realpath_cache_bucket *r = *bucket; + *bucket = (*bucket)->next; + CWDG(realpath_cache_size) -= sizeof(realpath_cache_bucket) + r->path_len + 1 + r->realpath_len + 1; + free(r); + } + } + return 0; +} + /* 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, int use_realpath) --- TSRM/tsrm_virtual_cwd.h.orig Sat Nov 4 02:39:04 2006 +++ TSRM/tsrm_virtual_cwd.h Sat Nov 4 03:06:03 2006 @@ -156,6 +156,7 @@ CWD_API DIR *virtual_opendir(const char *pathname TSRMLS_DC); 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); +CWD_API int realpath_cache_delete(const char *path, int path_len); #if defined(TSRM_WIN32) /* these are not defined in win32 headers */ #ifndef W_OK @@ -232,14 +233,14 @@ #define VCWD_CHDIR_FILE(path) virtual_chdir_file(path, virtual_chdir TSRMLS_CC) #define VCWD_GETWD(buf) #define VCWD_REALPATH(path, real_path) virtual_realpath(path, real_path TSRMLS_CC) -#define VCWD_RENAME(oldname, newname) virtual_rename(oldname, newname TSRMLS_CC) +#define VCWD_RENAME(oldname, newname) (virtual_rename(oldname, newname TSRMLS_CC) + realpath_cache_delete(oldname, strlen(oldname)) + realpath_cache_delete(newname, strlen(newname))) #define VCWD_STAT(path, buff) virtual_stat(path, buff TSRMLS_CC) #if !defined(TSRM_WIN32) #define VCWD_LSTAT(path, buff) virtual_lstat(path, buff TSRMLS_CC) #endif -#define VCWD_UNLINK(path) virtual_unlink(path TSRMLS_CC) +#define VCWD_UNLINK(path) (virtual_unlink(path TSRMLS_CC) + realpath_cache_delete(path, strlen(path))) #define VCWD_MKDIR(pathname, mode) virtual_mkdir(pathname, mode TSRMLS_CC) -#define VCWD_RMDIR(pathname) virtual_rmdir(pathname TSRMLS_CC) +#define VCWD_RMDIR(pathname) (virtual_rmdir(pathname TSRMLS_CC) + realpath_cache_delete(pathname, strlen(pathname))) #define VCWD_OPENDIR(pathname) virtual_opendir(pathname TSRMLS_CC) #define VCWD_POPEN(command, type) virtual_popen(command, type TSRMLS_CC) #define VCWD_ACCESS(pathname, mode) virtual_access(pathname, mode TSRMLS_CC) @@ -261,15 +262,15 @@ #define VCWD_OPEN(path, flags) open(path, flags) #define VCWD_OPEN_MODE(path, flags, mode) open(path, flags, mode) #define VCWD_CREAT(path, mode) creat(path, mode) -#define VCWD_RENAME(oldname, newname) rename(oldname, newname) +#define VCWD_RENAME(oldname, newname) (rename(oldname, newname) + realpath_cache_delete(oldname, strlen(oldname)) + realpath_cache_delete(newname, strlen(newname))) #define VCWD_CHDIR(path) chdir(path) #define VCWD_CHDIR_FILE(path) virtual_chdir_file(path, chdir) #define VCWD_GETWD(buf) getwd(buf) #define VCWD_STAT(path, buff) stat(path, buff) #define VCWD_LSTAT(path, buff) lstat(path, buff) -#define VCWD_UNLINK(path) unlink(path) +#define VCWD_UNLINK(path) (unlink(path) + realpath_cache_delete(path, strlen(path))) #define VCWD_MKDIR(pathname, mode) mkdir(pathname, mode) -#define VCWD_RMDIR(pathname) rmdir(pathname) +#define VCWD_RMDIR(pathname) (rmdir(pathname) + realpath_cache_delete(pathname, strlen(pathname))) #define VCWD_OPENDIR(pathname) opendir(pathname) #define VCWD_POPEN(command, type) popen(command, type) #if defined(TSRM_WIN32)