public inbox for cygwin-cvs@sourceware.org help / color / mirror / Atom feed
From: Ken Brown <kbrown@sourceware.org> To: cygwin-cvs@sourceware.org Subject: [newlib-cygwin] Cygwin: AF_UNIX: allow opening with the O_PATH flag Date: Wed, 24 Feb 2021 13:00:33 +0000 (GMT) [thread overview] Message-ID: <20210224130033.3A794393C857@sourceware.org> (raw) https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=949fe7bec564f91818bad801bda47a4ddd58fadf commit 949fe7bec564f91818bad801bda47a4ddd58fadf Author: Ken Brown <kbrown@cornell.edu> Date: Tue Feb 23 11:48:46 2021 -0500 Cygwin: AF_UNIX: allow opening with the O_PATH flag This was done for the fhandler_socket_local class in commits 3a2191653a, 141437d374, and 477121317d, but the fhandler_socket_unix class was overlooked. Diff: --- 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 @@ -1111,6 +1111,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)
reply other threads:[~2021-02-24 13:00 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20210224130033.3A794393C857@sourceware.org \ --to=kbrown@sourceware.org \ --cc=cygwin-cvs@sourceware.org \ /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: linkBe 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).