diff options
Diffstat (limited to 'winsup/cygwin')
-rw-r--r-- | winsup/cygwin/cygheap.h | 1 | ||||
-rw-r--r-- | winsup/cygwin/external.cc | 19 | ||||
-rw-r--r-- | winsup/cygwin/fhandler_console.cc | 2 | ||||
-rw-r--r-- | winsup/cygwin/include/sys/cygwin.h | 4 | ||||
-rw-r--r-- | winsup/cygwin/path.cc | 23 | ||||
-rw-r--r-- | winsup/cygwin/shared.cc | 11 | ||||
-rw-r--r-- | winsup/cygwin/shared_info.h | 4 |
7 files changed, 43 insertions, 21 deletions
diff --git a/winsup/cygwin/cygheap.h b/winsup/cygwin/cygheap.h index 7f0f04f..16f22c5 100644 --- a/winsup/cygwin/cygheap.h +++ b/winsup/cygwin/cygheap.h @@ -165,6 +165,7 @@ struct init_cygheap HANDLE shared_h; HANDLE console_h; HANDLE etc_changed_h; + char *cygwin_regname; cwdstuff cwd; dtable fdtab; diff --git a/winsup/cygwin/external.cc b/winsup/cygwin/external.cc index a4b81be..5780647 100644 --- a/winsup/cygwin/external.cc +++ b/winsup/cygwin/external.cc @@ -11,6 +11,7 @@ Cygwin license. Please consult the file "CYGWIN_LICENSE" for details. */ #include "winsup.h" +#include <errno.h> #include "security.h" #include "fhandler.h" #include "sync.h" @@ -20,6 +21,11 @@ details. */ #include "shared_info.h" #include "cygwin_version.h" #include "perprocess.h" +#include "cygerrno.h" +#include "fhandler.h" +#include "path.h" +#include "dtable.h" +#include "cygheap.h" static external_pinfo * fillout_pinfo (pid_t pid, int winpid) @@ -175,6 +181,19 @@ cygwin_internal (cygwin_getinfo_types t, ...) return get_cygdrive_info (user, system, user_flags, system_flags); } + case CW_SET_CYGWIN_REGISTRY_NAME: + { +# define cr ((char *) arg) + if (check_null_empty_str_errno (cr)) + return (DWORD) NULL; + cygheap->cygwin_regname = (char *) crealloc (cygheap->cygwin_regname, + strlen (cr) + 1); + strcpy (cygheap->cygwin_regname, cr); + case CW_GET_CYGWIN_REGISTRY_NAME: + return (DWORD) cygheap->cygwin_regname; +# undef cr + } + default: return (DWORD) -1; } diff --git a/winsup/cygwin/fhandler_console.cc b/winsup/cygwin/fhandler_console.cc index a9b7bff..504d245 100644 --- a/winsup/cygwin/fhandler_console.cc +++ b/winsup/cygwin/fhandler_console.cc @@ -104,7 +104,7 @@ get_tty_stuff (int flags = 0) if (shared_console_info) return shared_console_info; - shared_console_info = (tty_min *) open_shared (NULL, cygheap->console_h, + shared_console_info = (tty_min *) open_shared (NULL, 0, cygheap->console_h, sizeof (*shared_console_info), NULL); ProtectHandle (cygheap->console_h); diff --git a/winsup/cygwin/include/sys/cygwin.h b/winsup/cygwin/include/sys/cygwin.h index 1d53f63..a4a8cf6 100644 --- a/winsup/cygwin/include/sys/cygwin.h +++ b/winsup/cygwin/include/sys/cygwin.h @@ -64,7 +64,9 @@ typedef enum CW_GET_CYGDRIVE_PREFIXES, CW_GETPINFO_FULL, CW_INIT_EXCEPTIONS, - CW_GET_CYGDRIVE_INFO + CW_GET_CYGDRIVE_INFO, + CW_SET_CYGWIN_REGISTRY_NAME, + CW_GET_CYGWIN_REGISTRY_NAME } cygwin_getinfo_types; #define CW_NEXTPID 0x80000000 // or with pid to get next one diff --git a/winsup/cygwin/path.cc b/winsup/cygwin/path.cc index 066ef2e..ad3008c 100644 --- a/winsup/cygwin/path.cc +++ b/winsup/cygwin/path.cc @@ -107,6 +107,8 @@ struct symlink_info int pcheck_case = PCHECK_RELAXED; /* Determines the case check behaviour. */ +#define CYGWIN_REGNAME (cygheap->cygwin_regname ?: CYGWIN_INFO_CYGWIN_REGISTRY_NAME) + /* Determine if path prefix matches current cygdrive */ #define iscygdrive(path) \ (path_prefix_p (mount_table->cygdrive, (path), mount_table->cygdrive_len)) @@ -1711,8 +1713,7 @@ mount_info::from_registry () /* Then read mounts from system-wide mount table. */ reg_key r1 (HKEY_LOCAL_MACHINE, KEY_READ, "SOFTWARE", - CYGWIN_INFO_CYGNUS_REGISTRY_NAME, - CYGWIN_INFO_CYGWIN_REGISTRY_NAME, + CYGWIN_INFO_CYGNUS_REGISTRY_NAME, CYGWIN_REGNAME, CYGWIN_INFO_CYGWIN_MOUNT_REGISTRY_NAME, NULL); read_mounts (r1); @@ -1757,8 +1758,7 @@ mount_info::add_reg_mount (const char * native_path, const char * posix_path, un { /* reg_key for system mounts in HKEY_LOCAL_MACHINE. */ reg_key reg_sys (HKEY_LOCAL_MACHINE, KEY_ALL_ACCESS, "SOFTWARE", - CYGWIN_INFO_CYGNUS_REGISTRY_NAME, - CYGWIN_INFO_CYGWIN_REGISTRY_NAME, + CYGWIN_INFO_CYGNUS_REGISTRY_NAME, CYGWIN_REGNAME, CYGWIN_INFO_CYGWIN_MOUNT_REGISTRY_NAME, NULL); @@ -1806,8 +1806,7 @@ mount_info::del_reg_mount (const char * posix_path, unsigned flags) 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, + CYGWIN_INFO_CYGNUS_REGISTRY_NAME, CYGWIN_REGNAME, CYGWIN_INFO_CYGWIN_MOUNT_REGISTRY_NAME, NULL); res = reg_sys.kill (posix_path); @@ -1839,8 +1838,7 @@ mount_info::read_cygdrive_info_from_registry () /* reg_key for system path prefix in HKEY_LOCAL_MACHINE. */ reg_key r2 (HKEY_LOCAL_MACHINE, KEY_READ, "SOFTWARE", - CYGWIN_INFO_CYGNUS_REGISTRY_NAME, - CYGWIN_INFO_CYGWIN_REGISTRY_NAME, + CYGWIN_INFO_CYGNUS_REGISTRY_NAME, CYGWIN_REGNAME, CYGWIN_INFO_CYGWIN_MOUNT_REGISTRY_NAME, NULL); @@ -1890,8 +1888,7 @@ mount_info::write_cygdrive_info_to_registry (const char *cygdrive_prefix, unsign /* 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", - CYGWIN_INFO_CYGNUS_REGISTRY_NAME, - CYGWIN_INFO_CYGWIN_REGISTRY_NAME, + CYGWIN_INFO_CYGNUS_REGISTRY_NAME, CYGWIN_REGNAME, CYGWIN_INFO_CYGWIN_MOUNT_REGISTRY_NAME, NULL); @@ -1947,8 +1944,7 @@ mount_info::remove_cygdrive_info_from_registry (const char *cygdrive_prefix, uns /* 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", - CYGWIN_INFO_CYGNUS_REGISTRY_NAME, - CYGWIN_INFO_CYGWIN_REGISTRY_NAME, + CYGWIN_INFO_CYGNUS_REGISTRY_NAME, CYGWIN_REGNAME, CYGWIN_INFO_CYGWIN_MOUNT_REGISTRY_NAME, NULL); @@ -1980,8 +1976,7 @@ mount_info::get_cygdrive_info (char *user, char *system, char* user_flags, /* Get the system path prefix from HKEY_LOCAL_MACHINE. */ reg_key r2 (HKEY_LOCAL_MACHINE, KEY_READ, "SOFTWARE", - CYGWIN_INFO_CYGNUS_REGISTRY_NAME, - CYGWIN_INFO_CYGWIN_REGISTRY_NAME, + CYGWIN_INFO_CYGNUS_REGISTRY_NAME, CYGWIN_REGNAME, CYGWIN_INFO_CYGWIN_MOUNT_REGISTRY_NAME, NULL); int res2 = r2.get_string (CYGWIN_INFO_CYGDRIVE_PREFIX, system, MAX_PATH, ""); diff --git a/winsup/cygwin/shared.cc b/winsup/cygwin/shared.cc index 7e155eb..0158487 100644 --- a/winsup/cygwin/shared.cc +++ b/winsup/cygwin/shared.cc @@ -55,7 +55,7 @@ shared_name (const char *str, int num) } void * __stdcall -open_shared (const char *name, HANDLE &shared_h, DWORD size, void *addr) +open_shared (const char *name, int n, HANDLE &shared_h, DWORD size, void *addr) { void *shared; @@ -66,7 +66,7 @@ open_shared (const char *name, HANDLE &shared_h, DWORD size, void *addr) mapname = NULL; else { - mapname = shared_name (name, 0); + mapname = shared_name (name, n); shared_h = OpenFileMappingA (FILE_MAP_READ | FILE_MAP_WRITE, TRUE, mapname); } @@ -127,6 +127,7 @@ memory_init () /* Initialize general shared memory */ HANDLE shared_h = cygheap ? cygheap->shared_h : NULL; cygwin_shared = (shared_info *) open_shared ("shared", + CYGWIN_VERSION_SHARED_DATA, shared_h, sizeof (*cygwin_shared), cygwin_shared_address); @@ -151,7 +152,8 @@ memory_init () ProtectHandle (cygheap->shared_h); heap_init (); - mount_table = (mount_info *) open_shared (user_name, cygwin_mount_h, + mount_table = (mount_info *) open_shared (user_name, MOUNT_VERSION, + cygwin_mount_h, sizeof (mount_info), 0); debug_printf ("opening mount table for '%s' at %p", cygheap->user.name (), mount_table_address); @@ -165,6 +167,9 @@ memory_init () debug_printf ("initializing mount table"); mount_table->init (); /* Initialize the mount table. */ } + else if (mount_table->version != MOUNT_VERSION) + multiple_cygwin_die (); + } void __stdcall diff --git a/winsup/cygwin/shared_info.h b/winsup/cygwin/shared_info.h index 088b3f9..46b53c8 100644 --- a/winsup/cygwin/shared_info.h +++ b/winsup/cygwin/shared_info.h @@ -40,7 +40,7 @@ class mount_item scheme should be satisfactory for a long while yet. */ #define MAX_MOUNTS 30 -#define MOUNT_VERSION 0x01010103 +#define MOUNT_VERSION 27 // increment when mount table changes class reg_key; class mount_info @@ -158,4 +158,4 @@ void __stdcall shared_terminate (void); #define cygheap_address shared_align_past ((mount_info *) shared_align_past (cygwin_shared)) char *__stdcall shared_name (const char *, int); -void *__stdcall open_shared (const char *name, HANDLE &shared_h, DWORD size, void *addr); +void *__stdcall open_shared (const char *name, int n, HANDLE &shared_h, DWORD size, void *addr); |