While filenames on NFS shares are converted internally to a widechar
representation of the input bytes treated as the default system ANSI
codepage (CP_ACP), this doesn't hold for share names. The names
returned by WNetEnumResourceW are just the original bytes dropped
verbatim into WCHAR.
The original conversion from 7db1c6fc4e2a ("Cygwin: //server: revert
to using WNet and support NFS shares") was erroneous in that it
treated the bytes as ISO-8859-1, not as CP_ACP codepoints.
Fix the conversion to convert from CP_ACP to widechar. Use a tmp_pathbuf
buffer for the new widechar string instead of malloc/free. Extend the
comment, better explaining the encoding difference between files and
shares.
Fixes: 7db1c6fc4e2a ("Cygwin: //server: revert to using WNet and support NFS shares")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
Some providers don't implement share enumeration. Allow to find
the server's connected resources in this case. Enable this feature
for the WNNC_NET_DAV provider.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
For some provider types, WNetGetResourceInformationW fails, namely
WNNC_NET_DAV. When that happens, try to find the server's provider
by enumerating all WNet containers from the top.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
- As before, first try NFS for dotted names, but additionally check if
the NFS profvider is installed.
- Next try *any* provider (i.e. provider = 0). Move the necessary
heuristics into thread_netdrive_wnet with lots of comments.
- Last, but not least, if the server was already tried for NFS,
but WNetGetResourceInformationW returns WNNC_NET_MS_NFS again
when trying any provider, bail out and retry with SMB, since
many NFS servers could be SMB servers as well.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
Fix the cygthread names used for debugging when calling the
thread_netdrive_wnet thread, so they actually show the provider
getting enumerated.
Fixes: 7db1c6fc4e2a ("Cygwin: //server: revert to using WNet and support NFS shares")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
So far there's no known way to enumerate connected WebDAV resources.
WNetGetResourceInformationW/WNetOpenEnumW both return ERROR_BAD_NET_NAME.
Windows Explorer also shows an error dialog when trying to open a
Nextcloud instance to see the shares.
However, `net use' enumerates the connected cloud shares, so
there must be a way to do this.
For the time being, we just don't even try to enumerate WebDAV
shares and return an empty list.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
WebDAV resources trigger the code trying to enumerate NFS shares
on the server. Disable this by checking for an at-sign as well.
Fixes: 8cebbb2b42bf ("Cygwin: fhandler_netdrive::exists: handle WebDAV URLs")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
WebDAV URLs may contain an at-sign followed by a port number or SSL.
This will throw GetAddrInfoW, so remove the at-sign prior to calling
GetAddrInfoW.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
The debug statement was wrong twice: Not only was it in the wrong
spot, it was also supposed to print the share name and missed to
add said argument.
Fixes: df307349a09e ("Cygwin: fhandler_netdrive::exists: add debug statement")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
per
https://pubs.opengroup.org/onlinepubs/9799919799/functions/posix_close.html
Add a flag value to fhandler_*::close() and close_with_arch() methods,
taking -1 as default argument, used to indicate default close(2)
behaviour.
The only fhandlers capable of returning EINTR are the INET based
socket fhandlers. Handle -1 and POSIX_CLOSE_RESTART equivalent,
making close() and posix_close(POSIX_CLOSE_RESTART) behaving
identically.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
Simplify code in that it only fetches a single entry per
IEnumShellItems::Next call. For some reason this appears to
be quicker most of the time.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
Root dirs of WSL installations are exposed via \\wsl$.
Add support to expose \\wsl$.
While at it, check if TERMSRV and P9 provider exist before
exposing them.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
The //tsclient provider is WNNC_NET_TERMSRV.
Fixes: 7db1c6fc4e2a ("Cygwin: //server: revert to using WNet and support NFS shares")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
Continue using WSD for enumerating //, but switch back to
WNet for enumerating shares.
Add trying to enumerate NFS shares for machine names given as FQDN.
Only downcase server names, keep case of shares intact.
Move downcasing into dir_cache class.
Add a comment to explain an extrem weirdness in Windows.
Fixes: 205190a80bd0 ("Cygwin: // and //server: switch to Network Discovery")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
Checking server existence by trying to enumerate its shares
may result in 2 minutes delay until some internal timeout is hit.
In the light that every network is an IP network anyway these
days, let's try with a simple getaddrinfo() call. This is usually
back in 3 secs even if the server doesn't exist, and it's usually
back in 8 secs if the DNS server can't be connected. This is the
fastest method I found to check server existence yet.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
SMBv1 is ultimately deprecated since Novemer 2023. It's also
not installed by default on latest Windows versions.
Drop using the WNet (SMBv1) API in favor of using Network Discovery.
Given there's no documented Win32 API for that, the code now uses
the Shell API.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>