realpath issue with native[strict] symlinks

Corinna Vinschen corinna-cygwin@cygwin.com
Fri May 7 21:20:49 GMT 2021


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


More information about the Cygwin mailing list