From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mout.kundenserver.de (mout.kundenserver.de [212.227.126.133]) by sourceware.org (Postfix) with ESMTPS id EEE693858C39 for ; Thu, 3 Feb 2022 11:34:15 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org EEE693858C39 Authentication-Results: sourceware.org; dmarc=fail (p=none dis=none) header.from=cygwin.com Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=cygwin.com Received: from calimero.vinschen.de ([24.134.7.25]) by mrelayeu.kundenserver.de (mreue010 [212.227.15.167]) with ESMTPSA (Nemesis) id 1MJEMt-1mv1WX0TJz-00KdAx for ; Thu, 03 Feb 2022 12:34:14 +0100 Received: by calimero.vinschen.de (Postfix, from userid 500) id 1EF4FA808FF; Thu, 3 Feb 2022 12:34:13 +0100 (CET) Date: Thu, 3 Feb 2022 12:34:13 +0100 From: Corinna Vinschen To: cygwin@cygwin.com Subject: Re: Cygwin 3.3.4 - cmd to symlinked path doesn't work Message-ID: Reply-To: cygwin@cygwin.com Mail-Followup-To: cygwin@cygwin.com References: <1157721958.20220201154725@yandex.ru> <456680172.20220203135631@yandex.ru> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <456680172.20220203135631@yandex.ru> X-Provags-ID: V03:K1:FFXUHryqSmbS+dAgJQ1Qc8fQG4lLagJN6IOCc7IYcBfcxKjSx4u fZqMwcoFdQgdOetZAuO11bOKDXvtqeKWWQBKhmSL4tWXWdZZ/UOX6wDgos8ZyxBkgMgOSky vUIvoE88TGj98AXpT6HXEMNv0ZXuajT5GuPcceess9z742DUi9Vk0qhROKSQmTWRRTunZJK L6Pk8aUalmGa3SpnYxStw== X-UI-Out-Filterresults: notjunk:1;V03:K0:IzZD1yMu0cU=:ro76IrkbH0VfBoh4U56my4 yfSEHiNbPt6eQWW5iYcXNFNc5GzhyT/law3r8OzT7JToS5Irj41bRuiA0zJDkYo55ZuQO9ESw +3UG01SPyjUeiBx7oAefFEqD3bQV/Iluj+nlfBD8yP9vL3Rq+Tc7EWRj2GUrzzbdroRl9RU52 DtNAVt6FSvhVBikZOsCi4ayADIoMnvVHod89dqCKpDGGVvoVqHO7ftj3arqfG5n7ao37E1i3U d9g7DeJxFD3U6BY/vTVbNJe7Lb8VW6qeVilHo7d448B4Jq9rOklTKZbvdzJFyjwRD/wdUm+nj bqalJ9W1dld4HsbiE2sA8NW9pZZicmWYMZEJr1k+WY4Xy6mPBU2cY0UQCgIc/Ejx9W4TQIigm wf+ZnOwabO+LTLNKwRBCK+A1BB2iPeyhvD69sTM2APJCG1+Sq16gSwCDVnjeCex6KH+MSX3Bq estlaUk85DOBsVvi/xVLNodB808bn4AGQkm5/A0J6npd/sa6+rOko3wMtlaL86gxHWN020AxP PJEcFxm49uh/NctJ7JvoCJBG6bwXbbRYLOlHcfQkHORMWbndmUif+2CHhGjv87LwE1ciiLGoR +UfAj7wzV0FZd+GcyPO3eutnRLTFjID2vvRwgX8R+fpEUGMgjGE0NmJqJ2WMwMbqbRpspRNi4 7F+RIvdNHNmhWHLrd6OfWoF+b1IgW7UDZ4na3DqwuDQpYH7o6EK5en+6QnmXGtYWz3h9L29hs 8UVROS9GPWsXAQR3 X-Spam-Status: No, score=-97.6 required=5.0 tests=BAYES_00, GOOD_FROM_CORINNA_CYGWIN, KAM_DMARC_NONE, KAM_DMARC_STATUS, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL, SPF_FAIL, SPF_HELO_NONE, TXREP, T_SCC_BODY_TEXT_LINE 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: Thu, 03 Feb 2022 11:34:17 -0000 On Feb 3 13:56, Andrey Repin wrote: > Greetings, Corinna Vinschen! > > > On Feb 1 15:47, Andrey Repin wrote: > >> The interesting part is that the behavior is dependent on sequence of events. > >> > >> `mintty bash -i` in a directory: > >> > >> > $ pwd > >> > /cygdrive/d/cygwin > >> > $ cmd > >> > Microsoft Windows [Version 6.1.7601] > >> > Copyright (c) 2009 Microsoft Corporation. All rights reserved. > >> > > >> > D:\cygwin> exit > > > Not sure how you did that, > > Did what? Opened an interactive shell in a directory? Navigated into it in a > different file manager and just used a command. That's the trick! I never use this functionality so I wasn't able to reproduce. > Opened CMD in an UNC path? > > reg ADD "HKCU\\Software\\Microsoft\\Command Processor" /f /v "DisableUNCCheck" /t REG_DWORD /d 1 > > Not even required to re-login. > Or globally for entire system in HKLM\SOFTWARE\Microsoft\Command Processor Ahhh, thanks for this registry key setting. I remembered vaguely that such a setting exists, but my internet searches failed to uncover it, so I thought I had imagined things :) > > Reparse points created with mklink /d are evaluated as symlinks. This > > reparse point contains an absolute UNC path. If you cd to this dir in > > Cygwin, Cygwin evaluates the path and reads the symlink content. Given > > the content is an absolute path, the symlink content replaces the > > entire path. Internally the CWD is stored twice, once in POSIX, once > > in Windows syntax. In short, what happens is this: > > > pwd -> POSIX(/cygdrive/d), WIN(D:) > > cd cygwin -> > > open reparse point "cygwin" > > read content == "\\server2\share\folder1" > > convert to POSIX == "//server2/share/folder1" > > restart path evaluation and check for further symlinks > > -> no further symlinks > > convert path to Windows == "\\server2\share\folder1" > > store both paths as new CWD > > pwd -> POSIX(//server2/share/folder1), > > WIN(\\server2\share\folder1) > > > So what happens in bash? > > > $ pwd > > /cygdrive/d > > $ cd cygwin > > $ pwd > > /cygdrive/d/cygwin > > $ /bin/pwd > > //server2/share/folder1 > > Except if you don't "cd", it uses whatever is given by the operating system. Yeah, that's right and explains that this worked for you. We could run GetFinalPathNameByHandleW on the CWD if the Cygwin process is the root of the process tree, but I'm not sure it's worth it. > I though, by the time everybody had learned to suppress that stupid CMD > behavior, but here it is once again. Yeah, guilty as charged. Thanks again for the registry key! Corinna