public inbox for cygwin-patches@cygwin.com
 help / color / mirror / Atom feed
From: Jon Turney <jon.turney@dronecode.org.uk>
To: cygwin-patches@cygwin.com
Cc: Jon Turney <jon.turney@dronecode.org.uk>
Subject: [PATCH 2/3] Add winsymlinks:magic
Date: Mon, 19 Jul 2021 17:31:33 +0100	[thread overview]
Message-ID: <20210719163134.9230-3-jon.turney@dronecode.org.uk> (raw)
In-Reply-To: <20210719163134.9230-1-jon.turney@dronecode.org.uk>

Add winsymlinks:magic, to explicitly select always using plain files
containing a magic cookie to represent a symlink.
---
 winsup/cygwin/environ.cc |  2 ++
 winsup/cygwin/globals.cc |  3 ++-
 winsup/cygwin/path.cc    |  3 ++-
 winsup/doc/cygwinenv.xml | 16 +++++++++++++++-
 winsup/doc/pathnames.xml |  7 +++----
 5 files changed, 24 insertions(+), 7 deletions(-)

diff --git a/winsup/cygwin/environ.cc b/winsup/cygwin/environ.cc
index 3a03657db..a7a52feeb 100644
--- a/winsup/cygwin/environ.cc
+++ b/winsup/cygwin/environ.cc
@@ -82,6 +82,8 @@ set_winsymlinks (const char *buf)
     allow_winsymlinks = WSYM_lnk;
   else if (ascii_strncasematch (buf, "lnk", 3))
     allow_winsymlinks = WSYM_lnk;
+  else if (ascii_strncasematch (buf, "magic", 5))
+    allow_winsymlinks = WSYM_magic;
   /* Make sure to try native symlinks only on systems supporting them. */
   else if (ascii_strncasematch (buf, "native", 6))
     allow_winsymlinks = ascii_strcasematch (buf + 6, "strict")
diff --git a/winsup/cygwin/globals.cc b/winsup/cygwin/globals.cc
index 066026421..b15980bb3 100644
--- a/winsup/cygwin/globals.cc
+++ b/winsup/cygwin/globals.cc
@@ -57,7 +57,8 @@ enum winsym_t
   WSYM_lnk,
   WSYM_native,
   WSYM_nativestrict,
-  WSYM_nfs
+  WSYM_nfs,
+  WSYM_magic,
 };
 
 exit_states NO_COPY exit_state;
diff --git a/winsup/cygwin/path.cc b/winsup/cygwin/path.cc
index cd029c5b4..edb3b27ee 100644
--- a/winsup/cygwin/path.cc
+++ b/winsup/cygwin/path.cc
@@ -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
 	     creating the WSL symlink, fall back to creating the plain old
 	     SYSTEM file symlink. */
+	  wsym_type = WSYM_magic;
 	  break;
 	default:
 	  break;
@@ -2211,7 +2212,7 @@ symlink_worker (const char *oldpath, path_conv &win32_newpath, bool isdevice)
 		  * sizeof (WCHAR);
 	  cp += *plen;
 	}
-      else
+      else /* wsym_type == WSYM_magic */
 	{
 	  /* Default technique creating a symlink. */
 	  buf = tp.t_get ();
diff --git a/winsup/doc/cygwinenv.xml b/winsup/doc/cygwinenv.xml
index a52b6ac19..496088292 100644
--- a/winsup/doc/cygwinenv.xml
+++ b/winsup/doc/cygwinenv.xml
@@ -76,11 +76,23 @@ in addition to the normal UNIX argv list.  Defaults to not set.</para>
 </listitem>
 
 <listitem>
-<para><envar>winsymlinks:{lnk,native,nativestrict}</envar> - if set to just
+<para><envar>winsymlinks:{lnk,magic,native,nativestrict}</envar></para>
+
+<itemizedlist mark="square">
+<listitem>
+<para>If set to just
 <literal>winsymlinks</literal> or <literal>winsymlinks:lnk</literal>,
 Cygwin creates symlinks as Windows shortcuts with a special header and
 the R/O attribute set.</para>
+</listitem>
 
+<listitem>
+<para>If set to <literal>winsymlinks:magic</literal> Cygwin creates symlinks
+as plain files containing a magic cookie followed by the path to which the
+link points.</para>
+</listitem>
+
+<listitem>
 <para>If set to <literal>winsymlinks:native</literal> or
 <literal>winsymlinks:nativestrict</literal>, Cygwin creates symlinks as
 native Windows symlinks on filesystems and OS versions supporting them.</para>
@@ -92,6 +104,8 @@ some reason, it will fall back to creating Cygwin default symlinks
 with <literal>winsymlinks:native</literal>, while with
 <literal>winsymlinks:nativestrict</literal> the <literal>symlink(2)</literal>
 system call will immediately fail.</para>
+</listitem>
+</itemizedlist>
 
 <para>For more information on symbolic links, see
 <xref linkend="pathnames-symlinks"></xref>.</para>
diff --git a/winsup/doc/pathnames.xml b/winsup/doc/pathnames.xml
index 2966bdabf..132d8a3e1 100644
--- a/winsup/doc/pathnames.xml
+++ b/winsup/doc/pathnames.xml
@@ -389,10 +389,9 @@ ways.</para>
 <itemizedlist mark="bullet">
 
 <listitem>
-<para>The default symlinks created by Cygwin are either special reparse
-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>
+<para>The default symlinks created by Cygwin are either special reparse points
+shared with WSL on NTFS on Windows 10 1607 or later, otherwise plain files
+containing a magic cookie followed by the path to which the link points.</para>
 
 <note><para>Symlinks created by really old Cygwin releases (prior to
 Cygwin 1.7.0) are usually readable.  However, you could run into problems
-- 
2.32.0


  parent reply	other threads:[~2021-07-19 16:32 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-19 16:31 [PATCH 0/3] Add more winsymlinks values Jon Turney
2021-07-19 16:31 ` [PATCH 1/3] Rename WSYM_sysfile to WSM_default Jon Turney
2021-07-19 16:31 ` Jon Turney [this message]
2021-07-19 16:31 ` [PATCH 3/3] Add winsymlinks:wslstrict Jon Turney
2021-07-21  8:19 ` [PATCH 0/3] Add more winsymlinks values Corinna Vinschen
2021-07-21 10:24   ` Christian Franke
2021-07-22  8:03     ` Corinna Vinschen
2021-07-22 13:53   ` Jon Turney
2021-07-22 14:21     ` Corinna Vinschen
2021-07-28 19:55       ` Jon Turney
2021-07-29 10:23         ` Corinna Vinschen
2021-07-29 10:40           ` Corinna Vinschen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210719163134.9230-3-jon.turney@dronecode.org.uk \
    --to=jon.turney@dronecode.org.uk \
    --cc=cygwin-patches@cygwin.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).