检查cygwin中符号链接类型的区别 [英] check the difference of symlink type in cygwin

查看:44
本文介绍了检查cygwin中符号链接类型的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我同时使用winsymlinks:native和cygwin符号链接,这取决于Windows是否需要并且可以遵循该链接.我想用一种cygwin的方法来查看它是哪种符号链接,因为它只看到一个符号链接,而DOS却看到了区别.我需要了解diff,以便我可以处理rsyncing/etc/并保留(或重新创建)符号链接的类型.

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).

我有权限创建dos本地权限,并具有设置以下任一功能的功能:

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将它们全部视为符号链接:

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知道本机符号链接:或从DOS中看到:

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

那么,在CYGWIN中查看该如何链接?当我同步这些符号链接时,cygwin将使它们在目的地处的所有类型均与CYGWIN env var中设置的种类相同.我想将符号链接类型保留在rsync的目标位置中,或者至少将其通过源文件夹,找出类型并在目标位置进行更改. stat 也仅将它们报告为符号链接,看不到差异.

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.

添加此部分是因为我讨厌为什么需要(或想要)这样做?"答案:

为什么我要混合符号链接?我尝试将我的整个CYGWIN env var设置为 CYGWIN = winsymlinks:native CYGWIN = winsymlinks:nativestrict ,但是在某些软件包安装过程中(主要使用 apt-cyg )我提取了一些软件包的TAR时发生了错误,因此我忽略了这一点,仅在需要时才调用CYGWIN = winsymlinks:native(如果Windows需要遵循链接).我认为这些软件包是从初始CYGWIN setup.exe作为cygwin符号链接安装的,因此全局设置该值将在以后造成问题.我也有CYGWIN = winsymlinks:nativestrict设置创建一个实际的"/usr/bin/"文件夹(可以在资源管理器中看到),但是cygwin将/bin挂载为/usr/bin,因此您可以提取未在以下目录中找到的软件包.西格温.

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.

而且仅仅是因为有些符号链接我不希望Windows知道或关注.

And also just because there are some symlinks I DON'T want Windows to know about or follow.

推荐答案

我最终编写了此脚本.cygwin中的测试是调用dos命令和grep获取所需的信息.

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

这篇关于检查cygwin中符号链接类型的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