public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
From: Takashi Yano <takashi.yano@nifty.ne.jp>
To: cygwin@cygwin.com
Subject: Re: vboxsharedfs - Too many levels of symbolic links
Date: Sun, 5 Dec 2021 11:54:11 +0900	[thread overview]
Message-ID: <20211205115411.1619911cb3e2d23f671912ce@nifty.ne.jp> (raw)
In-Reply-To: <d6470ffe-8e49-3eb7-4d21-3212e0ad4f31@oskog97.com>

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.

In 32bit Windows10:
$ ls -l /cygdrive/z
total 0
-rw-r--r-- 1 yano yano 0 Dec  3 22:16 testfile.txt
$ 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)
Z: on /cygdrive/z type vboxsharedfolderfs (binary,posix=0,user,noumount,auto)
$ uname -a
CYGWIN_NT-10.0 DESKTOP-HGUT5FP 3.3.2(0.341/5/3) 2021-11-08 16:51 i686 Cygwin

In 64bit Windows10:
$ ls -l /cygdrive/z
ls: /cygdrive/z: Too many levels of symbolic links
ls: cannot open directory '/cygdrive/z': Too many levels of symbolic links
$ 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)
Z: on /cygdrive/z type vboxsharedfolderfs (binary,posix=0,user,noumount,auto)
$ uname -a
CYGWIN_NT-10.0-WOW DESKTOP-CUHC1NV 3.3.2(0.341/5/3) 2021-11-08 16:51 i686 Cygwin

I tested with VirtualBox version 6.1.30.

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

For example, RtlEqualUnicodeString() compares \??\UNC\VBoxSrv\tmp and
\??\UNC\VBoxSrv\tmp\, then it fails.

This does not happen in 32bit Windows10. It seems that UNC path is not
treated as a symlink in 32bit Windows10. I am not sure why.

Therefore, I have applied a patch which stops to treat UNC path as a
symlink for testing as follows.

diff --git a/winsup/cygwin/path.cc b/winsup/cygwin/path.cc
index baf04ce89..31a96ca58 100644
--- a/winsup/cygwin/path.cc
+++ b/winsup/cygwin/path.cc
@@ -3490,6 +3490,9 @@ restart:
 	  ret = GetFinalPathNameByHandleW (h, fpbuf, NT_MAX_PATH, 0);
 	  if (ret)
 	    {
+	      if (wcsstr (fpbuf, L"\\\\?\\UNC\\") == fpbuf)
+		goto file_not_symlink;
+
 	      UNICODE_STRING fpath;
 
 	      RtlInitCountedUnicodeString (&fpath, fpbuf, ret * sizeof (WCHAR));

I have confirmed this patch fixes the issue. In addition, this patch
also resolves the issue:
https://cygwin.com/pipermail/cygwin/2021-December/250103.html

Is this the right thing?

-- 
Takashi Yano <takashi.yano@nifty.ne.jp>

  parent reply	other threads:[~2021-12-05  2:54 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-30 17:04 Oskar Skog
2021-11-30 21:40 ` Gackle, Philip P
2021-12-02 10:43 ` Corinna Vinschen
2021-12-05  2:54 ` Takashi Yano [this message]
2021-12-05 14:49   ` Oskar Skog
2021-12-06  3:31     ` Takashi Yano
2021-12-06  6:34       ` Oskar Skog
2021-12-06  8:04       ` Takashi Yano
2021-12-06 10:16   ` Corinna Vinschen
2021-12-06 10:55     ` Takashi Yano
2021-12-07  0:46       ` Takashi Yano
2021-12-07 14:57         ` Corinna Vinschen
2021-12-07 15:32           ` Takashi Yano
2021-12-07 15:43             ` Takashi Yano
2021-12-07 16:03             ` Corinna Vinschen
     [not found] <Ya+WvmECA+zAbuV9@calimero.vinschen.de>
2021-12-08  8:20 ` Takashi Yano
2021-12-08 10:37   ` Corinna Vinschen
2021-12-09  8:16     ` Takashi Yano
2021-12-09  9:16       ` Corinna Vinschen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211205115411.1619911cb3e2d23f671912ce@nifty.ne.jp \
    --to=takashi.yano@nifty.ne.jp \
    --cc=cygwin@cygwin.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).