Change in logical link behaviour
Corinna Vinschen
corinna-cygwin@cygwin.com
Tue Mar 3 14:19:00 GMT 2020
On Mar 3 14:17, Rainer Emrich wrote:
> Dear Corinna,
>
> Am 02.03.2020 um 17:48 schrieb Corinna Vinschen:
> > On Feb 29 14:10, Rainer Emrich wrote:
> >> I try to reliably determine if native Windows symlink are working for a
> >> current cygwin environment in a shell script.
> >> [...]
> >> On cygwin 3.1.4 I get:
> >>
> >>
> >> Directory: D:\cygwin\home\rainer\temp
> >>
> >>
> >> Mode LastWriteTime Length Name
> >> ---- ------------- ------ ----
> >> d---- 29.02.2020 13:58 asdfgh-1
> >>
> >> So now there is no indication that this is a link. Is this new behaviour
> >> intended or a bug?
> >>
> >> I did not try on Windows 10, I'm still on windows 7.
> >
> > I can't reproduce this behaviour. Keep in mind that, [bla]
> I know all the implications. I have to test in an unknown cygwin
> environment if it is possible to set native symlinks.
> >
> > So, on Windows 7 in an elevated shell:
> >
> > # id -G | grep -Eq '\<544\>' && echo elevated || echo non-elevated
> > elevated
> > # uname -a
> > CYGWIN_NT-6.1 vmbert764 3.1.4(0.340/5/3) 2020-02-19 08:49 x86_64 Cygwin
> > # mkdir qwe
> > # cd qwe
> > # export CYGWIN="winsymlinks:nativestrict"
> > # touch foo
> > # ln -s foo bar
> > # cmd /c dir /a
> > Volume in drive C has no label.
> > Volume Serial Number is A8E0-A24E
> >
> > Directory of C:\cygwin64\home\corinna\qwe
> >
> > 2020-03-02 17:31 <DIR> .
> > 2020-03-02 17:31 <DIR> ..
> > 2020-03-02 17:31 <SYMLINK> bar [foo]
> > 2020-03-02 17:31 0 foo
> > 2 File(s) 0 bytes
> > 2 Dir(s) 7.907.352.576 bytes free
> >
> Yes, this is the same for me, but if you use the powershell
>
> # powershell "& {Get-Item -Path bar | Select-Object}"
>
> on cygwin 3.0.7 you get
>
> Directory: D:\cygwin\home\rainer\temp
>
> Mode LastWriteTime Length Name
> ---- ------------- ------ ----
> -a---l 03.03.2020 14:09 0 bar
>
> and on cygwin 3.1.4 you get
>
> Directory: D:\cygwin\home\rainer\temp
>
> Mode LastWriteTime Length Name
> ---- ------------- ------ ----
> -a--- 03.03.2020 14:09 0 bar
>
>
> The only difference is the used cygwin version. So, I don't understand
> what has changed.
Nothing has changed in terms of symlink handling. Are you saying that
`cmd /c dir /a' shows
2020-03-03 14:21 <SYMLINK> bar [foo]
but powershell shows
-a--- 03.03.2020 14:21 0 bar
for the same file? That would be most puzzeling but certainly outside
of Cygwin's control.
So I created a symlink again on W7 with Cygwin 3.1.4 and `export
CYGWIN=winsymlinks:nativestrict', and tried with cmd *and* powershell
(which I usually don't touch) and I see
# uname -a
CYGWIN_NT-6.1 vmbert764 3.1.4(0.340/5/3) 2020-02-19 08:49 x86_64 Cygwin
# setenv CYGWIN winsymlinks:nativestrict
# ln -s foo bar
# cmd /c dir /a bar
Volume in drive C has no label.
Volume Serial Number is A8E0-A24E
Directory of C:\cygwin64\home\corinna\qwe
03.03.2020 14:30 <SYMLINK> bar [foo]
1 File(s) 0 bytes
0 Dir(s) 7.929.241.600 bytes free
# powershell "& {Get-Item -Path bar | Select-Object}"
Directory: C:\cygwin64\home\corinna\qwe
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a--- 03.03.2020 14:30 0 bar
Aha! So powershell does not show the 'l'.
Let's try the same on Windows 10:
# uname.ORIG -a
CYGWIN_NT-10.0 vmbert10 3.1.5(0.340/5/3) 2020-03-02 18:46 x86_64 Cygwin
# setenv CYGWIN winsymlinks:nativestrict
# ln -s foo bar
# cmd /c dir /a bar
Volume in drive C has no label.
Volume Serial Number is C65C-2A36
Directory of C:\cygwin64\home\corinna\tmp
2020-03-03 14:33 <SYMLINK> bar [foo]
1 File(s) 0 bytes
0 Dir(s) 23,112,925,184 bytes free
# powershell "& {Get-Item -Path bar | Select-Object}"
Directory: C:\cygwin64\home\corinna\tmp
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a---l 2020-03-03 14:33 0 bar
Aha! powershell shows the 'l'. Also, notice how the number of
mode bits seem to be only 5 on Windows 7:
-a---
^^^^^
12345
but *6* on Windows 10:
-a---l
^^^^^^
123456
On Windows 10 it shows 6 mode bits for non-symlinks as well, so the 'l'
mode is not just missing on Windows 7 in this specific case, but a
generic difference. From my POV, this is just a shortcoming of W7
powershell. Keep in mind that the output of powershell has nothing to
do with Cygwin itself.
Corinna
--
Corinna Vinschen
Cygwin Maintainer
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://cygwin.com/pipermail/cygwin/attachments/20200303/2651b72b/attachment.sig>
More information about the Cygwin
mailing list