X-Recipient: archive-cygwin@delorie.com
DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org ED5363896C2F
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cygwin.com;
	s=default; t=1620422457;
	bh=AP1bI8pvynd2AYThyeXg42VlxGdtGJ66MU8B1FRsHNI=;
	h=Date:To:Subject:References:In-Reply-To:List-Id:List-Unsubscribe:
	 List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:
	 From;
	b=j+5VtGVJE/hPaYDRIxldLkjwfqVywE7e0tTluz3Udt+IgGaBnYafcb+Aj9aNzF+oS
	 N8k27X3Xy63Wpn1HG6BY6SnXpnCOZrF3Z21YH+GV6e4c33TizOwCBXfi5Hsmc9vcQc
	 yv20Nfjem6HeS21pj4ivDLZdTvxWoL0KThqcXgEk=
X-Original-To: cygwin@cygwin.com
Delivered-To: cygwin@cygwin.com
DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org E99C93896C2F
Date: Fri, 7 May 2021 23:20:49 +0200
To: cygwin@cygwin.com
Subject: Re: realpath issue with native[strict] symlinks
Message-ID: <YJWvMVkkiqy4rmBc@calimero.vinschen.de>
Mail-Followup-To: cygwin@cygwin.com, Orgad Shaneh <orgads@gmail.com>
References: <CAGHpTBLp9tVES8=ggRkNk3HZLr-QT7n79ewKadTkWXyshBfcAw@mail.gmail.com>
 <CAGHpTBJHXXE6YUXjEX8wtE9wnX_wCz5HhrDKsJ_Dz2z1_f4LuQ@mail.gmail.com>
 <YJQrCvv79bHcH3Rz@calimero.vinschen.de>
 <CAGHpTBJ5L1Y4RU+n7PVr6vRCeEBkFPUgnVa8JGZDKcGt7n7JBQ@mail.gmail.com>
MIME-Version: 1.0
Content-Disposition: inline
In-Reply-To: <CAGHpTBJ5L1Y4RU+n7PVr6vRCeEBkFPUgnVa8JGZDKcGt7n7JBQ@mail.gmail.com>
X-Provags-ID: V03:K1:KfG1wUwYXs1YvPzJMqmOsjnQHPbacXk7az4EoCIewEdb75tYoLO
 eNp4MdhvT8CIwZ8EqJ2eXoMoiZJISVG/foSRIc0ppzT+ZEXiILorzbHQjknOsrKdHJ6LTHH
 /gnYFa3amVfEXJgE9KyD0NMXxRpVyVuZvGJUKxUnhtdddm0C6NrYR2opNq0NQQWpi1eTx6h
 a1QNX/7ZQVYTWac68lovQ==
X-UI-Out-Filterresults: notjunk:1;V03:K0:/izWkFX24EQ=:7OTD6sTpHardkE4HznEVz4
 l8BcxUDhOqdkM6Ud9734MzwSNy5OCz7Va7KAH4sAzHqcBoM46RxXNRc/IwCYz75GRsANFzKDE
 +ejOgP6JctWkrvBuh2wgiwoXPO52zKork/aM3MkIbc0Y3/6TzcR01KeLLYwaKv84wpYSTd/RJ
 Ku8BSnOydv3lAb4SYq52yOclUmsomVlDnz0d3jaS47G6QpR9hbFQQV46oZZEf36+99EpN+ifG
 JXck6nz7x8G/wd+psiaDO0oDkHhdegE/OwTE7KXO9xHcB3ujfsYt7uvv+48H92NgNAgWwHPOv
 YPRPha+VYuFNd59qxDCJXI0xz0z/hzPT2NVf9oPRiTwJQ+zLVMWSW2HolYzfx8QqJ2Ena30RR
 cnMXMC7jPBZW4TaVdXFkg1LJ3eUfFKL08+I9wDdRIHTFiXVbldmYUPbBG0SRqoMFGH38UxsW2
 MsgiruxGmQqdKh4vyB3zokDdgthJrNyKG0wsjsg34fq4OBonuZ1vuS/+EQYeKvPz440pa3nsx
 Hh9jJFGa/f2daFsRrvbX6o=
