diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2009-11-04 15:47:29 +0000 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2009-11-04 15:47:29 +0000 |
commit | 44a019897fde5a5fbbd2a36c8a6c99066ec18d42 (patch) | |
tree | 37fad9d61e4e54fb71c9cd0bf7f8661cdda39b0d /winsup/utils | |
parent | 73f2ecd19dea4a9c08f131af9a3dd2af6341d6b0 (diff) | |
download | cygnal-44a019897fde5a5fbbd2a36c8a6c99066ec18d42.tar.gz cygnal-44a019897fde5a5fbbd2a36c8a6c99066ec18d42.tar.bz2 cygnal-44a019897fde5a5fbbd2a36c8a6c99066ec18d42.zip |
* path.cc (read_mounts): First get installation path from own path.
Check if cygwin1.dll exists in same directory. Only if not, try to
get installation path from setup registry key. Add ample warnings.
Diffstat (limited to 'winsup/utils')
-rw-r--r-- | winsup/utils/ChangeLog | 6 | ||||
-rw-r--r-- | winsup/utils/path.cc | 63 |
2 files changed, 49 insertions, 20 deletions
diff --git a/winsup/utils/ChangeLog b/winsup/utils/ChangeLog index c87d2cae3..8f8ffe889 100644 --- a/winsup/utils/ChangeLog +++ b/winsup/utils/ChangeLog @@ -1,5 +1,11 @@ 2009-11-04 Corinna Vinschen <corinna@vinschen.de> + * path.cc (read_mounts): First get installation path from own path. + Check if cygwin1.dll exists in same directory. Only if not, try to + get installation path from setup registry key. Add ample warnings. + +2009-11-04 Corinna Vinschen <corinna@vinschen.de> + * Makefile.in (cygpath.exe): Add -fno-threadsafe-statics to CXXFLAGS. 2009-10-31 Corinna Vinschen <corinna@vinschen.de> diff --git a/winsup/utils/path.cc b/winsup/utils/path.cc index 63c2ccc43..9495fbf44 100644 --- a/winsup/utils/path.cc +++ b/winsup/utils/path.cc @@ -577,33 +577,56 @@ read_mounts () } max_mount_entry = 0; - for (int i = 0; i < 2; ++i) - if ((ret = RegOpenKeyExW (i ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER, - L"Software\\Cygwin\\setup", 0, - KEY_READ, &setup_key)) == ERROR_SUCCESS) - { - len = 32768 * sizeof (WCHAR); - ret = RegQueryValueExW (setup_key, L"rootdir", NULL, NULL, - (PBYTE) path, &len); - RegCloseKey (setup_key); - if (ret == ERROR_SUCCESS) - break; - } - if (ret == ERROR_SUCCESS) - path_end = wcschr (path, L'\0'); - else + /* First check where cygcheck is living itself and try to fetch installation + path from here. Does cygwin1.dll exist in the same path? */ + if (!GetModuleFileNameW (NULL, path, 32768)) + return; + path_end = wcsrchr (path, L'\\'); + if (path_end) { - if (!GetModuleFileNameW (NULL, path, 32768)) - return; - path_end = wcsrchr (path, L'\\'); - if (path_end) + wcscpy (path_end, L"\\cygwin1.dll"); + DWORD attr = GetFileAttributesW (path); + if (attr == (DWORD) -1 + || (attr & (FILE_ATTRIBUTE_DIRECTORY | FILE_ATTRIBUTE_REPARSE_POINT))) + path_end = NULL; + else { *path_end = L'\0'; path_end = wcsrchr (path, L'\\'); } } + /* If we can't create a valid installation dir from that, try to fetch + the installation dir from the setup registry key. */ if (!path_end) - return; + { + for (int i = 0; i < 2; ++i) + if ((ret = RegOpenKeyExW (i ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER, + L"Software\\Cygwin\\setup", 0, + KEY_READ, &setup_key)) == ERROR_SUCCESS) + { + len = 32768 * sizeof (WCHAR); + ret = RegQueryValueExW (setup_key, L"rootdir", NULL, NULL, + (PBYTE) path, &len); + RegCloseKey (setup_key); + if (ret == ERROR_SUCCESS) + break; + } + if (ret == ERROR_SUCCESS) + { + printf ("\n" +"Warning! Computing mount points from setup registry key. Mount points might\n" +"be wrong if you have multiple Cygwin installations on this machine.\n"); + path_end = wcschr (path, L'\0'); + } + } + /* If we can't fetch an installation dir, bail out. */ + if (!path_end) + { + printf ("\n" +"Warning! Could not generate mount table since no valid installation path\n" +"could be found.\n"); + return; + } *path_end = L'\0'; from_fstab (false, path, path_end); |