[PATCH v2 4/5] Cygwin: AF_LOCAL: fix fcntl and dup if O_PATH is set
Corinna Vinschen
corinna-cygwin@cygwin.com
Wed Jan 29 20:58:00 GMT 2020
On Jan 29 17:22, Ken Brown wrote:
> For fcntl this requires a new method, fhandler_socket_local::fcntl,
> which calls fhandler_base::fcntl if O_PATH is set and
> fhandler_socket_wsock::fcntl otherwise.
The patchset looks great. Please apply with just a minor change:
Can you please add a hint why using fhandler_base::dup and
fhandler_base::fcntl is sufficient, despite fhandler_disk_file has its
own methods? It's clear from looking at those functions, but a quick
description in the commit message and a one-line comment each in the
source might be helpful when debugging at one point.
Thanks,
Corinna
> ---
> winsup/cygwin/fhandler.h | 1 +
> winsup/cygwin/fhandler_socket_local.cc | 12 ++++++++++++
> 2 files changed, 13 insertions(+)
>
> diff --git a/winsup/cygwin/fhandler.h b/winsup/cygwin/fhandler.h
> index c54780ef6..1b477f633 100644
> --- a/winsup/cygwin/fhandler.h
> +++ b/winsup/cygwin/fhandler.h
> @@ -836,6 +836,7 @@ class fhandler_socket_local: public fhandler_socket_wsock
>
> int open (int flags, mode_t mode = 0);
> int close ();
> + int fcntl (int cmd, intptr_t);
> int __reg2 fstat (struct stat *buf);
> int __reg2 fstatvfs (struct statvfs *buf);
> int __reg1 fchmod (mode_t newmode);
> diff --git a/winsup/cygwin/fhandler_socket_local.cc b/winsup/cygwin/fhandler_socket_local.cc
> index 76815a611..531f574b0 100644
> --- a/winsup/cygwin/fhandler_socket_local.cc
> +++ b/winsup/cygwin/fhandler_socket_local.cc
> @@ -628,6 +628,9 @@ fhandler_socket_local::af_local_set_secret (char *buf)
> int
> fhandler_socket_local::dup (fhandler_base *child, int flags)
> {
> + if (get_flags () & O_PATH)
> + return fhandler_base::dup (child, flags);
> +
> fhandler_socket_local *fhs = (fhandler_socket_local *) child;
> fhs->set_sun_path (get_sun_path ());
> fhs->set_peer_sun_path (get_peer_sun_path ());
> @@ -654,6 +657,15 @@ fhandler_socket_local::close ()
> return fhandler_socket_wsock::close ();
> }
>
> +int
> +fhandler_socket_local::fcntl (int cmd, intptr_t arg)
> +{
> + if (get_flags () & O_PATH)
> + return fhandler_base::fcntl (cmd, arg);
> + else
> + return fhandler_socket_wsock::fcntl (cmd, arg);
> +}
> +
> int __reg2
> fhandler_socket_local::fstat (struct stat *buf)
> {
> --
> 2.21.0
--
Corinna Vinschen
Cygwin Maintainer
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://cygwin.com/pipermail/cygwin-patches/attachments/20200129/50a0baa1/attachment.sig>
More information about the Cygwin-patches
mailing list