I use both winsymlinks:native and cygwin symlinks depending on if windows needs to and CAN follow the link. I'd like to have a cygwin way to see what kind of symlink it is since it just sees a symlink but DOS sees the difference. I need to know the diff so I can handle rsyncing/etc/ and have the type of symlink preserved (or recreated).
I have the perms to create the dos native ones and have functions to set either:
$ touch test
# cygwin style symlink
$ CYGWIN= ln -s test t1
# WINDOWS style
$ CYGWIN=winsymlinks:native ln -s test t2
# for good measure make one the DOS way
$ cmd /c mklink t3 test
symbolic link created for t3 <<===>> test
cygwin sees them all as symlinks:
$ ls -l
total 1
lrwxrwxrwx 1 user Users 4 Jun 14 11:06 t1 -> test
lrwxrwxrwx 1 user Users 4 Jun 14 11:06 t2 -> test
lrwxrwxrwx 1 user Users 4 Jun 14 11:06 t3 -> test
-rw-rw-rw-+ 1 user Users 0 Jun 14 11:05 test
Windows knows the native symlinks: Or as seen from DOS:
$ cmd /c dir /a
Volume in drive C is Windows
Directory of C:\Cygwin-32\tmp
06/14/2014 11:06 AM 22 t1
06/14/2014 11:06 AM <SYMLINK> t2 [test]
06/14/2014 11:06 AM <SYMLINK> t3 [test]
06/14/2014 11:05 AM 0 test
4 File(s) 22 bytes
So how do I tell what kind of symlink it is when viewed in CYGWIN? When I rsync these symlinks, cygwin will make all of them at the destination the kind set in the CYGWIN env var. I would like to keep the symlink type in the rsync'd destination or at the very least go through the source folder, figure out the type and change them at the destination. stat
also only reports them as symlinks, does not see the difference.
Adding this section because I HATE the "Why do you need (or want) to do that?" answers:
Why do I mix symlinks? I tried setting my overall CYGWIN env var to CYGWIN=winsymlinks:native
and CYGWIN=winsymlinks:nativestrict
but during some package installs (mostly using apt-cyg
) I have had errors in the extracted TAR of a few packages so I left that out and only call CYGWIN=winsymlinks:native as I need them (if windows needs to follow the link). I think the packages are installed as cygwin symlinks from the initial CYGWIN setup.exe so setting that value globally will create the problem later. I've also had the CYGWIN=winsymlinks:nativestrict setting create an actual "/usr/bin/" folder (can see in explorer) but cygwin has /bin mounted as /usr/bin so you get packages extracted that are not found in cygwin.
And also just because there are some symlinks I DON'T want Windows to know about or follow.
I ended up scripting this. The test in cygwin would be to call a dos command and grep for the info needed.
if fsutil reparsepoint query "$1" | grep -iq "Tag value: Symbolic Link" ; then
echo "Windows Native Symlink"
fi