Cygwin: Add winsymlinks:sys

Add winsymlinks:sys, to explicitly select always using plain files with
the system attribute containing a magic cookie to represent a symlink.
This commit is contained in:
Jon Turney 2021-07-17 15:51:11 +01:00
parent 66eefa25f2
commit 38965159df
No known key found for this signature in database
GPG Key ID: C7C86F0370285C81
5 changed files with 43 additions and 12 deletions

View File

@ -82,6 +82,8 @@ set_winsymlinks (const char *buf)
allow_winsymlinks = WSYM_lnk; allow_winsymlinks = WSYM_lnk;
else if (ascii_strncasematch (buf, "lnk", 3)) else if (ascii_strncasematch (buf, "lnk", 3))
allow_winsymlinks = WSYM_lnk; allow_winsymlinks = WSYM_lnk;
else if (ascii_strncasematch (buf, "sys", 3))
allow_winsymlinks = WSYM_sysfile;
/* Make sure to try native symlinks only on systems supporting them. */ /* Make sure to try native symlinks only on systems supporting them. */
else if (ascii_strncasematch (buf, "native", 6)) else if (ascii_strncasematch (buf, "native", 6))
allow_winsymlinks = ascii_strcasematch (buf + 6, "strict") allow_winsymlinks = ascii_strcasematch (buf + 6, "strict")

View File

@ -57,7 +57,8 @@ enum winsym_t
WSYM_lnk, WSYM_lnk,
WSYM_native, WSYM_native,
WSYM_nativestrict, WSYM_nativestrict,
WSYM_nfs WSYM_nfs,
WSYM_sysfile,
}; };
exit_states NO_COPY exit_state; exit_states NO_COPY exit_state;

View File

@ -2071,6 +2071,7 @@ symlink_worker (const char *oldpath, path_conv &win32_newpath, bool isdevice)
/* On FSes not supporting reparse points, or in case of an error /* On FSes not supporting reparse points, or in case of an error
creating the WSL symlink, fall back to creating the plain old creating the WSL symlink, fall back to creating the plain old
SYSTEM file symlink. */ SYSTEM file symlink. */
wsym_type = WSYM_sysfile;
break; break;
default: default:
break; break;
@ -2211,7 +2212,7 @@ symlink_worker (const char *oldpath, path_conv &win32_newpath, bool isdevice)
* sizeof (WCHAR); * sizeof (WCHAR);
cp += *plen; cp += *plen;
} }
else else /* wsym_type == WSYM_sysfile */
{ {
/* Default technique creating a symlink. */ /* Default technique creating a symlink. */
buf = tp.t_get (); buf = tp.t_get ();

View File

@ -76,11 +76,17 @@ in addition to the normal UNIX argv list. Defaults to not set.</para>
</listitem> </listitem>
<listitem> <listitem>
<para><envar>winsymlinks:{lnk,native,nativestrict}</envar> - if set to just <para><envar>winsymlinks:{lnk,native,nativestrict,sys}</envar></para>
<itemizedlist mark="square">
<listitem>
<para>If set to just
<literal>winsymlinks</literal> or <literal>winsymlinks:lnk</literal>, <literal>winsymlinks</literal> or <literal>winsymlinks:lnk</literal>,
Cygwin creates symlinks as Windows shortcuts with a special header and Cygwin creates symlinks as Windows shortcuts with a special header and
the R/O attribute set.</para> the R/O attribute set.</para>
</listitem>
<listitem>
<para>If set to <literal>winsymlinks:native</literal> or <para>If set to <literal>winsymlinks:native</literal> or
<literal>winsymlinks:nativestrict</literal>, Cygwin creates symlinks as <literal>winsymlinks:nativestrict</literal>, Cygwin creates symlinks as
native Windows symlinks on filesystems and OS versions supporting them.</para> native Windows symlinks on filesystems and OS versions supporting them.</para>
@ -92,9 +98,21 @@ some reason, it will fall back to creating Cygwin default symlinks
with <literal>winsymlinks:native</literal>, while with with <literal>winsymlinks:native</literal>, while with
<literal>winsymlinks:nativestrict</literal> the <literal>symlink(2)</literal> <literal>winsymlinks:nativestrict</literal> the <literal>symlink(2)</literal>
system call will immediately fail.</para> system call will immediately fail.</para>
</listitem>
<listitem>
<para>If set to <literal>winsymlinks:sys</literal>, Cygwin creates symlinks as
plain files with the <literal>system</literal> attribute, containing a magic
cookie followed by the path to which the link points.</para>
</listitem>
</itemizedlist>
<para>Note that this setting has no effect where Cygwin knows that the
filesystem only supports a creating symlinks in a specific way.</para>
<para>For more information on symbolic links, see <para>For more information on symbolic links, see
<xref linkend="pathnames-symlinks"></xref>.</para> <xref linkend="pathnames-symlinks"></xref>.</para>
</listitem> </listitem>
<listitem> <listitem>

View File

@ -389,17 +389,26 @@ ways.</para>
<itemizedlist mark="bullet"> <itemizedlist mark="bullet">
<listitem> <listitem>
<para>The default symlinks created by Cygwin are either special reparse <para>The default symlinks created by Cygwin are:</para>
points shared with WSL on Windows 10, or plain files containing a magic
cookie followed by the path to which the link points. The reparse point
is used on NTFS, the plain file on almost any other filesystem.</para>
<note><para>Symlinks created by really old Cygwin releases (prior to <itemizedlist mark="square">
Cygwin 1.7.0) are usually readable. However, you could run into problems <listitem>
if you're now using another character set than the one you used when <para>special reparse points shared with WSL (on NTFS on Windows 10 1607
creating these symlinks (see <xref linkend="setup-locale-problems"></xref>). or later)</para>
</listitem>
<listitem>
<para>plain files with the <literal>system</literal> attribute, containing
a magic cookie followed by the path to which the link points.
</para>
<note><para>Symlinks of this type created by really old Cygwin releases
(prior to Cygwin 1.7.0) are usually readable. However, you could run into
problems if you're now using another character set than the one you used
when creating these symlinks (see <xref
linkend="setup-locale-problems"></xref>).
</para></note> </para></note>
</listitem> </listitem>
</itemizedlist>
</listitem>
<listitem> <listitem>
<para>On filesystems mounted via Microsoft's NFS client, Cygwin always <para>On filesystems mounted via Microsoft's NFS client, Cygwin always