Cygwin: AF_LOCAL: allow opening with the O_PATH flag

If that flag is not set, or if an attempt is made to open a different
type of socket, the errno is now EOPNOTSUPP instead of ENXIO.  This is
consistent with POSIX, starting with the 2016 edition.  Earlier
editions were silent on this issue.

Opening is done in a (new) fhandler_socket_local::open method by
calling fhandler_base::open_fs.

Also add a corresponding fhandler_socket_local::close method.
This commit is contained in:
Ken Brown
2020-01-23 14:39:15 -05:00
parent 9042d0ce65
commit 3a2191653a
2 changed files with 22 additions and 0 deletions

View File

@@ -634,6 +634,26 @@ fhandler_socket_local::dup (fhandler_base *child, int flags)
return fhandler_socket_wsock::dup (child, flags);
}
int
fhandler_socket_local::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_local::close ()
{
if (get_flags () & O_PATH)
return fhandler_base::close ();
else
return fhandler_socket_wsock::close ();
}
int __reg2
fhandler_socket_local::fstat (struct stat *buf)
{