X-Spam-Status: No, score=-100.3 required=5.0 tests=BAYES_00,
 GOOD_FROM_CORINNA_CYGWIN, KAM_DMARC_NONE, KAM_DMARC_STATUS, RCVD_IN_DNSWL_NONE,
 RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, 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@cygwin.com
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: General Cygwin discussions and problem reports <cygwin.cygwin.com>
List-Unsubscribe: <https://cygwin.com/mailman/options/cygwin>,
 <mailto:cygwin-request@cygwin.com?subject=unsubscribe>
List-Archive: <https://cygwin.com/pipermail/cygwin/>
List-Post: <mailto:cygwin@cygwin.com>
List-Help: <mailto:cygwin-request@cygwin.com?subject=help>
List-Subscribe: <https://cygwin.com/mailman/listinfo/cygwin>,
 <mailto:cygwin-request@cygwin.com?subject=subscribe>
From: Corinna Vinschen via Cygwin <cygwin@cygwin.com>
Reply-To: cygwin@cygwin.com
Cc: Corinna Vinschen <corinna-cygwin@cygwin.com>,
        Orgad Shaneh <orgads@gmail.com>
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Errors-To: cygwin-bounces@cygwin.com
Sender: "Cygwin" <cygwin-bounces@cygwin.com>

On May  6 21:36, Orgad Shaneh via Cygwin wrote:
> On Thu, May 6, 2021 at 8:44 PM Corinna Vinschen
> <corinna-cygwin@cygwin.com> wrote:
> >
> > On May  4 22:52, Orgad Shaneh via Cygwin wrote:
> > > On Tue, Apr 27, 2021 at 8:44 AM Orgad Shaneh <orgads@gmail.com> wrote:
> > > >
> > > > On Apr 19 12:58, Corinna Vinschen via Cygwin wrote:
> > > > > On Apr 18 10:59, Orgad Shaneh via Cygwin wrote:
> > > >
> > > > > I was going to write:
> > > > >
> > > > >   Nothing we can do about without re-implementing Cygwin's path handling
> > > > >   from scratch.  For historical reasons, POSIX paths are evaluated in a
> > > > >   non-POSIXy manner from right to left.  If the resulting path is an
> > > > >   existing path, the assumption is that no inner path component is a
> > > > >   symlink.  That's true as long as Windows didn't support
> > > > >   symlinks/junctions and Cygwin didn't support them.
> > > > >
> > > > > But now I'm writing this:
> > > > >
> > > > >   Probably I have a workaround for this problem.  I added a certain test
> > > > >   to the function checking the outer path component, so the checks for
> > > > >   path validity don't stop at the outer path component, just because
> > > > >   it's a valid Windows path.
> > > > >
> > > > > I pushed the patch and uploaded new developer snapshots to
> > > > > https://cygwin.com/snapshots/
> > > > >
> > > > > Please give them a try.
> > > >
> > > > Tried now, and it works for me. Thanks a lot!
> > > >
> > > > - Orgad
> > >
> > >
> > > Hi Corinna,
> > >
> > > This change breaks access to subst drives. Reported on MSYS2:
> > > https://github.com/msys2/msys2-runtime/pull/38#issuecomment-832160980
> > >
> > > Can you please have a look?
> >
> > Works fine for me:
> >
> >   $ subst T: C:\\cygwin64\\home\\corinna\\tmp
> >   $ subst
> >   T:\: => C:\cygwin64\home\corinna\tmp
> >   $ ls /cygdrive/t
> >   bar  cygwin  foo  gawk-5.1.0  ocaml  openssh-8.5p1  recurse  tst
> >
> > TAB completion works, too.
> 
> Right. But if you set / for cygdrive in /etc/fstab it fails:
> none / cygdrive binary,posix=0,user 0 0

I reworked the code handling native symlinks to handle virtual drives
as well.  It might even be a tiny bit quicker now.

The changes have a behavioral change, but I think this is for the
better: Virtual drives are not treated as drives anymore, but as
symlinks.  Given they are just pointers to other drives or directories,
tha't much closer to reality.  I. e., in case of my above virtual drive
T:, what you'll see in the /cygdrive dir (unless your cygdrive prefix is
/ only) is this:

$ ls /cygdrive
$ ls -lG /mnt
total 16
d---r-x---+ 1 TrustedInstaller  0 Apr 29 21:07 c
drwxr-xr-x  1 corinna           0 Dec 31  1979 e
lrwxrwxrwx  1 corinna          32 May  6 20:43 t -> /cygdrive/c/cygwin64/home/corinna/tmp

I uploaded new developer snapshots to https://cygwin.com/snapshots/
for testing.


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
