X-Recipient: archive-cygwin AT delorie DOT com DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2747D385E445 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cygwin.com; s=default; t=1602751046; bh=1c+sRNoCyHXnvjU5jOOnVeK1q2XhVpHcfAhKCBjEcyw=; h=Date:From:To:Subject:References:In-Reply-To:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: Reply-To:From; b=wKieAgvUz7x8cv6/YCh0t7RUPCYMTkowe8P/FSm9RSpQzMeg0HoxiZiODSZbPvm9e AWXOLs5DZ11lqVbIEdpbKaxqAMkQta9L+wKNnKBkZpIw2lx5PtzF7NLunR4TCSxOCp DKqtatUwcpRPuHa3b9vfJqf3s3kPSzejhbOfU3k4= X-Original-To: cygwin AT cygwin DOT com Delivered-To: cygwin AT cygwin DOT com DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 15D30385780B Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=cygwin.com Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=corinna-cygwin AT cygwin DOT com Date: Thu, 15 Oct 2020 10:37:20 +0200 From: Corinna Vinschen To: cygwin AT cygwin DOT com Subject: Re: Strange behaviour with winsymlinks:native Message-ID: <20201015083720.GF26704@calimero.vinschen.de> Mail-Followup-To: cygwin AT cygwin DOT com References: <001001d6a23a$3d5ebc70$b81c3550$@cl.cam.ac.uk> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <001001d6a23a$3d5ebc70$b81c3550$@cl.cam.ac.uk> X-Provags-ID: V03:K1:7cqdAuAy9RAFcqprgf45zNQQTwndtDDhfCHfe3HbNIWJzN0IGma eyZ+BZY73STi9qBLfBDp8ODM0TdMpNZvNfCkZk1+Nai1BqxO+c6F7/q+S+fyMjm/c3//knl NrLl479aLirt/VjXSgNi9AmHV+9I2U+KIghBc8foHKLdXGJNIa+hwhemT6yLi3zoTGw/L9v EXn8WrySKciWf293O3G7g== X-UI-Out-Filterresults: notjunk:1;V03:K0:8+CJYyVMRFg=:02Shu3OSe/fXJfAcuO0uy9 BYywORsVuc030X5HngpKFCKKTuuxrxvUst/CA5EaV5SwDBZsSPQcZT3x5Qjwn2X4dvzAkOgLi dC/v1rUK78sqKFKDYMgrpk+pYKnrKCw52i0dIRYyCppZG8NoPo5e1MxqEY8NW5eDfryX6BAVt BIIClJ6+1IZOascRACfXYa6AglHYijMSFKFnpU8FQYy+MlD1xcx8MgHfBV/bNKzD/6KuZNJ/A qTdPwZotENKBwNIdEtONf9BOUxNQwfqnDk9qfrt6XVJxhgvQtmvEHh/M9hsqqXMrU3w1CdTjT Iw54o+dOVtH5eCkUSi4LEGfqNzDxRoRZ3qiaYgPQlKSCExVwG8gsXjIYz9AAWFwDB6JWe35W9 2Wqa774Vm94gvrf85DfGPgSSBAzO4VrlSMIDYxQR9whRFSRzWdH9CjzubHlYoGiPgiU33dpT5 +oJyfgjNXg== X-Spam-Status: No, score=-100.4 required=5.0 tests=BAYES_00, GOOD_FROM_CORINNA_CYGWIN, KAM_DMARC_STATUS, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NEUTRAL, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: cygwin AT cygwin DOT 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: , Reply-To: cygwin AT cygwin DOT com Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: cygwin-bounces AT cygwin DOT com Sender: "Cygwin" On Oct 14 15:56, David Allsopp via Cygwin wrote: > I've been doing some working around the problems with Cygwin 3.1.5+ WSL > junction points in Docker and found three unexpected pieces of behaviour > with CYGWIN=winsymlinks:native > > In all cases, these work as expected with the default symlink behaviour > (i.e. CYGWIN unset or without a winsymlinks option). > > 1. Relative paths get unnecessarily resolved > > mkdir -p foo/bar > cd foo/bar > touch baz > CYGWIN='winsymlinks:native' ln -s ../bar/baz link > readlink link > > Result is baz, not ../bar/baz > > 2a. Links in the magic mount directories (/usr/bin and /usr/lib) get extra > bits added (source is a default mount): > > cd /usr/lib > CYGWIN='winsymlinks:native' ln -s ../share/terminfo terminfo2 > readlink terminfo2 > > Result is ../usr/share/terminfo, which makes it valid from /lib (the "real" > directory) but not in the virtual one > > 2b. Same but where target is a default mount > > cd /usr/libexec/p11-kit > CYGWIN='winsymlinks:native' ln -s ../../bin/update-ca-trust > trust-extract-compat2 > readlink trust-extract-compat2 > > Result is ../../../bin/update-ca-trust, again it seems to be computing an > extra level back to the "real" lib directory > > Are these behaviours expected? I can create those symbolic links manually > with mklink with no problem, so I'm wondering if it's an outright bug or an > unexpected consequence of something else. The difference between mklink and Cygwin creating native symlinks is that Cygwin performs the additional POSIX -> Windows conversion. Given that Cygwin doesn't need native symlinks to do its job, the goal in creating native symlinks is to make the target path understood by non-Cygwin tools. This requires a bit of tweaking the path, especially if the path is given as relative path. Cygwin tries to keep the path relative, but it's not foolproof: 1. After converting the POSIX path to Windows paths, the absolute symlink and target paths are compared to find the common prefix. The resulting relative path skips all common directories. Please keep in mind that the target path is relative to the symlink you're just creating, not relative to CWD. Just checking the relative path for existence using a Windows function is not going to work, except in border cases. 2a. and 2b. are basically the same problem: The virtual mounts are not valid in Windows. Cygwin has to resolve them using the underlying real path to make them work with native Windows tools. Having said that, there's very likely still room for improvement. You may want to take a look at the function creating native symlinks: https://sourceware.org/git/?p=newlib-cygwin.git;a=blob;f=winsup/cygwin/path.cc;h=4f5f03a761d3839e10c77b4531855233ddf80d88;hb=HEAD#l1740 Feel free to provide patches to improve the situation in certain scenarios. But keep in mind that, ultimately, the native symlinks should be usable by a non-Cygwin Windows tool. Corinna -- Corinna Vinschen Cygwin Maintainer -- 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