* autoload.cc: Replace WNet[...]A with WNet[...]W imports.
* dcrt0.cc (initial_env): Drop strlwr calls. Call strcasestr instead. * fhandler_netdrive.cc: Throughout, convert to calling WNet UNICODE functions. Use tmp_pathbuf rather than alloca. Replace call to strlwr with call to RtlDowncaseUnicodeString.
This commit is contained in:
parent
be2b7c5684
commit
67986ac4a4
|
@ -1,3 +1,11 @@
|
||||||
|
2014-08-19 Corinna Vinschen <corinna@vinschen.de>
|
||||||
|
|
||||||
|
* autoload.cc: Replace WNet[...]A with WNet[...]W imports.
|
||||||
|
* dcrt0.cc (initial_env): Drop strlwr calls. Call strcasestr instead.
|
||||||
|
* fhandler_netdrive.cc: Throughout, convert to calling WNet UNICODE
|
||||||
|
functions. Use tmp_pathbuf rather than alloca. Replace call to
|
||||||
|
strlwr with call to RtlDowncaseUnicodeString.
|
||||||
|
|
||||||
2014-08-19 Corinna Vinschen <corinna@vinschen.de>
|
2014-08-19 Corinna Vinschen <corinna@vinschen.de>
|
||||||
|
|
||||||
* fhandler.h (fhandler_serial::is_tty): Reinstantiate.
|
* fhandler.h (fhandler_serial::is_tty): Reinstantiate.
|
||||||
|
|
|
@ -608,10 +608,10 @@ LoadDLLfunc (LdapMapErrorToWin32, 0, wldap32)
|
||||||
#pragma pop_macro ("mangle")
|
#pragma pop_macro ("mangle")
|
||||||
|
|
||||||
LoadDLLfunc (WNetCloseEnum, 4, mpr)
|
LoadDLLfunc (WNetCloseEnum, 4, mpr)
|
||||||
LoadDLLfunc (WNetEnumResourceA, 16, mpr)
|
LoadDLLfunc (WNetEnumResourceW, 16, mpr)
|
||||||
LoadDLLfunc (WNetGetProviderNameA, 12, mpr)
|
LoadDLLfunc (WNetGetProviderNameW, 12, mpr)
|
||||||
LoadDLLfunc (WNetGetResourceInformationA, 16, mpr)
|
LoadDLLfunc (WNetGetResourceInformationW, 16, mpr)
|
||||||
LoadDLLfunc (WNetOpenEnumA, 20, mpr)
|
LoadDLLfunc (WNetOpenEnumW, 20, mpr)
|
||||||
|
|
||||||
LoadDLLfunc (DsEnumerateDomainTrustsW, 16, netapi32)
|
LoadDLLfunc (DsEnumerateDomainTrustsW, 16, netapi32)
|
||||||
LoadDLLfunc (DsGetDcNameW, 24, netapi32)
|
LoadDLLfunc (DsGetDcNameW, 24, netapi32)
|
||||||
|
|
|
@ -517,14 +517,12 @@ initial_env ()
|
||||||
{
|
{
|
||||||
char buf1[NT_MAX_PATH];
|
char buf1[NT_MAX_PATH];
|
||||||
GetModuleFileName (NULL, buf1, NT_MAX_PATH);
|
GetModuleFileName (NULL, buf1, NT_MAX_PATH);
|
||||||
strlwr (buf1);
|
|
||||||
strlwr (buf);
|
|
||||||
char *p = strpbrk (buf, ":=");
|
char *p = strpbrk (buf, ":=");
|
||||||
if (!p)
|
if (!p)
|
||||||
p = (char *) "gdb.exe -nw";
|
p = (char *) "gdb.exe -nw";
|
||||||
else
|
else
|
||||||
*p++ = '\0';
|
*p++ = '\0';
|
||||||
if (strstr (buf1, buf))
|
if (strcasestr (buf1, buf))
|
||||||
{
|
{
|
||||||
error_start_init (p);
|
error_start_init (p);
|
||||||
jit_debug = true;
|
jit_debug = true;
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
/* fhandler_netdrive.cc: fhandler for // and //MACHINE handling
|
/* fhandler_netdrive.cc: fhandler for // and //MACHINE handling
|
||||||
|
|
||||||
Copyright 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Red Hat, Inc.
|
Copyright 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014
|
||||||
|
Red Hat, Inc.
|
||||||
|
|
||||||
This file is part of Cygwin.
|
This file is part of Cygwin.
|
||||||
|
|
||||||
|
@ -17,6 +18,7 @@ details. */
|
||||||
#include "dtable.h"
|
#include "dtable.h"
|
||||||
#include "cygheap.h"
|
#include "cygheap.h"
|
||||||
#include "cygthread.h"
|
#include "cygthread.h"
|
||||||
|
#include "tls_pbuf.h"
|
||||||
|
|
||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
|
|
||||||
|
@ -47,18 +49,19 @@ static DWORD WINAPI
|
||||||
thread_netdrive (void *arg)
|
thread_netdrive (void *arg)
|
||||||
{
|
{
|
||||||
netdriveinf *ndi = (netdriveinf *) arg;
|
netdriveinf *ndi = (netdriveinf *) arg;
|
||||||
char provider[256], *dummy = NULL;
|
WCHAR provider[256], *dummy = NULL;
|
||||||
LPNETRESOURCE nro;
|
LPNETRESOURCEW nro;
|
||||||
DWORD cnt, size;
|
DWORD cnt, size;
|
||||||
struct net_hdls *nh;
|
struct net_hdls *nh;
|
||||||
|
tmp_pathbuf tp;
|
||||||
|
|
||||||
ReleaseSemaphore (ndi->sem, 1, NULL);
|
ReleaseSemaphore (ndi->sem, 1, NULL);
|
||||||
switch (ndi->what)
|
switch (ndi->what)
|
||||||
{
|
{
|
||||||
case GET_RESOURCE_OPENENUMTOP:
|
case GET_RESOURCE_OPENENUMTOP:
|
||||||
nro = (LPNETRESOURCE) alloca (size = 4096);
|
nro = (LPNETRESOURCEW) tp.c_get ();
|
||||||
nh = (struct net_hdls *) ndi->out;
|
nh = (struct net_hdls *) ndi->out;
|
||||||
ndi->ret = WNetGetProviderName (WNNC_NET_LANMAN, provider,
|
ndi->ret = WNetGetProviderNameW (WNNC_NET_LANMAN, provider,
|
||||||
(size = 256, &size));
|
(size = 256, &size));
|
||||||
if (ndi->ret != NO_ERROR)
|
if (ndi->ret != NO_ERROR)
|
||||||
break;
|
break;
|
||||||
|
@ -69,32 +72,34 @@ thread_netdrive (void *arg)
|
||||||
nro->dwUsage = RESOURCEUSAGE_RESERVED | RESOURCEUSAGE_CONTAINER;
|
nro->dwUsage = RESOURCEUSAGE_RESERVED | RESOURCEUSAGE_CONTAINER;
|
||||||
nro->lpRemoteName = provider;
|
nro->lpRemoteName = provider;
|
||||||
nro->lpProvider = provider;
|
nro->lpProvider = provider;
|
||||||
ndi->ret = WNetOpenEnum (RESOURCE_GLOBALNET, RESOURCETYPE_DISK,
|
ndi->ret = WNetOpenEnumW (RESOURCE_GLOBALNET, RESOURCETYPE_DISK,
|
||||||
RESOURCEUSAGE_ALL, nro, &nh->net);
|
RESOURCEUSAGE_ALL, nro, &nh->net);
|
||||||
if (ndi->ret != NO_ERROR)
|
if (ndi->ret != NO_ERROR)
|
||||||
break;
|
break;
|
||||||
while ((ndi->ret = WNetEnumResource (nh->net, (cnt = 1, &cnt), nro,
|
while ((ndi->ret = WNetEnumResourceW (nh->net, (cnt = 1, &cnt), nro,
|
||||||
(size = 4096, &size))) == NO_ERROR)
|
(size = NT_MAX_PATH, &size)))
|
||||||
|
== NO_ERROR)
|
||||||
{
|
{
|
||||||
ndi->ret = WNetOpenEnum (RESOURCE_GLOBALNET, RESOURCETYPE_DISK,
|
ndi->ret = WNetOpenEnumW (RESOURCE_GLOBALNET, RESOURCETYPE_DISK,
|
||||||
RESOURCEUSAGE_ALL, nro, &nh->dom);
|
RESOURCEUSAGE_ALL, nro, &nh->dom);
|
||||||
if (ndi->ret == NO_ERROR)
|
if (ndi->ret == NO_ERROR)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case GET_RESOURCE_OPENENUM:
|
case GET_RESOURCE_OPENENUM:
|
||||||
nro = (LPNETRESOURCE) alloca (size = 4096);
|
nro = (LPNETRESOURCEW) tp.c_get ();
|
||||||
nh = (struct net_hdls *) ndi->out;
|
nh = (struct net_hdls *) ndi->out;
|
||||||
ndi->ret = WNetGetProviderName (WNNC_NET_LANMAN, provider,
|
ndi->ret = WNetGetProviderNameW (WNNC_NET_LANMAN, provider,
|
||||||
(size = 256, &size));
|
(size = 256, &size));
|
||||||
if (ndi->ret != NO_ERROR)
|
if (ndi->ret != NO_ERROR)
|
||||||
break;
|
break;
|
||||||
((LPNETRESOURCE) ndi->in)->lpProvider = provider;
|
((LPNETRESOURCEW) ndi->in)->lpProvider = provider;
|
||||||
ndi->ret = WNetGetResourceInformation ((LPNETRESOURCE) ndi->in,
|
ndi->ret = WNetGetResourceInformationW ((LPNETRESOURCEW) ndi->in, nro,
|
||||||
nro, &size, &dummy);
|
(size = NT_MAX_PATH, &size),
|
||||||
|
&dummy);
|
||||||
if (ndi->ret != NO_ERROR)
|
if (ndi->ret != NO_ERROR)
|
||||||
break;
|
break;
|
||||||
ndi->ret = WNetOpenEnum (RESOURCE_GLOBALNET, RESOURCETYPE_DISK,
|
ndi->ret = WNetOpenEnumW (RESOURCE_GLOBALNET, RESOURCETYPE_DISK,
|
||||||
RESOURCEUSAGE_ALL, nro, &nh->dom);
|
RESOURCEUSAGE_ALL, nro, &nh->dom);
|
||||||
break;
|
break;
|
||||||
case GET_RESOURCE_ENUM:
|
case GET_RESOURCE_ENUM:
|
||||||
|
@ -104,18 +109,19 @@ thread_netdrive (void *arg)
|
||||||
ndi->ret = ERROR_NO_MORE_ITEMS;
|
ndi->ret = ERROR_NO_MORE_ITEMS;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
while ((ndi->ret = WNetEnumResource (nh->dom, (cnt = 1, &cnt),
|
nro = (LPNETRESOURCEW) tp.c_get ();
|
||||||
(LPNETRESOURCE) ndi->out,
|
while ((ndi->ret = WNetEnumResourceW (nh->dom, (cnt = 1, &cnt),
|
||||||
|
(LPNETRESOURCEW) ndi->out,
|
||||||
&ndi->outsize)) != NO_ERROR
|
&ndi->outsize)) != NO_ERROR
|
||||||
&& nh->net)
|
&& nh->net)
|
||||||
{
|
{
|
||||||
WNetCloseEnum (nh->dom);
|
WNetCloseEnum (nh->dom);
|
||||||
nh->dom = NULL;
|
nh->dom = NULL;
|
||||||
nro = (LPNETRESOURCE) alloca (size = 4096);
|
while ((ndi->ret = WNetEnumResourceW (nh->net, (cnt = 1, &cnt), nro,
|
||||||
while ((ndi->ret = WNetEnumResource (nh->net, (cnt = 1, &cnt), nro,
|
(size = NT_MAX_PATH, &size)))
|
||||||
(size = 4096, &size))) == NO_ERROR)
|
== NO_ERROR)
|
||||||
{
|
{
|
||||||
ndi->ret = WNetOpenEnum (RESOURCE_GLOBALNET, RESOURCETYPE_DISK,
|
ndi->ret = WNetOpenEnumW (RESOURCE_GLOBALNET, RESOURCETYPE_DISK,
|
||||||
RESOURCEUSAGE_ALL, nro, &nh->dom);
|
RESOURCEUSAGE_ALL, nro, &nh->dom);
|
||||||
if (ndi->ret == NO_ERROR)
|
if (ndi->ret == NO_ERROR)
|
||||||
break;
|
break;
|
||||||
|
@ -152,15 +158,20 @@ fhandler_netdrive::exists ()
|
||||||
size_t len = strlen (get_name ());
|
size_t len = strlen (get_name ());
|
||||||
if (len == 2)
|
if (len == 2)
|
||||||
return virt_rootdir;
|
return virt_rootdir;
|
||||||
|
|
||||||
char namebuf[len + 1];
|
char namebuf[len + 1];
|
||||||
|
tmp_pathbuf tp;
|
||||||
|
PWCHAR name = tp.w_get ();
|
||||||
|
|
||||||
for (to = namebuf, from = get_name (); *from; to++, from++)
|
for (to = namebuf, from = get_name (); *from; to++, from++)
|
||||||
*to = (*from == '/') ? '\\' : *from;
|
*to = (*from == '/') ? '\\' : *from;
|
||||||
*to = '\0';
|
*to = '\0';
|
||||||
|
|
||||||
struct net_hdls nh = { NULL, NULL };
|
struct net_hdls nh = { NULL, NULL };
|
||||||
NETRESOURCE nr = {0};
|
NETRESOURCEW nr = {0};
|
||||||
nr.dwType = RESOURCETYPE_DISK;
|
nr.dwType = RESOURCETYPE_DISK;
|
||||||
nr.lpRemoteName = namebuf;
|
sys_mbstowcs (name, NT_MAX_PATH, namebuf);
|
||||||
|
nr.lpRemoteName = name;
|
||||||
DWORD ret = create_thread_and_wait (GET_RESOURCE_OPENENUM,
|
DWORD ret = create_thread_and_wait (GET_RESOURCE_OPENENUM,
|
||||||
&nr, &nh, 0, "WNetOpenEnum");
|
&nr, &nh, 0, "WNetOpenEnum");
|
||||||
if (nh.dom)
|
if (nh.dom)
|
||||||
|
@ -190,28 +201,30 @@ fhandler_netdrive::fstat (struct stat *buf)
|
||||||
int
|
int
|
||||||
fhandler_netdrive::readdir (DIR *dir, dirent *de)
|
fhandler_netdrive::readdir (DIR *dir, dirent *de)
|
||||||
{
|
{
|
||||||
NETRESOURCE *nro;
|
NETRESOURCEW *nro;
|
||||||
DWORD ret;
|
DWORD ret;
|
||||||
int res;
|
int res;
|
||||||
|
tmp_pathbuf tp;
|
||||||
|
|
||||||
if (!dir->__d_position)
|
if (!dir->__d_position)
|
||||||
{
|
{
|
||||||
size_t len = strlen (get_name ());
|
size_t len = strlen (get_name ());
|
||||||
char *namebuf = NULL;
|
PWCHAR name = NULL;
|
||||||
NETRESOURCE nr = { 0 };
|
NETRESOURCEW nr = { 0 };
|
||||||
struct net_hdls *nh;
|
struct net_hdls *nh;
|
||||||
|
|
||||||
if (len != 2) /* // */
|
if (len != 2) /* // */
|
||||||
{
|
{
|
||||||
const char *from;
|
const char *from;
|
||||||
char *to;
|
char *to;
|
||||||
namebuf = (char *) alloca (len + 1);
|
char *namebuf = (char *) alloca (len + 1);
|
||||||
for (to = namebuf, from = get_name (); *from; to++, from++)
|
for (to = namebuf, from = get_name (); *from; to++, from++)
|
||||||
*to = (*from == '/') ? '\\' : *from;
|
*to = (*from == '/') ? '\\' : *from;
|
||||||
*to = '\0';
|
*to = '\0';
|
||||||
|
name = tp.w_get ();
|
||||||
|
sys_mbstowcs (name, NT_MAX_PATH, namebuf);
|
||||||
}
|
}
|
||||||
|
nr.lpRemoteName = name;
|
||||||
nr.lpRemoteName = namebuf;
|
|
||||||
nr.dwType = RESOURCETYPE_DISK;
|
nr.dwType = RESOURCETYPE_DISK;
|
||||||
nh = (struct net_hdls *) ccalloc (HEAP_FHANDLER, 1, sizeof *nh);
|
nh = (struct net_hdls *) ccalloc (HEAP_FHANDLER, 1, sizeof *nh);
|
||||||
ret = create_thread_and_wait (len == 2 ? GET_RESOURCE_OPENENUMTOP
|
ret = create_thread_and_wait (len == 2 ? GET_RESOURCE_OPENENUMTOP
|
||||||
|
@ -225,28 +238,37 @@ fhandler_netdrive::readdir (DIR *dir, dirent *de)
|
||||||
}
|
}
|
||||||
dir->__handle = (HANDLE) nh;
|
dir->__handle = (HANDLE) nh;
|
||||||
}
|
}
|
||||||
ret = create_thread_and_wait (GET_RESOURCE_ENUM, dir->__handle,
|
nro = (LPNETRESOURCEW) tp.c_get ();
|
||||||
nro = (LPNETRESOURCE) alloca (16384),
|
ret = create_thread_and_wait (GET_RESOURCE_ENUM, dir->__handle, nro,
|
||||||
16384, "WnetEnumResource");
|
NT_MAX_PATH, "WnetEnumResource");
|
||||||
if (ret != NO_ERROR)
|
if (ret != NO_ERROR)
|
||||||
res = geterrno_from_win_error (ret);
|
res = geterrno_from_win_error (ret);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
dir->__d_position++;
|
dir->__d_position++;
|
||||||
char *bs = strrchr (nro->lpRemoteName, '\\');
|
PWCHAR bs = wcsrchr (nro->lpRemoteName, L'\\');
|
||||||
strcpy (de->d_name, bs ? bs + 1 : nro->lpRemoteName);
|
bs = bs ? bs + 1 : nro->lpRemoteName;
|
||||||
if (strlen (get_name ()) == 2)
|
if (strlen (get_name ()) == 2)
|
||||||
{
|
{
|
||||||
strlwr (de->d_name);
|
UNICODE_STRING ss, ds;
|
||||||
|
|
||||||
|
tp.u_get (&ds);
|
||||||
|
RtlInitUnicodeString (&ss, bs);
|
||||||
|
RtlDowncaseUnicodeString (&ds, &ss, FALSE);
|
||||||
|
sys_wcstombs (de->d_name, sizeof de->d_name,
|
||||||
|
ds.Buffer, ds.Length / sizeof (WCHAR));
|
||||||
de->d_ino = hash_path_name (get_ino (), de->d_name);
|
de->d_ino = hash_path_name (get_ino (), de->d_name);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
de->d_ino = readdir_get_ino (nro->lpRemoteName, false);
|
sys_wcstombs (de->d_name, sizeof de->d_name, bs);
|
||||||
|
char *rpath = tp.c_get ();
|
||||||
|
sys_wcstombs (rpath, NT_MAX_PATH, nro->lpRemoteName);
|
||||||
|
de->d_ino = readdir_get_ino (rpath, false);
|
||||||
/* We can't trust remote inode numbers of only 32 bit. That means,
|
/* We can't trust remote inode numbers of only 32 bit. That means,
|
||||||
remote NT4 NTFS, as well as shares of Samba version < 3.0. */
|
remote NT4 NTFS, as well as shares of Samba version < 3.0. */
|
||||||
if (de->d_ino <= UINT32_MAX)
|
if (de->d_ino <= UINT32_MAX)
|
||||||
de->d_ino = hash_path_name (0, nro->lpRemoteName);
|
de->d_ino = hash_path_name (0, rpath);
|
||||||
}
|
}
|
||||||
de->d_type = DT_DIR;
|
de->d_type = DT_DIR;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue