From: Jon Turney <jon.turney@dronecode.org.uk>
To: cygwin-patches@cygwin.com
Cc: Jon Turney <jon.turney@dronecode.org.uk>
Subject: [PATCH 3/3] Add winsymlinks:wslstrict
Date: Mon, 19 Jul 2021 17:31:34 +0100 [thread overview]
Message-ID: <20210719163134.9230-4-jon.turney@dronecode.org.uk> (raw)
In-Reply-To: <20210719163134.9230-1-jon.turney@dronecode.org.uk>
Add winsymlinks:wslstrict, so we have a spanning set of values for
winsymlinks.
---
winsup/cygwin/environ.cc | 3 +++
winsup/cygwin/globals.cc | 1 +
winsup/cygwin/path.cc | 7 +++++++
winsup/doc/cygwinenv.xml | 15 ++++++++++++++-
4 files changed, 25 insertions(+), 1 deletion(-)
diff --git a/winsup/cygwin/environ.cc b/winsup/cygwin/environ.cc
index a7a52feeb..b53b018fd 100644
--- a/winsup/cygwin/environ.cc
+++ b/winsup/cygwin/environ.cc
@@ -88,6 +88,9 @@ set_winsymlinks (const char *buf)
else if (ascii_strncasematch (buf, "native", 6))
allow_winsymlinks = ascii_strcasematch (buf + 6, "strict")
? WSYM_nativestrict : WSYM_native;
+ else if (ascii_strncasematch (buf, "wsl", 3))
+ allow_winsymlinks = ascii_strcasematch (buf + 3, "strict")
+ ? WSYM_wslstrict : WSYM_default;
}
/* The structure below is used to set up an array which is used to
diff --git a/winsup/cygwin/globals.cc b/winsup/cygwin/globals.cc
index b15980bb3..9459d8bcb 100644
--- a/winsup/cygwin/globals.cc
+++ b/winsup/cygwin/globals.cc
@@ -59,6 +59,7 @@ enum winsym_t
WSYM_nativestrict,
WSYM_nfs,
WSYM_magic,
+ WSYM_wslstrict,
};
exit_states NO_COPY exit_state;
diff --git a/winsup/cygwin/path.cc b/winsup/cygwin/path.cc
index edb3b27ee..57ec8be72 100644
--- a/winsup/cygwin/path.cc
+++ b/winsup/cygwin/path.cc
@@ -2062,12 +2062,19 @@ symlink_worker (const char *oldpath, path_conv &win32_newpath, bool isdevice)
wsym_type = WSYM_default;
fallthrough;
case WSYM_default:
+ case WSYM_wslstrict:
if (win32_newpath.fs_flags () & FILE_SUPPORTS_REPARSE_POINTS)
{
res = symlink_wsl (oldpath, win32_newpath);
if (!res)
__leave;
}
+ /* Strictly wsl? */
+ if (wsym_type == WSYM_wslstrict)
+ {
+ __seterrno ();
+ __leave;
+ }
/* 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. */
diff --git a/winsup/doc/cygwinenv.xml b/winsup/doc/cygwinenv.xml
index 496088292..b98e27243 100644
--- a/winsup/doc/cygwinenv.xml
+++ b/winsup/doc/cygwinenv.xml
@@ -76,7 +76,7 @@ in addition to the normal UNIX argv list. Defaults to not set.</para>
</listitem>
<listitem>
-<para><envar>winsymlinks:{lnk,magic,native,nativestrict}</envar></para>
+<para><envar>winsymlinks:{lnk,magic,native,nativestrict,wsl,wslstrict}</envar></para>
<itemizedlist mark="square">
<listitem>
@@ -105,6 +105,19 @@ with <literal>winsymlinks:native</literal>, while with
<literal>winsymlinks:nativestrict</literal> the <literal>symlink(2)</literal>
system call will immediately fail.</para>
</listitem>
+
+<listitem>
+<para>If set to <literal>winsymlinks:wsl</literal> or
+<literal>winsymlinks:wslstrict</literal>, Cygwin creates symlinks as special
+reparse points, defined by WSL.</para>
+
+<para>With <literal>winsymlinks:wsl</literal>, if Cygwin fails to create a WSL
+symlink for some reason, it will fall back to creating a Cygwin magic cookie
+symlink, while with <literal>winsymlinks:wslstrict</literal> the
+<literal>symlink(2)</literal> system call will immediately fail.</para>
+
+<para><literal>winsymlinks:wsl</literal> is the default behaviour.</para>
+</listitem>
</itemizedlist>
<para>For more information on symbolic links, see
--
2.32.0
next prev 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 ` [PATCH 2/3] Add winsymlinks:magic Jon Turney
2021-07-19 16:31 ` Jon Turney [this message]
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-4-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).