/*********************************************************************** * wine_server_handle_to_fd (NTDLL.@) * * Retrieve the file descriptor corresponding to a file handle. * * PARAMS * handle [I] Wine file handle. * access [I] Win32 file access rights requested. * unix_fd [O] Address where Unix file descriptor will be stored. * options [O] Address where the file open options will be stored. Optional. * * RETURNS * NTSTATUS code */ int CDECL wine_server_handle_to_fd( HANDLE handle, unsigned int access, int *unix_fd, unsigned int *options ) { int needs_close, ret = server_get_unix_fd( handle, access, unix_fd, &needs_close, NULL, options ); if (!ret && !needs_close) { if ((*unix_fd = dup(*unix_fd)) == -1) ret = FILE_GetNtStatus(); } return ret; }
/****************************************************************** * TAPE_DeviceIoControl * * SEE ALSO * NtDeviceIoControl. */ NTSTATUS TAPE_DeviceIoControl( HANDLE device, HANDLE event, PIO_APC_ROUTINE apc, PVOID apc_user, PIO_STATUS_BLOCK io_status, ULONG io_control, LPVOID in_buffer, DWORD in_size, LPVOID out_buffer, DWORD out_size ) { DWORD sz = 0; NTSTATUS status = STATUS_INVALID_PARAMETER; int fd, needs_close; TRACE( "%p %s %p %d %p %d %p\n", device, io2str(io_control), in_buffer, in_size, out_buffer, out_size, io_status ); io_status->Information = 0; if ((status = server_get_unix_fd( device, 0, &fd, &needs_close, NULL, NULL ))) goto error; switch (io_control) { case IOCTL_TAPE_CREATE_PARTITION: status = TAPE_CreatePartition( fd, in_buffer ); break; case IOCTL_TAPE_ERASE: status = TAPE_Erase( fd, in_buffer ); break; case IOCTL_TAPE_GET_DRIVE_PARAMS: status = TAPE_GetDriveParams( fd, out_buffer ); break; case IOCTL_TAPE_GET_MEDIA_PARAMS: status = TAPE_GetMediaParams( fd, out_buffer ); break; case IOCTL_TAPE_GET_POSITION: status = TAPE_GetPosition( fd, ((TAPE_GET_POSITION *)in_buffer)->Type, out_buffer ); break; case IOCTL_TAPE_GET_STATUS: status = FILE_GetNtStatus(); break; case IOCTL_TAPE_PREPARE: status = TAPE_Prepare( fd, in_buffer ); break; case IOCTL_TAPE_SET_DRIVE_PARAMS: status = TAPE_SetDriveParams( fd, in_buffer ); break; case IOCTL_TAPE_SET_MEDIA_PARAMS: status = TAPE_SetMediaParams( fd, in_buffer ); break; case IOCTL_TAPE_SET_POSITION: status = TAPE_SetPosition( fd, in_buffer ); break; case IOCTL_TAPE_WRITE_MARKS: status = TAPE_WriteMarks( fd, in_buffer ); break; case IOCTL_TAPE_CHECK_VERIFY: case IOCTL_TAPE_FIND_NEW_DEVICES: break; default: FIXME( "Unsupported IOCTL %x (type=%x access=%x func=%x meth=%x)\n", io_control, io_control >> 16, (io_control >> 14) & 3, (io_control >> 2) & 0xfff, io_control & 3 ); break; } if (needs_close) close( fd ); error: io_status->u.Status = status; io_status->Information = sz; if (event) NtSetEvent( event, NULL ); return status; }