From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2210) id 59A743857C7F; Sun, 4 Oct 2020 16:54:17 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 59A743857C7F Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Ken Brown To: cygwin-cvs@sourceware.org Subject: [newlib-cygwin] Cygwin: always recognize AF_UNIX sockets as reparse points X-Act-Checkin: newlib-cygwin X-Git-Author: Ken Brown X-Git-Refname: refs/heads/master X-Git-Oldrev: 0b4beaf46f34869aa2773c08a658e8aadba496e1 X-Git-Newrev: 0e290489568675192188d98ee8070d5576deed8e Message-Id: <20201004165417.59A743857C7F@sourceware.org> Date: Sun, 4 Oct 2020 16:54:17 +0000 (GMT) X-BeenThere: cygwin-cvs@cygwin.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Cygwin core component git logs List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 04 Oct 2020 16:54:17 -0000 https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=0e290489568675192188d98ee8070d5576deed8e commit 0e290489568675192188d98ee8070d5576deed8e Author: Ken Brown Date: Tue Sep 29 16:18:15 2020 -0400 Cygwin: always recognize AF_UNIX sockets as reparse points 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. Diff: --- 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 #include #include @@ -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; }