From 00660f01105b2b727076e9ba416189059abd6ec2 Mon Sep 17 00:00:00 2001 From: Christopher Faylor Date: Tue, 13 Jun 2000 04:40:36 +0000 Subject: * thread.h: Shorten "current_directory" variables to "cwd_*" throughout. * path.cc: Ditto. (normalize_posix_path): Add some extra debugging info. (chdir): Ditto. Store chdir'ed posix and MS-DOS directory names in "cache" here rather than trying to derive them later. --- winsup/cygwin/ChangeLog | 43 ++++++++++++++++---------- winsup/cygwin/path.cc | 82 ++++++++++++++++++++++++------------------------- winsup/cygwin/thread.h | 6 ++-- 3 files changed, 69 insertions(+), 62 deletions(-) (limited to 'winsup/cygwin') diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 705cd55..eb6afc7 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,12 +1,21 @@ +Tue Jun 13 00:17:04 2000 Christopher Faylor + + * thread.h: Shorten "current_directory" variables to "cwd_*" + throughout. + * path.cc: Ditto. + (normalize_posix_path): Add some extra debugging info. + (chdir): Ditto. Store chdir'ed posix and MS-DOS directory names in + "cache" here rather than trying to derive them later. + Sun Jun 11 15:57:00 2000 Corinna Vinschen * fhandler_random.cc (read): Call CryptAquireContext with - CRYPT_VERIFYCONTEXT. + CRYPT_VERIFYCONTEXT. Thu Jun 8 22:49:00 2000 Corinna Vinschen * path.cc (path_conv::check): Erase two lines checked in - by mistake. + by mistake. Thu Jun 8 15:53:00 2000 Corinna Vinschen @@ -15,21 +24,21 @@ Thu Jun 8 15:53:00 2000 Corinna Vinschen 2000-06-07 Kazuhiro Fujieda - * path.cc (mount_info::init): Eliminate the mount_slash feature. - (mount_slash): Eliminated. - (mount_info::read_mounts): Eliminate looking up existing entries. The - loop for deleting cygpath entries is done only when such entries exist. - (mount_info::from_registry): Eliminate sorting. - (mount_info::add_item): Call add_reg_mount if necessary. Check nmounts - more precisely. Use strcasematch in looking up existing entries. - (mount_info::del_item): Call del_reg_mount if necessary. Use - strcasematch. Use memmove instead of memcpy. - (mount_info::import_v1_registry): Everything is done in this method. - (mount_info::to_registry): Eliminated. - (mount_info::from_v1_registry): Eliminated. - (cygwin_umount): Simply call del_item. - * shared.h: Modify the declaration of add_item and del_item. Remove the - declaration of from_v1_registry. + * path.cc (mount_info::init): Eliminate the mount_slash feature. + (mount_slash): Eliminated. + (mount_info::read_mounts): Eliminate looking up existing entries. The + loop for deleting cygpath entries is done only when such entries exist. + (mount_info::from_registry): Eliminate sorting. + (mount_info::add_item): Call add_reg_mount if necessary. Check nmounts + more precisely. Use strcasematch in looking up existing entries. + (mount_info::del_item): Call del_reg_mount if necessary. Use + strcasematch. Use memmove instead of memcpy. + (mount_info::import_v1_registry): Everything is done in this method. + (mount_info::to_registry): Eliminated. + (mount_info::from_v1_registry): Eliminated. + (cygwin_umount): Simply call del_item. + * shared.h: Modify the declaration of add_item and del_item. Remove the + declaration of from_v1_registry. Wed Jun 7 23:56:10 2000 Christopher Faylor diff --git a/winsup/cygwin/path.cc b/winsup/cygwin/path.cc index 948d793..f491be0 100644 --- a/winsup/cygwin/path.cc +++ b/winsup/cygwin/path.cc @@ -87,7 +87,7 @@ static char *getcwd_inner (char *buf, size_t ulen, int posix_p); static void slashify (const char *src, char *dst, int trailing_slash_p); static void backslashify (const char *src, char *dst, int trailing_slash_p); static int path_prefix_p_ (const char *path1, const char *path2, int len1); -static int get_current_directory_name (); +static int get_cwd_win32 (); static NO_COPY const char escape_char = '^'; @@ -143,13 +143,13 @@ struct symlink_info support multiple threads. */ #ifdef _MT_SAFE -#define current_directory_name _reent_winsup()->_current_directory_name -#define current_directory_posix_name _reent_winsup()->_current_directory_posix_name -#define current_directory_hash _reent_winsup()->_current_directory_hash +#define cwd_win32 _reent_winsup()->_cwd_win32 +#define cwd_posix _reent_winsup()->_cwd_posix +#define cwd_hash _reent_winsup()->_cwd_hash #else -static char *current_directory_name; -static char *current_directory_posix_name; -static unsigned long current_directory_hash; +static char *cwd_win32; +static char *cwd_posix; +static unsigned long cwd_hash; #endif static int @@ -555,6 +555,7 @@ normalize_posix_path (const char *cwd, const char *src, char *dst) const char *src_start = src; char *dst_start = dst; + syscall_printf ("cwd %s, src %s", cwd, src); if (!isslash (src[0])) { if (strlen (cwd) + 1 + strlen (src) >= MAX_PATH) @@ -873,7 +874,7 @@ mount_info::conv_to_win32_path (const char *src_path, char *win32_path, unsigned *flags) { int src_path_len = strlen (src_path); - int trailing_slash_p = (src_path_len > 0 + int trailing_slash_p = (src_path_len > 1 && SLASH_P (src_path[src_path_len - 1])); MALLOC_CHECK; int isrelpath; @@ -916,7 +917,7 @@ mount_info::conv_to_win32_path (const char *src_path, char *win32_path, if (strpbrk (src_path, ":\\") != NULL) { debug_printf ("%s already win32", src_path); - rc = normalize_win32_path (current_directory_name, src_path, dst); + rc = normalize_win32_path (cwd_win32, src_path, dst); if (rc) { debug_printf ("normalize_win32_path failed, rc %d", rc); @@ -1020,8 +1021,7 @@ fillin: if (win32_path == NULL) /* nothing to do */; else if (isrelpath && - path_prefix_p (current_directory_name, dst, - cwdlen = strlen (current_directory_name))) + path_prefix_p (cwd_win32, dst, cwdlen = strlen (cwd_win32))) { size_t n = strlen (dst); if (n < cwdlen) @@ -1031,7 +1031,7 @@ fillin: if (n == cwdlen) dst += cwdlen; else - dst += isdirsep (current_directory_name[cwdlen - 1]) ? cwdlen : cwdlen + 1; + dst += isdirsep (cwd_win32[cwdlen - 1]) ? cwdlen : cwdlen + 1; memmove (win32_path, dst, strlen (dst) + 1); if (!*win32_path) @@ -2279,10 +2279,10 @@ hash_path_name (unsigned long hash, const char *name) Otherwise the inodes same will differ depending on whether a file is referenced with an absolute value or relatively. */ - if (*name != '\\' && (current_directory_name == NULL || - get_current_directory_name ())) + if (*name != '\\' && (cwd_win32 == NULL || + get_cwd_win32 ())) { - hash = current_directory_hash; + hash = cwd_hash; if (name[0] == '.' && name[1] == '\0') return hash; hash = hash_path_name (hash, "\\"); @@ -2303,21 +2303,21 @@ hashit: } static int -get_current_directory_name () +get_cwd_win32 () { DWORD dlen, len; for (dlen = 256; ; dlen *= 2) { - current_directory_name = (char *) realloc (current_directory_name, dlen + 2); - if ((len = GetCurrentDirectoryA (dlen, current_directory_name)) < dlen) + cwd_win32 = (char *) realloc (cwd_win32, dlen + 2); + if ((len = GetCurrentDirectoryA (dlen, cwd_win32)) < dlen) break; } if (len == 0) __seterrno (); else - current_directory_hash = hash_path_name (0, current_directory_name); + cwd_hash = hash_path_name (0, cwd_win32); return len; } @@ -2330,16 +2330,16 @@ getcwd_inner (char *buf, size_t ulen, int posix_p) char *resbuf = NULL; size_t len = ulen; - if (current_directory_name == NULL && !get_current_directory_name ()) + if (cwd_win32 == NULL && !get_cwd_win32 ()) return NULL; if (!posix_p) { - if (strlen (current_directory_name) >= len) + if (strlen (cwd_win32) >= len) set_errno (ERANGE); else { - strcpy (buf, current_directory_name); + strcpy (buf, cwd_win32); resbuf = buf; } @@ -2347,13 +2347,13 @@ getcwd_inner (char *buf, size_t ulen, int posix_p) resbuf, resbuf ? resbuf : "", buf, len); return resbuf; } - else if (current_directory_posix_name != NULL) + else if (cwd_posix != NULL) { - if (strlen (current_directory_posix_name) >= len) + if (strlen (cwd_posix) >= len) set_errno (ERANGE); else { - strcpy (buf, current_directory_posix_name); + strcpy (buf, cwd_posix); resbuf = buf; } @@ -2362,19 +2362,19 @@ getcwd_inner (char *buf, size_t ulen, int posix_p) return resbuf; } - /* posix_p required and current_directory_posix_name == NULL */ + /* posix_p required and cwd_posix == NULL */ char temp[MAX_PATH]; /* Turn from Win32 style to our style. */ - cygwin_shared->mount.conv_to_posix_path (current_directory_name, temp, 0); + cygwin_shared->mount.conv_to_posix_path (cwd_win32, temp, 0); size_t tlen = strlen (temp); - current_directory_posix_name = (char *) realloc ( - current_directory_posix_name, tlen + 1); - if (current_directory_posix_name != NULL) - strcpy (current_directory_posix_name, temp); + cwd_posix = (char *) realloc ( + cwd_posix, tlen + 1); + if (cwd_posix != NULL) + strcpy (cwd_posix, temp); if (tlen >= ulen) { @@ -2425,6 +2425,7 @@ extern "C" int chdir (const char *dir) { + syscall_printf ("dir %s", dir); path_conv path (dir); if (path.error) @@ -2450,18 +2451,15 @@ chdir (const char *dir) __seterrno (); /* Clear the cache until we need to retrieve the directory again. */ - if (current_directory_name != NULL) - { - free (current_directory_name); - current_directory_name = NULL; - } - if (current_directory_posix_name != NULL) - { - free (current_directory_posix_name); - current_directory_posix_name = NULL; - } + free (cwd_win32); + cwd_win32 = strdup (path);; + + char pathbuf[MAX_PATH]; + (void) normalize_posix_path (cwd_posix, dir, pathbuf); + free (cwd_posix); + cwd_posix = strdup (pathbuf); - syscall_printf ("%d = chdir (%s) (dos %s)", res, dir, native_dir); + syscall_printf ("%d = chdir (%s )", res, cwd_posix, cwd_win32); return res; } diff --git a/winsup/cygwin/thread.h b/winsup/cygwin/thread.h index e9e0c82..e16d3ce 100644 --- a/winsup/cygwin/thread.h +++ b/winsup/cygwin/thread.h @@ -75,9 +75,9 @@ struct _winsup_t /* path.cc */ struct mntent _ret; - char *_current_directory_name; - char *_current_directory_posix_name; - unsigned long _current_directory_hash; + char *_cwd_win32; + char *_cwd_posix; + unsigned long _cwd_hash; int _iteration; /* strerror */ -- cgit v1.1