* cygheap.cc (creturn): Reorganize to avoid a new compiler warning/error.
* dtable.cc (handle_to_fn): Ditto. * fhandler_console.cc (fhandler_console::read): Ditto. (fhandler_console::scroll_screen): Ditto. (dev_console::set_color): Ditto. * fhandler_dsp.cc (fhandler_dev_dsp::write): Ditto. (fhandler_dev_dsp::read): Ditto. * fhandler_tape.cc (mtinfo_drive::get_status): Ditto. * hookapi.cc (find_first_notloaded_dll): Ditto. * mmap.cc (msync): Ditto. * pipe.cc (pipesync::pipesync): Ditto. * sec_acl.cc (getace): Ditto. * sec_auth.cc (create_token): Ditto. (lsaauth): Ditto. * select.cc (peek_pipe): Ditto. * spawn.cc (av::fixup): Ditto. * syscalls.cc (popen): Ditto. * tty.cc (tty::init_session): Ditto. * uinfo.cc (pwdgrp::load): Ditto. * fhandler.cc (fhandler_base::setup_overlapped): Ditto. (fhandler_base::wait_overlapped): Rename second use of res variable to wres or errors are not returned correctly. * dcrt0.cc: Remove obsolete variable. * dll_init.cc (release_upto): Fix typo involving incorrect use of '|'. * fhandler_disk_file.cc (fhandler_base::fstat_by_handle): Avoid a compiler warning regarding coercing type-punned variables. (fhandler_base::fstat_by_name): Ditto. fhandler_fifo.cc (fhandler_fifo::open_nonserver): Fix = vs. == typo. (fhandler_fifo::wait): Add all conditions to switch statement to avoid a compiler warning. * fhandler_process.cc: Avoid unneeded initialization of variables to zero. (fhandler_socket::listen): Add braces around initializer. * flock.cc (inode_t::get_all_locks_list): Reorganize to avoid a compiler warning. Fix problem with EWOULDBLOCK error return. * path.cc (GUID_shortcut): Use braces around struct initializer. (cygwin_conv_path): Reorganize to avoid a compiler warning. * random.cc (dummy): Mark variable as volatile to avoid a "used uninitialized" warning. * libc/getopt.c: Mark some variables as dllexport although gcc doesn't seem to do the right thing with them. * libc/minires-os-if.c (get_registry_dns_items): Coerce some function arguments to avoid a compiler warning.
This commit is contained in:
@@ -853,124 +853,117 @@ handle_to_fn (HANDLE h, char *posix_fn)
|
||||
|
||||
NtQueryObject (h, ObjectNameInformation, &dummy_oni, sizeof (dummy_oni), &len);
|
||||
if (!len)
|
||||
debug_printf ("NtQueryObject failed 1");
|
||||
else
|
||||
{
|
||||
debug_printf ("NtQueryObject failed 1");
|
||||
goto unknown;
|
||||
}
|
||||
OBJECT_NAME_INFORMATION *ntfn = (OBJECT_NAME_INFORMATION *) alloca (len + sizeof (WCHAR));
|
||||
NTSTATUS res = NtQueryObject (h, ObjectNameInformation, ntfn, len, NULL);
|
||||
|
||||
OBJECT_NAME_INFORMATION *ntfn = (OBJECT_NAME_INFORMATION *) alloca (len + sizeof (WCHAR));
|
||||
NTSTATUS res = NtQueryObject (h, ObjectNameInformation, ntfn, len, NULL);
|
||||
|
||||
if (!NT_SUCCESS (res))
|
||||
{
|
||||
debug_printf ("NtQueryObject failed 2");
|
||||
goto unknown;
|
||||
}
|
||||
|
||||
// NT seems to do this on an unopened file
|
||||
if (!ntfn->Name.Buffer)
|
||||
{
|
||||
debug_printf ("nt->Name.Buffer == NULL");
|
||||
goto unknown;
|
||||
}
|
||||
|
||||
WCHAR *w32 = ntfn->Name.Buffer;
|
||||
size_t w32len = ntfn->Name.Length / sizeof (WCHAR);
|
||||
w32[w32len] = L'\0';
|
||||
|
||||
if (wcscasecmp (w32, DEV_NULL) == 0)
|
||||
{
|
||||
strcpy (posix_fn, "/dev/null");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (wcsncasecmp (w32, DEV_NAMED_PIPE, DEV_NAMED_PIPE_LEN) == 0)
|
||||
{
|
||||
w32 += DEV_NAMED_PIPE_LEN;
|
||||
if (wcsncmp (w32, L"cygwin-", WCLEN (L"cygwin-")) != 0)
|
||||
return false;
|
||||
w32 += WCLEN (L"cygwin-");
|
||||
bool istty = wcsncmp (w32, L"tty", WCLEN (L"tty")) == 0;
|
||||
if (istty)
|
||||
decode_tty (posix_fn, w32 + WCLEN (L"tty"));
|
||||
else if (wcsncmp (w32, L"pipe", WCLEN (L"pipe")) == 0)
|
||||
strcpy (posix_fn, "/dev/pipe");
|
||||
return istty;
|
||||
}
|
||||
|
||||
|
||||
WCHAR fnbuf[64 * 1024];
|
||||
if (wcsncasecmp (w32, DEVICE_PREFIX, DEVICE_PREFIX_LEN) != 0
|
||||
|| !QueryDosDeviceW (NULL, fnbuf, sizeof (fnbuf)))
|
||||
{
|
||||
sys_wcstombs (posix_fn, NT_MAX_PATH, w32, w32len);
|
||||
return false;
|
||||
}
|
||||
|
||||
for (WCHAR *s = fnbuf; *s; s = wcschr (s, '\0') + 1)
|
||||
{
|
||||
WCHAR device[NT_MAX_PATH];
|
||||
if (!QueryDosDeviceW (s, device, sizeof (device)))
|
||||
continue;
|
||||
if (wcschr (s, ':') == NULL)
|
||||
continue;
|
||||
WCHAR *q = wcsrchr (device, ';');
|
||||
if (q)
|
||||
{
|
||||
WCHAR *r = wcschr (q, '\\');
|
||||
if (r)
|
||||
wcscpy (q, r + 1);
|
||||
}
|
||||
int devlen = wcslen (device);
|
||||
if (device[devlen - 1] == L'\\')
|
||||
device[--devlen] = L'\0';
|
||||
if (devlen < maxmatchlen)
|
||||
continue;
|
||||
if (wcsncmp (device, w32, devlen) != 0||
|
||||
(w32[devlen] != L'\0' && w32[devlen] != L'\\'))
|
||||
continue;
|
||||
maxmatchlen = devlen;
|
||||
maxmatchdos = s;
|
||||
debug_printf ("current match '%W' = '%W'\n", s, device);
|
||||
}
|
||||
|
||||
if (maxmatchlen)
|
||||
{
|
||||
WCHAR *p = wcschr (w32 + DEVICE_PREFIX_LEN, L'\\');
|
||||
size_t n = wcslen (maxmatchdos);
|
||||
WCHAR ch;
|
||||
if (!p)
|
||||
ch = L'\0';
|
||||
if (!NT_SUCCESS (res))
|
||||
debug_printf ("NtQueryObject failed 2");
|
||||
// NT seems to do this on an unopened file
|
||||
else if (!ntfn->Name.Buffer)
|
||||
debug_printf ("nt->Name.Buffer == NULL");
|
||||
else
|
||||
{
|
||||
if (maxmatchdos[n - 1] == L'\\')
|
||||
n--;
|
||||
w32 += maxmatchlen - n;
|
||||
ch = L'\\';
|
||||
WCHAR *w32 = ntfn->Name.Buffer;
|
||||
size_t w32len = ntfn->Name.Length / sizeof (WCHAR);
|
||||
w32[w32len] = L'\0';
|
||||
|
||||
if (wcscasecmp (w32, DEV_NULL) == 0)
|
||||
{
|
||||
strcpy (posix_fn, "/dev/null");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (wcsncasecmp (w32, DEV_NAMED_PIPE, DEV_NAMED_PIPE_LEN) == 0)
|
||||
{
|
||||
w32 += DEV_NAMED_PIPE_LEN;
|
||||
if (wcsncmp (w32, L"cygwin-", WCLEN (L"cygwin-")) != 0)
|
||||
return false;
|
||||
w32 += WCLEN (L"cygwin-");
|
||||
bool istty = wcsncmp (w32, L"tty", WCLEN (L"tty")) == 0;
|
||||
if (istty)
|
||||
decode_tty (posix_fn, w32 + WCLEN (L"tty"));
|
||||
else if (wcsncmp (w32, L"pipe", WCLEN (L"pipe")) == 0)
|
||||
strcpy (posix_fn, "/dev/pipe");
|
||||
return istty;
|
||||
}
|
||||
|
||||
|
||||
WCHAR fnbuf[64 * 1024];
|
||||
if (wcsncasecmp (w32, DEVICE_PREFIX, DEVICE_PREFIX_LEN) != 0
|
||||
|| !QueryDosDeviceW (NULL, fnbuf, sizeof (fnbuf)))
|
||||
{
|
||||
sys_wcstombs (posix_fn, NT_MAX_PATH, w32, w32len);
|
||||
return false;
|
||||
}
|
||||
|
||||
for (WCHAR *s = fnbuf; *s; s = wcschr (s, '\0') + 1)
|
||||
{
|
||||
WCHAR device[NT_MAX_PATH];
|
||||
if (!QueryDosDeviceW (s, device, sizeof (device)))
|
||||
continue;
|
||||
if (wcschr (s, ':') == NULL)
|
||||
continue;
|
||||
WCHAR *q = wcsrchr (device, ';');
|
||||
if (q)
|
||||
{
|
||||
WCHAR *r = wcschr (q, '\\');
|
||||
if (r)
|
||||
wcscpy (q, r + 1);
|
||||
}
|
||||
int devlen = wcslen (device);
|
||||
if (device[devlen - 1] == L'\\')
|
||||
device[--devlen] = L'\0';
|
||||
if (devlen < maxmatchlen)
|
||||
continue;
|
||||
if (wcsncmp (device, w32, devlen) != 0||
|
||||
(w32[devlen] != L'\0' && w32[devlen] != L'\\'))
|
||||
continue;
|
||||
maxmatchlen = devlen;
|
||||
maxmatchdos = s;
|
||||
debug_printf ("current match '%W' = '%W'\n", s, device);
|
||||
}
|
||||
|
||||
if (maxmatchlen)
|
||||
{
|
||||
WCHAR *p = wcschr (w32 + DEVICE_PREFIX_LEN, L'\\');
|
||||
size_t n = wcslen (maxmatchdos);
|
||||
WCHAR ch;
|
||||
if (!p)
|
||||
ch = L'\0';
|
||||
else
|
||||
{
|
||||
if (maxmatchdos[n - 1] == L'\\')
|
||||
n--;
|
||||
w32 += maxmatchlen - n;
|
||||
ch = L'\\';
|
||||
}
|
||||
memcpy (w32, maxmatchdos, n * sizeof (WCHAR));
|
||||
w32[n] = ch;
|
||||
}
|
||||
else if (wcsncmp (w32, DEV_REMOTE, DEV_REMOTE_LEN) == 0)
|
||||
{
|
||||
w32 += DEV_REMOTE_LEN - 2;
|
||||
*w32 = L'\\';
|
||||
debug_printf ("remote drive");
|
||||
}
|
||||
else if (wcsncmp (w32, DEV_REMOTE1, DEV_REMOTE1_LEN) == 0)
|
||||
{
|
||||
w32 += DEV_REMOTE1_LEN - 2;
|
||||
*w32 = L'\\';
|
||||
debug_printf ("remote drive");
|
||||
}
|
||||
|
||||
cygwin_conv_path (CCP_WIN_W_TO_POSIX | CCP_ABSOLUTE, w32, posix_fn,
|
||||
NT_MAX_PATH);
|
||||
|
||||
debug_printf ("derived path '%W', posix '%s'", w32, posix_fn);
|
||||
return false;
|
||||
}
|
||||
memcpy (w32, maxmatchdos, n * sizeof (WCHAR));
|
||||
w32[n] = ch;
|
||||
}
|
||||
else if (wcsncmp (w32, DEV_REMOTE, DEV_REMOTE_LEN) == 0)
|
||||
{
|
||||
w32 += DEV_REMOTE_LEN - 2;
|
||||
*w32 = L'\\';
|
||||
debug_printf ("remote drive");
|
||||
}
|
||||
else if (wcsncmp (w32, DEV_REMOTE1, DEV_REMOTE1_LEN) == 0)
|
||||
{
|
||||
w32 += DEV_REMOTE1_LEN - 2;
|
||||
*w32 = L'\\';
|
||||
debug_printf ("remote drive");
|
||||
}
|
||||
|
||||
cygwin_conv_path (CCP_WIN_W_TO_POSIX | CCP_ABSOLUTE, w32, posix_fn,
|
||||
NT_MAX_PATH);
|
||||
|
||||
debug_printf ("derived path '%W', posix '%s'", w32, posix_fn);
|
||||
return false;
|
||||
|
||||
unknown:
|
||||
strcpy (posix_fn, unknown_file);
|
||||
return false;
|
||||
}
|
||||
|
Reference in New Issue
Block a user