From: Elizabeth Figura zfigura@codeweavers.com
--- dlls/ntdll/unix/cdrom.c | 5 +++-- dlls/ntdll/unix/file.c | 16 +++++++++++----- dlls/ntdll/unix/serial.c | 5 +++-- dlls/ntdll/unix/socket.c | 31 ++++++++++++++++++++----------- dlls/ntdll/unix/tape.c | 5 +++-- dlls/ntdll/unix/unix_private.h | 2 +- 6 files changed, 41 insertions(+), 23 deletions(-)
diff --git a/dlls/ntdll/unix/cdrom.c b/dlls/ntdll/unix/cdrom.c index c92ccc1185d..9e651414e9a 100644 --- a/dlls/ntdll/unix/cdrom.c +++ b/dlls/ntdll/unix/cdrom.c @@ -2819,10 +2819,11 @@ NTSTATUS cdrom_DeviceIoControl( HANDLE device, HANDLE event, PIO_APC_ROUTINE apc DWORD sz = 0; NTSTATUS status = STATUS_SUCCESS; int fd, needs_close, dev = 0; + unsigned int options;
TRACE( "%p %s %p %d %p %d %p\n", device, iocodex(code), in_buffer, in_size, out_buffer, out_size, io );
- if ((status = server_get_unix_fd( device, 0, &fd, &needs_close, NULL, NULL ))) + if ((status = server_get_unix_fd( device, 0, &fd, &needs_close, NULL, &options ))) return status;
if ((status = CDROM_Open(fd, &dev))) @@ -3113,6 +3114,6 @@ NTSTATUS cdrom_DeviceIoControl( HANDLE device, HANDLE event, PIO_APC_ROUTINE apc } if (needs_close) close( fd ); if (!NT_ERROR(status)) - file_complete_async( device, event, apc, apc_user, io, status, sz ); + file_complete_async( device, options, event, apc, apc_user, io, status, sz ); return status; } diff --git a/dlls/ntdll/unix/file.c b/dlls/ntdll/unix/file.c index 4f0fe685d88..2ab04040258 100644 --- a/dlls/ntdll/unix/file.c +++ b/dlls/ntdll/unix/file.c @@ -5515,13 +5515,12 @@ void set_async_direct_result( HANDLE *async_handle, IO_STATUS_BLOCK *io, }
/* complete async file I/O, signaling completion in all ways necessary */ -void file_complete_async( HANDLE handle, HANDLE event, PIO_APC_ROUTINE apc, void *apc_user, +void file_complete_async( HANDLE handle, unsigned int options, HANDLE event, PIO_APC_ROUTINE apc, void *apc_user, IO_STATUS_BLOCK *io, NTSTATUS status, ULONG_PTR information ) { ULONG_PTR iosb_ptr = iosb_client_ptr(io);
- io->Status = status; - io->Information = information; + set_sync_iosb( io, status, information, options ); if (event) NtSetEvent( event, NULL ); if (apc) NtQueueApcThread( GetCurrentThread(), (PNTAPCFUNC)apc, (ULONG_PTR)apc_user, iosb_ptr, 0 ); else if (apc_user) add_completion( handle, (ULONG_PTR)apc_user, status, information, FALSE ); @@ -6119,7 +6118,7 @@ NTSTATUS WINAPI NtWriteFileGather( HANDLE file, HANDLE event, PIO_APC_ROUTINE ap if (needs_close) close( unix_handle ); if (status == STATUS_SUCCESS) { - file_complete_async( file, event, apc, apc_user, io, status, total ); + file_complete_async( file, options, event, apc, apc_user, io, status, total ); TRACE("= SUCCESS (%u)\n", total); } else @@ -6224,6 +6223,8 @@ NTSTATUS WINAPI NtFsControlFile( HANDLE handle, HANDLE event, PIO_APC_ROUTINE ap IO_STATUS_BLOCK *io, ULONG code, void *in_buffer, ULONG in_size, void *out_buffer, ULONG out_size ) { + unsigned int options; + int fd, needs_close; ULONG_PTR size = 0; NTSTATUS status;
@@ -6233,6 +6234,11 @@ NTSTATUS WINAPI NtFsControlFile( HANDLE handle, HANDLE event, PIO_APC_ROUTINE ap
if (!io) return STATUS_INVALID_PARAMETER;
+ status = server_get_unix_fd( handle, 0, &fd, &needs_close, NULL, &options ); + if (status && status != STATUS_BAD_DEVICE_TYPE) + return status; + if (needs_close) close( fd ); + ignore_server_ioctl_struct_holes( code, in_buffer, in_size );
switch (code) @@ -6318,7 +6324,7 @@ NTSTATUS WINAPI NtFsControlFile( HANDLE handle, HANDLE event, PIO_APC_ROUTINE ap }
if (!NT_ERROR(status) && status != STATUS_PENDING) - file_complete_async( handle, event, apc, apc_context, io, status, size ); + file_complete_async( handle, options, event, apc, apc_context, io, status, size ); return status; }
diff --git a/dlls/ntdll/unix/serial.c b/dlls/ntdll/unix/serial.c index 8637dfbd447..89b12980df7 100644 --- a/dlls/ntdll/unix/serial.c +++ b/dlls/ntdll/unix/serial.c @@ -1245,6 +1245,7 @@ NTSTATUS serial_DeviceIoControl( HANDLE device, HANDLE event, PIO_APC_ROUTINE ap NTSTATUS status = STATUS_SUCCESS; int fd = -1, needs_close = 0; enum server_fd_type type; + unsigned int options;
TRACE("%p %s %p %d %p %d %p\n", device, iocode2str(code), in_buffer, in_size, out_buffer, out_size, io); @@ -1259,7 +1260,7 @@ NTSTATUS serial_DeviceIoControl( HANDLE device, HANDLE event, PIO_APC_ROUTINE ap return STATUS_NOT_SUPPORTED; }
- if ((status = server_get_unix_fd( device, access, &fd, &needs_close, &type, NULL ))) + if ((status = server_get_unix_fd( device, access, &fd, &needs_close, &type, &options ))) return status; if (type != FD_TYPE_SERIAL) { @@ -1455,7 +1456,7 @@ NTSTATUS serial_DeviceIoControl( HANDLE device, HANDLE event, PIO_APC_ROUTINE ap if (needs_close) close( fd );
if (!NT_ERROR(status)) - file_complete_async( device, event, apc, apc_user, io, status, sz ); + file_complete_async( device, options, event, apc, apc_user, io, status, sz ); return status; }
diff --git a/dlls/ntdll/unix/socket.c b/dlls/ntdll/unix/socket.c index b10d51f3c60..99b5a52326e 100644 --- a/dlls/ntdll/unix/socket.c +++ b/dlls/ntdll/unix/socket.c @@ -1460,6 +1460,7 @@ NTSTATUS sock_ioctl( HANDLE handle, HANDLE event, PIO_APC_ROUTINE apc, void *apc UINT code, void *in_buffer, UINT in_size, void *out_buffer, UINT out_size ) { int fd, needs_close = FALSE; + unsigned int options; NTSTATUS status;
TRACE( "handle %p, code %#x, in_buffer %p, in_size %u, out_buffer %p, out_size %u\n", @@ -1525,6 +1526,10 @@ NTSTATUS sock_ioctl( HANDLE handle, HANDLE event, PIO_APC_ROUTINE apc, void *apc break; }
+ if ((status = server_get_unix_fd( handle, 0, &fd, &needs_close, NULL, &options ))) + return status; + if (needs_close) close( fd ); + SERVER_START_REQ( socket_get_events ) { req->handle = wine_server_obj_handle( handle ); @@ -1535,7 +1540,7 @@ NTSTATUS sock_ioctl( HANDLE handle, HANDLE event, PIO_APC_ROUTINE apc, void *apc } SERVER_END_REQ;
- file_complete_async( handle, event, apc, apc_user, io, status, 0 ); + file_complete_async( handle, options, event, apc, apc_user, io, status, 0 ); return status; }
@@ -1681,8 +1686,12 @@ NTSTATUS sock_ioctl( HANDLE handle, HANDLE event, PIO_APC_ROUTINE apc, void *apc if (in_size != sizeof(NTSTATUS)) return STATUS_BUFFER_TOO_SMALL;
+ if ((status = server_get_unix_fd( handle, 0, &fd, &needs_close, NULL, &options ))) + return status; + if (needs_close) close( fd ); + status = *(NTSTATUS *)in_buffer; - file_complete_async( handle, event, apc, apc_user, io, status, 0 ); + file_complete_async( handle, options, event, apc, apc_user, io, status, 0 ); return status; }
@@ -1696,7 +1705,7 @@ NTSTATUS sock_ioctl( HANDLE handle, HANDLE event, PIO_APC_ROUTINE apc, void *apc break; }
- if ((status = server_get_unix_fd( handle, 0, &fd, &needs_close, NULL, NULL ))) + if ((status = server_get_unix_fd( handle, 0, &fd, &needs_close, NULL, &options ))) return status;
#ifdef linux @@ -1708,7 +1717,7 @@ NTSTATUS sock_ioctl( HANDLE handle, HANDLE event, PIO_APC_ROUTINE apc, void *apc { *(int *)out_buffer = 0; if (needs_close) close( fd ); - file_complete_async( handle, event, apc, apc_user, io, STATUS_SUCCESS, 0 ); + file_complete_async( handle, options, event, apc, apc_user, io, STATUS_SUCCESS, 0 ); return STATUS_SUCCESS; } } @@ -1721,7 +1730,7 @@ NTSTATUS sock_ioctl( HANDLE handle, HANDLE event, PIO_APC_ROUTINE apc, void *apc } *(int *)out_buffer = value; if (needs_close) close( fd ); - file_complete_async( handle, event, apc, apc_user, io, STATUS_SUCCESS, 0 ); + file_complete_async( handle, options, event, apc, apc_user, io, STATUS_SUCCESS, 0 ); return STATUS_SUCCESS; }
@@ -1730,7 +1739,7 @@ NTSTATUS sock_ioctl( HANDLE handle, HANDLE event, PIO_APC_ROUTINE apc, void *apc int value, ret; socklen_t len = sizeof(value);
- if ((status = server_get_unix_fd( handle, 0, &fd, &needs_close, NULL, NULL ))) + if ((status = server_get_unix_fd( handle, 0, &fd, &needs_close, NULL, &options ))) return status;
if (out_size < sizeof(int)) @@ -1760,7 +1769,7 @@ NTSTATUS sock_ioctl( HANDLE handle, HANDLE event, PIO_APC_ROUTINE apc, void *apc *(int *)out_buffer = !value; } if (needs_close) close( fd ); - file_complete_async( handle, event, apc, apc_user, io, STATUS_SUCCESS, 0 ); + file_complete_async( handle, options, event, apc, apc_user, io, STATUS_SUCCESS, 0 ); return STATUS_SUCCESS; }
@@ -1787,7 +1796,7 @@ NTSTATUS sock_ioctl( HANDLE handle, HANDLE event, PIO_APC_ROUTINE apc, void *apc if (out_size < ret_size) { freeifaddrs( ifaddrs ); - file_complete_async( handle, event, apc, apc_user, io, STATUS_BUFFER_TOO_SMALL, 0 ); + file_complete_async( handle, options, event, apc, apc_user, io, STATUS_BUFFER_TOO_SMALL, 0 ); return STATUS_PENDING; }
@@ -1837,7 +1846,7 @@ NTSTATUS sock_ioctl( HANDLE handle, HANDLE event, PIO_APC_ROUTINE apc, void *apc }
freeifaddrs( ifaddrs ); - file_complete_async( handle, event, apc, apc_user, io, STATUS_SUCCESS, ret_size ); + file_complete_async( handle, options, event, apc, apc_user, io, STATUS_SUCCESS, ret_size ); return STATUS_PENDING; #else FIXME( "Interface list queries are currently not supported on this platform.\n" ); @@ -1855,7 +1864,7 @@ NTSTATUS sock_ioctl( HANDLE handle, HANDLE event, PIO_APC_ROUTINE apc, void *apc return STATUS_BUFFER_TOO_SMALL; keepalive = !!k->onoff;
- if ((status = server_get_unix_fd( handle, 0, &fd, &needs_close, NULL, NULL ))) + if ((status = server_get_unix_fd( handle, 0, &fd, &needs_close, NULL, &options ))) return status;
if (setsockopt( fd, SOL_SOCKET, SO_KEEPALIVE, &keepalive, sizeof(int) ) < 0) @@ -1892,7 +1901,7 @@ NTSTATUS sock_ioctl( HANDLE handle, HANDLE event, PIO_APC_ROUTINE apc, void *apc }
if (needs_close) close( fd ); - file_complete_async( handle, event, apc, apc_user, io, STATUS_SUCCESS, 0 ); + file_complete_async( handle, options, event, apc, apc_user, io, STATUS_SUCCESS, 0 ); return STATUS_SUCCESS; }
diff --git a/dlls/ntdll/unix/tape.c b/dlls/ntdll/unix/tape.c index 366096bbf4f..366e12c35a0 100644 --- a/dlls/ntdll/unix/tape.c +++ b/dlls/ntdll/unix/tape.c @@ -523,12 +523,13 @@ NTSTATUS tape_DeviceIoControl( HANDLE device, HANDLE event, PIO_APC_ROUTINE apc, { DWORD sz = 0; NTSTATUS status = STATUS_INVALID_PARAMETER; + unsigned int options; int fd, needs_close;
TRACE( "%p %s %p %d %p %d %p\n", device, io2str(code), in_buffer, in_size, out_buffer, out_size, io );
- if ((status = server_get_unix_fd( device, 0, &fd, &needs_close, NULL, NULL ))) + if ((status = server_get_unix_fd( device, 0, &fd, &needs_close, NULL, &options ))) return status;
switch (code) @@ -580,6 +581,6 @@ NTSTATUS tape_DeviceIoControl( HANDLE device, HANDLE event, PIO_APC_ROUTINE apc, if (needs_close) close( fd );
if (!NT_ERROR(status)) - file_complete_async( device, event, apc, apc_user, io, status, sz ); + file_complete_async( device, options, event, apc, apc_user, io, status, sz ); return status; } diff --git a/dlls/ntdll/unix/unix_private.h b/dlls/ntdll/unix/unix_private.h index 2e0477e42e0..41c7ab4ff2c 100644 --- a/dlls/ntdll/unix/unix_private.h +++ b/dlls/ntdll/unix/unix_private.h @@ -354,7 +354,7 @@ extern NTSTATUS open_unix_file( HANDLE *handle, const char *unix_name, ACCESS_MA extern NTSTATUS get_device_info( int fd, struct _FILE_FS_DEVICE_INFORMATION *info ); extern void init_files(void); extern void init_cpu_info(void); -extern void file_complete_async( HANDLE handle, HANDLE event, PIO_APC_ROUTINE apc, void *apc_user, +extern void file_complete_async( HANDLE handle, unsigned int options, HANDLE event, PIO_APC_ROUTINE apc, void *apc_user, IO_STATUS_BLOCK *io, NTSTATUS status, ULONG_PTR information ); extern void set_async_direct_result( HANDLE *async_handle, IO_STATUS_BLOCK *io, NTSTATUS status, ULONG_PTR information, BOOL mark_pending );