From 9a089f21ea4862705c6c996502c089b8d18fc833 Mon Sep 17 00:00:00 2001 From: Christopher Faylor Date: Sun, 28 Jan 2001 06:23:42 +0000 Subject: [PATCH] * cygheap.cc (init_cheap): Move username initialization. (cygheap_init): Here. * shared_info.h (mount_info): Add a sys_mount_table_counter field. (shared_info): Ditto. * path.cc (mount_info::conv_to_win32_path): Check that our mount table is in sync with the system mount table and reinitialize it if not. (mount_info::add_reg_mount): Bump sys_mount_table counters if the system mount table changes. (mount_info::del_reg_mount): Ditto. (mount_info::write_cygdrive_info_to_registry): Ditto. (mount_info::remove_cygdrive_info_from_registry): Ditto. --- winsup/cygwin/ChangeLog | 14 ++++++++++++++ winsup/cygwin/cygheap.cc | 16 ++++++++-------- winsup/cygwin/path.cc | 31 ++++++++++++++++++++++++++----- winsup/cygwin/shared_info.h | 5 +++-- 4 files changed, 51 insertions(+), 15 deletions(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index b04a6f875..f9c7c0ebc 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,17 @@ +Sun Jan 28 01:18:22 2001 Christopher Faylor + + * cygheap.cc (init_cheap): Move username initialization. + (cygheap_init): Here. + * shared_info.h (mount_info): Add a sys_mount_table_counter field. + (shared_info): Ditto. + * path.cc (mount_info::conv_to_win32_path): Check that our mount table + is in sync with the system mount table and reinitialize it if not. + (mount_info::add_reg_mount): Bump sys_mount_table counters if the + system mount table changes. + (mount_info::del_reg_mount): Ditto. + (mount_info::write_cygdrive_info_to_registry): Ditto. + (mount_info::remove_cygdrive_info_from_registry): Ditto. + Sun Jan 28 00:28:30 2001 Christopher Faylor Throughout, change 'cygwin_shared.mount' to 'mount_table'. diff --git a/winsup/cygwin/cygheap.cc b/winsup/cygwin/cygheap.cc index c9081aa5d..10c16d1a2 100644 --- a/winsup/cygwin/cygheap.cc +++ b/winsup/cygwin/cygheap.cc @@ -32,14 +32,6 @@ init_cheap () if (!cygheap) api_fatal ("Couldn't reserve space for cygwin's heap, %E"); cygheap_max = cygheap + 1; - - char username[MAX_USER_NAME]; - DWORD username_len = MAX_USER_NAME; - - if (!GetUserName (username, &username_len)) - cygheap->user.set_name ("unknown"); - else - cygheap->user.set_name (username); } #define pagetrunc(x) ((void *) (((DWORD) (x)) & ~(4096 - 1))) @@ -75,6 +67,14 @@ cygheap_init () { cygheap_protect = new_muto (FALSE, "cygheap_protect"); _csbrk (0); + + char username[MAX_USER_NAME]; + DWORD username_len = MAX_USER_NAME; + + if (!GetUserName (username, &username_len)) + cygheap->user.set_name ("unknown"); + else + cygheap->user.set_name (username); } /* Copyright (C) 1997, 2000 DJ Delorie */ diff --git a/winsup/cygwin/path.cc b/winsup/cygwin/path.cc index 7bdf770da..20553920c 100644 --- a/winsup/cygwin/path.cc +++ b/winsup/cygwin/path.cc @@ -979,6 +979,11 @@ mount_info::conv_to_win32_path (const char *src_path, char *win32_path, char *full_win32_path, DWORD &devn, int &unit, unsigned *flags) { + while (sys_mount_table_counter < cygwin_shared->sys_mount_table_counter) + { + init (); + sys_mount_table_counter++; + } int src_path_len = strlen (src_path); int trailing_slash_p = (src_path_len > 1 && SLASH_P (src_path[src_path_len - 1])); @@ -1485,6 +1490,9 @@ mount_info::add_reg_mount (const char * native_path, const char * posix_path, un if (res != ERROR_SUCCESS) goto err; res = subkey.set_int ("flags", mountflags); + + sys_mount_table_counter++; + cygwin_shared->sys_mount_table_counter++; } return 0; /* Success! */ @@ -1502,7 +1510,7 @@ mount_info::del_reg_mount (const char * posix_path, unsigned flags) { int res; - if ((flags & MOUNT_SYSTEM) == 0) /* Delete from user registry */ + if (!(flags & MOUNT_SYSTEM)) /* Delete from user registry */ { reg_key reg_user (KEY_ALL_ACCESS, CYGWIN_INFO_CYGWIN_MOUNT_REGISTRY_NAME, NULL); @@ -1510,6 +1518,8 @@ mount_info::del_reg_mount (const char * posix_path, unsigned flags) } else /* Delete from system registry */ { + sys_mount_table_counter++; + cygwin_shared->sys_mount_table_counter++; reg_key reg_sys (HKEY_LOCAL_MACHINE, KEY_ALL_ACCESS, "SOFTWARE", CYGWIN_INFO_CYGNUS_REGISTRY_NAME, CYGWIN_INFO_CYGWIN_REGISTRY_NAME, @@ -1586,6 +1596,12 @@ mount_info::write_cygdrive_info_to_registry (const char *cygdrive_prefix, unsign /* Determine whether to modify user or system cygdrive path prefix. */ HKEY top = (flags & MOUNT_SYSTEM) ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; + if (flags & MOUNT_SYSTEM) + { + sys_mount_table_counter++; + cygwin_shared->sys_mount_table_counter++; + } + /* reg_key for user path prefix in HKEY_CURRENT_USER or system path prefix in HKEY_LOCAL_MACHINE. */ reg_key r (top, KEY_ALL_ACCESS, "SOFTWARE", @@ -1621,8 +1637,7 @@ mount_info::write_cygdrive_info_to_registry (const char *cygdrive_prefix, unsign appropriate: 1. setting user path prefix, or 2. overwriting (a previous) system path prefix */ - if ((flags & MOUNT_SYSTEM) == 0 || - (mount_table->cygdrive_flags & MOUNT_SYSTEM) != 0) + if (!(flags & MOUNT_SYSTEM) || (mount_table->cygdrive_flags & MOUNT_SYSTEM)) { slashify (cygdrive_prefix, mount_table->cygdrive, 1); mount_table->cygdrive_flags = flags; @@ -1638,6 +1653,12 @@ mount_info::remove_cygdrive_info_from_registry (const char *cygdrive_prefix, uns /* Determine whether to modify user or system cygdrive path prefix. */ HKEY top = (flags & MOUNT_SYSTEM) ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; + if (flags & MOUNT_SYSTEM) + { + sys_mount_table_counter++; + cygwin_shared->sys_mount_table_counter++; + } + /* reg_key for user path prefix in HKEY_CURRENT_USER or system path prefix in HKEY_LOCAL_MACHINE. */ reg_key r (top, KEY_ALL_ACCESS, "SOFTWARE", @@ -1728,7 +1749,7 @@ sort_by_posix_name (const void *a, const void *b) if (res == 0) { /* need to select between user and system mount to same POSIX path */ - if ((bp->flags & MOUNT_SYSTEM) == 0) /* user mount */ + if (!(bp->flags & MOUNT_SYSTEM)) /* user mount */ return 1; else return -1; @@ -1764,7 +1785,7 @@ sort_by_native_name (const void *a, const void *b) if (res == 0) { /* need to select between user and system mount to same POSIX path */ - if ((bp->flags & MOUNT_SYSTEM) == 0) /* user mount */ + if (!(bp->flags & MOUNT_SYSTEM)) /* user mount */ return 1; else return -1; diff --git a/winsup/cygwin/shared_info.h b/winsup/cygwin/shared_info.h index 047c7ffcd..13388a4d1 100644 --- a/winsup/cygwin/shared_info.h +++ b/winsup/cygwin/shared_info.h @@ -47,6 +47,7 @@ class mount_info { public: DWORD version; + DWORD sys_mount_table_counter; int nmounts; mount_item mount[MAX_MOUNTS]; @@ -138,14 +139,14 @@ public: class shared_info { DWORD inited; - public: int heap_chunk_in_mb; - unsigned heap_chunk_size (void); + DWORD sys_mount_table_counter; tty_list tty; delqueue_list delqueue; void initialize (void); + unsigned heap_chunk_size (void); }; extern shared_info *cygwin_shared;