On Dec  5 11:54, Takashi Yano wrote:
> On Tue, 30 Nov 2021 19:04:57 +0200
> Oskar Skog wrote:
> > vboxsharedfs file systems no longer work. Any attempt to access will
> > result in "too many levels of symbolic links".
> > 
> > This only affects the VirtualBox shared folder, the Samba share works
> > just fine.
> > 
> > Last time I updated (before today) was sometime before the 10th of
> > September.
> > 
> > MSYS2 has the same problem, but no one seems to have reported it to
> > Cygwin:
> > https://github.com/msys2/msys2-runtime/issues/58
> > 
> > 
> > user@DESKTOP-******* ~$ ls /cygdrive/z
> > ls: cannot access '/cygdrive/z': Too many levels of symbolic links
> > user@DESKTOP-******* ~$ mount
> > C:/Cygwin/bin on /usr/bin type ntfs (binary,auto)
> > C:/Cygwin/lib on /usr/lib type ntfs (binary,auto)
> > C:/Cygwin on / type ntfs (binary,auto)
> > C: on /cygdrive/c type ntfs (binary,posix=0,user,noumount,auto)
> > D: on /cygdrive/d type iso9660 (binary,posix=0,user,noumount,auto)
> > Y: on /cygdrive/y type smbfs (binary,posix=0,user,noumount,auto)
> > Z: on /cygdrive/z type vboxsharedfolderfs 
> > (binary,posix=0,user,noumount,auto)
> > user@DESKTOP-******* ~$ uname -a
> > CYGWIN_NT-10.0 DESKTOP-* 3.3.2(0.341/5/3) 2021-11-08 16:55 x86_64 Cygwin
> 
> Thanks for the report.
> It seems that this happens only in 64bit Windoes10/11.
> [...]
> I tested with VirtualBox version 6.1.30.

Thanks for testing, Takashi!

> In 64bit Windows10, for vbox shared path, GetFinalPathNameByHandleW()
> returns path with trailing '\'. As a result, RtlEqualUnicodeString()
> fails and tries to resolve symlink repeatedly.

That sounds like a bug in VirtualBox, but yeah, we should workaround it.

> For example, RtlEqualUnicodeString() compares \??\UNC\VBoxSrv\tmp and
> \??\UNC\VBoxSrv\tmp\, then it fails.
> [...]
> +           if (wcsstr (fpbuf, L"\\\\?\\UNC\\") == fpbuf)
> +             goto file_not_symlink;
> +

Isn't that a bit intrusive?  Wouldn't it also fix the issue if we
just overwrite a trailing '\\' with '\0', like this?

diff --git a/winsup/cygwin/path.cc b/winsup/cygwin/path.cc
index baf04ce89a08..b76e5b0466cf 100644
--- a/winsup/cygwin/path.cc
+++ b/winsup/cygwin/path.cc
@@ -3492,8 +3492,14 @@ restart:
            {
              UNICODE_STRING fpath;
 
-             RtlInitCountedUnicodeString (&fpath, fpbuf, ret * sizeof (WCHAR));
+             /* If incoming path has no trailing backslash, but final path
+                has one, drop trailing backslash from final path so the
+                below string comparison has a chance to succeed. */
+             if (upath.Buffer[(upath.Length - 1) / sizeof (WCHAR)] != L'\\'
+                 && fpbuf[ret - 1] == L'\\')
+               fpbuf[--ret] = L'\0';
              fpbuf[1] = L'?';  /* \\?\ --> \??\ */
+             RtlInitCountedUnicodeString (&fpath, fpbuf, ret * sizeof (WCHAR));
              if (!RtlEqualUnicodeString (&upath, &fpath, !!ci_flag))
                {
                  issymlink = true;


Thanks,
Corinna

-- 
Problem reports:      https://cygwin.com/problems.html
FAQ:                  https://cygwin.com/faq/
Documentation:        https://cygwin.com/docs.html
Unsubscribe info:     https://cygwin.com/ml/#unsubscribe-simple

Reply via email to