From: Ken Brown <kbrown@cornell.edu>
To: cygwin-patches@cygwin.com
Subject: [PATCH v2 3/6] Cygwin: always recognize AF_UNIX sockets as reparse points
Date: Sun, 4 Oct 2020 12:49:45 -0400 [thread overview]
Message-ID: <20201004164948.48649-4-kbrown@cornell.edu> (raw)
In-Reply-To: <20201004164948.48649-1-kbrown@cornell.edu>
If __WITH_AF_UNIX is defined when Cygwin is built, then a named
AF_UNIX socket is represented by a reparse point with a
Cygwin-specific tag and GUID. Make such files recognizable as reparse
points (but not as sockets) even if __WITH_AF_UNIX is not defined.
That way utilities such as 'ls' and 'rm' still behave reasonably.
This requires two changes:
- Define the GUID __cygwin_socket_guid unconditionally.
- Make check_reparse_point_target return PATH_REP on a reparse point
of this type if __WITH_AF_UNIX is not defined.
---
winsup/cygwin/fhandler_socket_unix.cc | 17 +++++++++--------
winsup/cygwin/path.cc | 10 ++++++----
2 files changed, 15 insertions(+), 12 deletions(-)
diff --git a/winsup/cygwin/fhandler_socket_unix.cc b/winsup/cygwin/fhandler_socket_unix.cc
index d7bb1090e..429aa8a90 100644
--- a/winsup/cygwin/fhandler_socket_unix.cc
+++ b/winsup/cygwin/fhandler_socket_unix.cc
@@ -8,9 +8,17 @@
Cygwin license. Please consult the file "CYGWIN_LICENSE" for
details. */
+#include "winsup.h"
+
+GUID __cygwin_socket_guid = {
+ .Data1 = 0xefc1714d,
+ .Data2 = 0x7b19,
+ .Data3 = 0x4407,
+ .Data4 = { 0xba, 0xb3, 0xc5, 0xb1, 0xf9, 0x2c, 0xb8, 0x8c }
+};
+
#ifdef __WITH_AF_UNIX
-#include "winsup.h"
#include <w32api/winioctl.h>
#include <asm/byteorder.h>
#include <unistd.h>
@@ -124,13 +132,6 @@ class af_unix_pkt_hdr_t
(void *)(((PBYTE)(_p)) + AF_UNIX_PKT_OFFSETOF_DATA (_p)); \
})
-GUID __cygwin_socket_guid = {
- .Data1 = 0xefc1714d,
- .Data2 = 0x7b19,
- .Data3 = 0x4407,
- .Data4 = { 0xba, 0xb3, 0xc5, 0xb1, 0xf9, 0x2c, 0xb8, 0x8c }
-};
-
/* Some error conditions on pipes have multiple status codes, unfortunately. */
#define STATUS_PIPE_NO_INSTANCE_AVAILABLE(status) \
({ NTSTATUS _s = (status); \
diff --git a/winsup/cygwin/path.cc b/winsup/cygwin/path.cc
index 2e3208d2d..4f5f03a76 100644
--- a/winsup/cygwin/path.cc
+++ b/winsup/cygwin/path.cc
@@ -2476,8 +2476,7 @@ check_reparse_point_string (PUNICODE_STRING subst)
/* Return values:
<0: Negative errno.
0: Not a reparse point recognized by us.
- >0: PATH_SYMLINK | PATH_REP for symlink or directory mount point,
- PATH_SOCKET | PATH_REP for AF_UNIX socket.
+ >0: Path flags for a recognized reparse point, always including PATH_REP.
*/
int
check_reparse_point_target (HANDLE h, bool remote, PREPARSE_DATA_BUFFER rp,
@@ -2618,15 +2617,18 @@ check_reparse_point_target (HANDLE h, bool remote, PREPARSE_DATA_BUFFER rp,
}
return -EIO;
}
-#ifdef __WITH_AF_UNIX
else if (rp->ReparseTag == IO_REPARSE_TAG_CYGUNIX)
{
PREPARSE_GUID_DATA_BUFFER rgp = (PREPARSE_GUID_DATA_BUFFER) rp;
if (memcmp (CYGWIN_SOCKET_GUID, &rgp->ReparseGuid, sizeof (GUID)) == 0)
+#ifdef __WITH_AF_UNIX
return PATH_SOCKET | PATH_REP;
+#else
+ /* Recognize this as a reparse point but not as a socket. */
+ return PATH_REP;
+#endif
}
-#endif /* __WITH_AF_UNIX */
return 0;
}
--
2.28.0
next prev parent reply other threads:[~2020-10-04 16:50 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-04 16:49 [PATCH v2 0/6] Some AF_UNIX fixes Ken Brown
2020-10-04 16:49 ` [PATCH v2 1/6] Cygwin: AF_UNIX: use FILE_OPEN_REPARSE_POINT when needed Ken Brown
2020-10-04 16:49 ` [PATCH v2 2/6] Cygwin: fix handling of known reparse points that are not symlinks Ken Brown
2020-10-04 16:49 ` Ken Brown [this message]
2020-10-04 16:49 ` [PATCH v2 4/6] Cygwin: AF_UNIX: socket: set the O_RDWR flag Ken Brown
2020-10-04 16:49 ` [PATCH v2 5/6] Cygwin: AF_UNIX: listen_pipe: check for STATUS_SUCCESS Ken Brown
2020-10-13 11:28 ` Corinna Vinschen
2020-10-13 13:18 ` Ken Brown
2020-10-13 15:31 ` Corinna Vinschen
2020-10-04 16:49 ` [PATCH v2 6/6] Cygwin: AF_UNIX: open_pipe: call recv_peer_info Ken Brown
2020-10-08 21:36 ` [PATCH v2 0/6] Some AF_UNIX fixes Ken Brown
2020-10-13 11:49 ` Corinna Vinschen
2020-10-14 16:39 ` Ken Brown
2020-10-15 4:19 ` Mark Geisert
2020-10-15 5:48 ` Brian Inglis
2020-10-15 8:16 ` Corinna Vinschen
2020-10-13 11:02 ` 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=20201004164948.48649-4-kbrown@cornell.edu \
--to=kbrown@cornell.edu \
--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).