This was done for the fhandler_socket_local class in commits
3a2191653a, 141437d374, and 477121317d, but the fhandler_socket_unix
class was overlooked.
---
winsup/cygwin/fhandler.h | 1 +
winsup/cygwin/fhandler_socket_unix.cc | 24
2 files changed, 25 insertions(+)
diff --git a/winsup/cygwin/fhandler.h b/winsup/cygwin/fhandler.h
index 21e1df172..ad90cf33d 100644
--- a/winsup/cygwin/fhandler.h
+++ b/winsup/cygwin/fhandler.h
@@ -,6 +,7 @@ class fhandler_socket_unix : public fhandler_socket
int getsockname (struct sockaddr *name, int *namelen);
int getpeername (struct sockaddr *name, int *namelen);
int shutdown (int how);
+ int open (int flags, mode_t mode = 0);
int close ();
int getpeereid (pid_t *pid, uid_t *euid, gid_t *egid);
ssize_t recvmsg (struct msghdr *msg, int flags);
diff --git a/winsup/cygwin/fhandler_socket_unix.cc
b/winsup/cygwin/fhandler_socket_unix.cc
index 9f7f86c47..eedb0847e 100644
--- a/winsup/cygwin/fhandler_socket_unix.cc
+++ b/winsup/cygwin/fhandler_socket_unix.cc
@@ -1208,6 +1208,11 @@ fhandler_socket_unix::~fhandler_socket_unix ()
int
fhandler_socket_unix::dup (fhandler_base *child, int flags)
{
+ if (get_flags () & O_PATH)
+/* We're viewing the socket as a disk file, but fhandler_base::dup
+ suffices here. */
+return fhandler_base::dup (child, flags);
+
if (fhandler_socket::dup (child, flags))
{
__seterrno ();
@@ -1801,9 +1806,23 @@ fhandler_socket_unix::shutdown (int how)
return 0;
}
+int
+fhandler_socket_unix::open (int flags, mode_t mode)
+{
+ /* We don't support opening sockets unless O_PATH is specified. */
+ if (flags & O_PATH)
+return open_fs (flags, mode);
+
+ set_errno (EOPNOTSUPP);
+ return 0;
+}
+
int
fhandler_socket_unix::close ()
{
+ if (get_flags () & O_PATH)
+return fhandler_base::close ();
+
HANDLE evt = InterlockedExchangePointer (&cwt_termination_evt, NULL);
HANDLE thr = InterlockedExchangePointer (&connect_wait_thr, NULL);
if (thr)
@@ -2281,6 +2300,11 @@ fhandler_socket_unix::ioctl (unsigned int cmd, void *p)
int
fhandler_socket_unix::fcntl (int cmd, intptr_t arg)
{
+ if (get_flags () & O_PATH)
+/* We're viewing the socket as a disk file, but
+ fhandler_base::fcntl suffices here. */
+return fhandler_base::fcntl (cmd, arg);
+
int ret = -1;
switch (cmd)
--
2.30.0