* cygcheck.cc (cygwin_dll_path): New global variable.
(load_cygwin): Fetch cygwin DLL path and store in cygwin_dll_path. * strace.cc: Full ditto. * path.cc (read_mounts): First use the path stored in cygwin_dll_path, if available. Then fall back to fetching own path. Add comment. Drop printing warnings since they look funny in strace output.
This commit is contained in:
parent
44a019897f
commit
b5f48aa961
|
@ -1,3 +1,12 @@
|
||||||
|
2009-11-04 Corinna Vinschen <corinna@vinschen.de>
|
||||||
|
|
||||||
|
* cygcheck.cc (cygwin_dll_path): New global variable.
|
||||||
|
(load_cygwin): Fetch cygwin DLL path and store in cygwin_dll_path.
|
||||||
|
* strace.cc: Full ditto.
|
||||||
|
* path.cc (read_mounts): First use the path stored in cygwin_dll_path,
|
||||||
|
if available. Then fall back to fetching own path. Add comment.
|
||||||
|
Drop printing warnings since they look funny in strace output.
|
||||||
|
|
||||||
2009-11-04 Corinna Vinschen <corinna@vinschen.de>
|
2009-11-04 Corinna Vinschen <corinna@vinschen.de>
|
||||||
|
|
||||||
* path.cc (read_mounts): First get installation path from own path.
|
* path.cc (read_mounts): First get installation path from own path.
|
||||||
|
|
|
@ -2270,6 +2270,7 @@ nuke (char *ev)
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
unsigned long (*cygwin_internal) (int, ...);
|
unsigned long (*cygwin_internal) (int, ...);
|
||||||
|
WCHAR cygwin_dll_path[32768];
|
||||||
};
|
};
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -2279,6 +2280,7 @@ load_cygwin (int& argc, char **&argv)
|
||||||
|
|
||||||
if (!(h = LoadLibrary ("cygwin1.dll")))
|
if (!(h = LoadLibrary ("cygwin1.dll")))
|
||||||
return;
|
return;
|
||||||
|
GetModuleFileNameW (h, cygwin_dll_path, 32768);
|
||||||
if ((cygwin_internal = (DWORD (*) (int, ...)) GetProcAddress (h, "cygwin_internal")))
|
if ((cygwin_internal = (DWORD (*) (int, ...)) GetProcAddress (h, "cygwin_internal")))
|
||||||
{
|
{
|
||||||
char **av = (char **) cygwin_internal (CW_ARGV);
|
char **av = (char **) cygwin_internal (CW_ARGV);
|
||||||
|
|
|
@ -556,6 +556,8 @@ mnt_sort (const void *a, const void *b)
|
||||||
return strcmp (ma->posix, mb->posix);
|
return strcmp (ma->posix, mb->posix);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extern "C" WCHAR cygwin_dll_path[];
|
||||||
|
|
||||||
static void
|
static void
|
||||||
read_mounts ()
|
read_mounts ()
|
||||||
{
|
{
|
||||||
|
@ -567,6 +569,7 @@ read_mounts ()
|
||||||
DWORD len;
|
DWORD len;
|
||||||
WCHAR path[32768];
|
WCHAR path[32768];
|
||||||
PWCHAR path_end;
|
PWCHAR path_end;
|
||||||
|
HMODULE h;
|
||||||
|
|
||||||
for (mnt_t *m1 = mount_table; m1->posix; m1++)
|
for (mnt_t *m1 = mount_table; m1->posix; m1++)
|
||||||
{
|
{
|
||||||
|
@ -577,9 +580,16 @@ read_mounts ()
|
||||||
}
|
}
|
||||||
max_mount_entry = 0;
|
max_mount_entry = 0;
|
||||||
|
|
||||||
/* First check where cygcheck is living itself and try to fetch installation
|
/* First fetch the cygwin1.dll path from the LoadLibrary call in load_cygwin.
|
||||||
path from here. Does cygwin1.dll exist in the same path? */
|
This utilizes the DLL search order to find a matching cygwin1.dll and to
|
||||||
if (!GetModuleFileNameW (NULL, path, 32768))
|
compute the installation path from that DLL's path. */
|
||||||
|
if (cygwin_dll_path[0])
|
||||||
|
wcscpy (path, cygwin_dll_path);
|
||||||
|
/* If we can't load cygwin1.dll, check where cygcheck is living itself and
|
||||||
|
try to fetch installation path from here. Does cygwin1.dll exist in the
|
||||||
|
same path? This should only kick in if the cygwin1.dll in the same path
|
||||||
|
has been made non-executable for the current user accidentally. */
|
||||||
|
else if (!GetModuleFileNameW (NULL, path, 32768))
|
||||||
return;
|
return;
|
||||||
path_end = wcsrchr (path, L'\\');
|
path_end = wcsrchr (path, L'\\');
|
||||||
if (path_end)
|
if (path_end)
|
||||||
|
@ -612,21 +622,11 @@ read_mounts ()
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (ret == ERROR_SUCCESS)
|
if (ret == ERROR_SUCCESS)
|
||||||
{
|
path_end = wcschr (path, L'\0');
|
||||||
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 we can't fetch an installation dir, bail out. */
|
||||||
if (!path_end)
|
if (!path_end)
|
||||||
{
|
return;
|
||||||
printf ("\n"
|
|
||||||
"Warning! Could not generate mount table since no valid installation path\n"
|
|
||||||
"could be found.\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
*path_end = L'\0';
|
*path_end = L'\0';
|
||||||
|
|
||||||
from_fstab (false, path, path_end);
|
from_fstab (false, path, path_end);
|
||||||
|
|
|
@ -264,6 +264,7 @@ ctrl_c (DWORD)
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
unsigned long (*cygwin_internal) (int, ...);
|
unsigned long (*cygwin_internal) (int, ...);
|
||||||
|
WCHAR cygwin_dll_path[32768];
|
||||||
};
|
};
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
@ -282,6 +283,7 @@ load_cygwin ()
|
||||||
errno = ENOENT;
|
errno = ENOENT;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
GetModuleFileNameW (h, cygwin_dll_path, 32768);
|
||||||
if (!(cygwin_internal = (DWORD (*) (int, ...)) GetProcAddress (h, "cygwin_internal")))
|
if (!(cygwin_internal = (DWORD (*) (int, ...)) GetProcAddress (h, "cygwin_internal")))
|
||||||
{
|
{
|
||||||
errno = ENOSYS;
|
errno = ENOSYS;
|
||||||
|
|
Loading…
Reference in New Issue