From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from conssluserg-01.nifty.com (conssluserg-01.nifty.com [210.131.2.80]) by sourceware.org (Postfix) with ESMTPS id AB6A13858408 for ; Mon, 6 Dec 2021 10:55:41 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org AB6A13858408 Authentication-Results: sourceware.org; dmarc=fail (p=none dis=none) header.from=nifty.ne.jp Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=nifty.ne.jp Received: from Express5800-S70 (z221123.dynamic.ppp.asahi-net.or.jp [110.4.221.123]) (authenticated) by conssluserg-01.nifty.com with ESMTP id 1B6AtPsE024034 for ; Mon, 6 Dec 2021 19:55:26 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conssluserg-01.nifty.com 1B6AtPsE024034 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.ne.jp; s=dec2015msa; t=1638788126; bh=EgTtsTr6+GrUqeSZfqUT3kLIIP3b5sg8qfbc5XW2+iY=; h=Date:From:To:Subject:In-Reply-To:References:From; b=Br2IMfQ1ILMQfut+ipE/1pwL13ZdgtrIjsWuICBrn1xmknItDguDcu3P9F8PNzVbG IHvy8Q46Bh1kO9Gv31Jt6ufuuhw6etSb+RU33RUf+HKBgCjwJNoYthtFcmxBqivc2F Q2fbi3o+UWbohNdkKMNvC32HWWN5OS9WSwYP7gcfPiViSxYpHmp7kFlcg/VZP1wV98 7QL0ffsMDZrP1G/0wUINWUwINpjoEReezzj517OU9hq9vn9mvAXnwCm2sMhnC3sk4N qKvDR+PG5WtDm0Pl8uJHGgVLf5FVv11s0yRgiM0TwYMNT98VuCR2SLwY784fBTV3o6 NmgofEg69bjTg== X-Nifty-SrcIP: [110.4.221.123] Date: Mon, 6 Dec 2021 19:55:27 +0900 From: Takashi Yano To: cygwin@cygwin.com Subject: Re: vboxsharedfs - Too many levels of symbolic links Message-Id: <20211206195527.9b9c09b549fa8fcc2512949e@nifty.ne.jp> In-Reply-To: References: <20211205115411.1619911cb3e2d23f671912ce@nifty.ne.jp> X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.30; i686-pc-mingw32) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-11.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: cygwin@cygwin.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: General Cygwin discussions and problem reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 06 Dec 2021 10:55:43 -0000 On Mon, 6 Dec 2021 11:16:30 +0100 Corinna Vinschen wrote: > > 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; First, I think the same. However, with this patch, it sometimes causes hang for a few seconds around the code: else if (isvirtual_dev (dev)) { /* FIXME: Calling build_fhandler here is not the right way to handle this. */ fhandler_virtual *fh = (fhandler_virtual *) build_fh_dev (dev, path_copy); virtual_ftype_t file_type; if (!fh) file_type = virt_none; else { file_type = fh->exists (); if (file_type == virt_symlink || file_type == virt_fdsymlink) { fh->fill_filebuf (); symlen = sym.set (fh->get_filebuf ()); } with path_copy of "//VBoxSrv". I am not sure why. In addition, https://cygwin.com/pipermail/cygwin/2021-December/250103.html still needs fix. So I proposed the patch which stops to treat UNC path as symlink. -- Takashi Yano