* fhandler_socket.cc (fhandler_socket::ioctl): Handle the different

ideas of u_long between Winsock and Cygwin applications on x86_64.
	Add long comment.
This commit is contained in:
Corinna Vinschen 2014-05-13 16:07:50 +00:00
parent 2915feb81e
commit d4ff931bf8
3 changed files with 30 additions and 1 deletions

View File

@ -1,3 +1,9 @@
2014-05-13 Corinna Vinschen <corinna@vinschen.de>
* fhandler_socket.cc (fhandler_socket::ioctl): Handle the different
ideas of u_long between Winsock and Cygwin applications on x86_64.
Add long comment.
2014-05-09 Christopher Faylor <me.cygwin2014@cgf.cx> 2014-05-09 Christopher Faylor <me.cygwin2014@cgf.cx>
* signal.cc (sigprocmask): Fix strace output to include "how". * signal.cc (sigprocmask): Fix strace output to include "how".

View File

@ -2093,7 +2093,22 @@ fhandler_socket::ioctl (unsigned int cmd, void *p)
} }
break; break;
} }
/* From this point on we handle only ioctl commands which are understood by
Winsock. However, we have a problem, which is, the different size of
u_long in Windows and 64 bit Cygwin. This affects the definitions of
FIOASYNC, etc, because they are defined in terms of sizeof(u_long).
So we have to use case labels which are independent of the sizeof
u_long. Since we're redefining u_long at the start of this file to
matching Winsock's idea of u_long, we can use the real definitions in
calls to Windows. In theory we also have to make sure to convert the
different ideas of u_long between the application and Winsock, but
fortunately, the parameters defined as u_long pointers are on Linux
and BSD systems defined as int pointer, so the applications will
use a type of the expected size. Hopefully. */
case FIOASYNC: case FIOASYNC:
#ifdef __x86_64__
case _IOW('f', 125, unsigned long):
#endif
res = WSAAsyncSelect (get_socket (), winmsg, WM_ASYNCIO, res = WSAAsyncSelect (get_socket (), winmsg, WM_ASYNCIO,
*(int *) p ? ASYNC_MASK : 0); *(int *) p ? ASYNC_MASK : 0);
syscall_printf ("Async I/O on socket %s", syscall_printf ("Async I/O on socket %s",
@ -2104,6 +2119,9 @@ fhandler_socket::ioctl (unsigned int cmd, void *p)
WSAEventSelect (get_socket (), wsock_evt, EVENT_MASK); WSAEventSelect (get_socket (), wsock_evt, EVENT_MASK);
break; break;
case FIONREAD: case FIONREAD:
#ifdef __x86_64__
case _IOR('f', 127, unsigned long):
#endif
res = ioctlsocket (get_socket (), FIONREAD, (u_long *) p); res = ioctlsocket (get_socket (), FIONREAD, (u_long *) p);
if (res == SOCKET_ERROR) if (res == SOCKET_ERROR)
set_winsock_errno (); set_winsock_errno ();
@ -2111,6 +2129,11 @@ fhandler_socket::ioctl (unsigned int cmd, void *p)
default: default:
/* Sockets are always non-blocking internally. So we just note the /* Sockets are always non-blocking internally. So we just note the
state here. */ state here. */
#ifdef __x86_64__
/* Convert the different idea of u_long in the definition of cmd. */
if (((cmd >> 16) & IOCPARM_MASK) == sizeof (unsigned long))
cmd = (cmd & ~(IOCPARM_MASK << 16)) | (sizeof (u_long) << 16);
#endif
if (cmd == FIONBIO) if (cmd == FIONBIO)
{ {
syscall_printf ("socket is now %sblocking", syscall_printf ("socket is now %sblocking",

View File

@ -1825,7 +1825,7 @@ pwdgrp::fetch_account_from_windows (fetch_user_arg_t &arg, cyg_ldap *pldap)
posix_name, sid.string (sidstr), uid); posix_name, sid.string (sidstr), uid);
/* For non-users, create a passwd entry which doesn't allow interactive /* For non-users, create a passwd entry which doesn't allow interactive
logon. Unless it's the SYSTEM account. This conveniently allows to logon. Unless it's the SYSTEM account. This conveniently allows to
long interactively as SYSTEM for debugging purposes. */ logon interactively as SYSTEM for debugging purposes. */
else if (acc_type != SidTypeUser && sid != well_known_system_sid) else if (acc_type != SidTypeUser && sid != well_known_system_sid)
__small_swprintf (linebuf, L"%W:*:%u:%u:,%W:/:/sbin/nologin", __small_swprintf (linebuf, L"%W:*:%u:%u:,%W:/:/sbin/nologin",
posix_name, uid, gid, sid.string (sidstr)); posix_name, uid, gid, sid.string (sidstr));