Added wine_server_fd_to_handle to replace FILE_DupUnixHandle.

This commit is contained in:
Alexandre Julliard 2002-05-30 20:40:02 +00:00
parent 9851f7a902
commit be367c7270
7 changed files with 41 additions and 33 deletions

View File

@ -1023,6 +1023,7 @@ name ntdll
# Server interface # Server interface
@ cdecl -norelay wine_server_call(ptr) wine_server_call @ cdecl -norelay wine_server_call(ptr) wine_server_call
@ cdecl wine_server_fd_to_handle(long long long ptr) wine_server_fd_to_handle
@ cdecl wine_server_handle_to_fd(long long ptr ptr ptr) wine_server_handle_to_fd @ cdecl wine_server_handle_to_fd(long long ptr ptr ptr) wine_server_handle_to_fd
# Codepages # Codepages

View File

@ -36,15 +36,15 @@
#include "wine/winbase16.h" #include "wine/winbase16.h"
#include "winreg.h" #include "winreg.h"
#include "wine/debug.h"
#include "gdi.h" #include "gdi.h"
#include "file.h"
#include "user.h" #include "user.h"
#include "win.h" #include "win.h"
#include "wine_gl.h" #include "wine_gl.h"
#include "x11drv.h" #include "x11drv.h"
#include "xvidmode.h" #include "xvidmode.h"
#include "dga2.h" #include "dga2.h"
#include "wine/server.h"
#include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(x11drv); WINE_DEFAULT_DEBUG_CHANNEL(x11drv);
@ -449,8 +449,12 @@ struct x11drv_thread_data *x11drv_init_thread_data(void)
fcntl( ConnectionNumber(data->display), F_SETFD, 1 ); /* set close on exec flag */ fcntl( ConnectionNumber(data->display), F_SETFD, 1 ); /* set close on exec flag */
if (synchronous) XSynchronize( data->display, True ); if (synchronous) XSynchronize( data->display, True );
wine_tsx11_unlock(); wine_tsx11_unlock();
data->display_fd = FILE_DupUnixHandle( ConnectionNumber(data->display), if (wine_server_fd_to_handle( ConnectionNumber(data->display), GENERIC_READ | SYNCHRONIZE,
GENERIC_READ | SYNCHRONIZE, FALSE ); FALSE, &data->display_fd ))
{
MESSAGE( "x11drv: Can't allocate handle for display fd\n" );
ExitProcess(1);
}
data->process_event_count = 0; data->process_event_count = 0;
NtCurrentTeb()->driver_data = data; NtCurrentTeb()->driver_data = data;
return data; return data;

View File

@ -306,31 +306,6 @@ void FILE_SetDosError(void)
} }
/***********************************************************************
* FILE_DupUnixHandle
*
* Duplicate a Unix handle into a task handle.
* Returns 0 on failure.
*/
HANDLE FILE_DupUnixHandle( int fd, DWORD access, BOOL inherit )
{
HANDLE ret;
wine_server_send_fd( fd );
SERVER_START_REQ( alloc_file_handle )
{
req->access = access;
req->inherit = inherit;
req->fd = fd;
wine_server_call( req );
ret = reply->handle;
}
SERVER_END_REQ;
return ret;
}
/*********************************************************************** /***********************************************************************
* FILE_GetUnixHandleType * FILE_GetUnixHandleType
* *

View File

@ -69,7 +69,6 @@ extern mode_t FILE_umask;
extern int FILE_strcasecmp( const char *str1, const char *str2 ); extern int FILE_strcasecmp( const char *str1, const char *str2 );
extern int FILE_strncasecmp( const char *str1, const char *str2, int len ); extern int FILE_strncasecmp( const char *str1, const char *str2, int len );
extern void FILE_SetDosError(void); extern void FILE_SetDosError(void);
extern HANDLE FILE_DupUnixHandle( int fd, DWORD access, BOOL inherit );
extern int FILE_GetUnixHandle( HANDLE handle, DWORD access ); extern int FILE_GetUnixHandle( HANDLE handle, DWORD access );
extern BOOL FILE_Stat( LPCSTR unixName, BY_HANDLE_FILE_INFORMATION *info ); extern BOOL FILE_Stat( LPCSTR unixName, BY_HANDLE_FILE_INFORMATION *info );
extern HFILE16 FILE_Dup2( HFILE16 hFile1, HFILE16 hFile2 ); extern HFILE16 FILE_Dup2( HFILE16 hFile1, HFILE16 hFile2 );

View File

@ -51,6 +51,7 @@ struct __server_request_info
extern unsigned int wine_server_call( void *req_ptr ); extern unsigned int wine_server_call( void *req_ptr );
extern void wine_server_send_fd( int fd ); extern void wine_server_send_fd( int fd );
extern int wine_server_fd_to_handle( int fd, unsigned int access, int inherit, obj_handle_t *handle );
extern int wine_server_handle_to_fd( obj_handle_t handle, unsigned int access, int *unix_fd, extern int wine_server_handle_to_fd( obj_handle_t handle, unsigned int access, int *unix_fd,
enum fd_type *type, int *flags ); enum fd_type *type, int *flags );

View File

@ -364,6 +364,30 @@ inline static int store_cached_fd( int fd, obj_handle_t handle )
} }
/***********************************************************************
* wine_server_fd_to_handle (NTDLL.@)
*
* Allocate a file handle for a Unix fd.
*/
int wine_server_fd_to_handle( int fd, unsigned int access, int inherit, obj_handle_t *handle )
{
int ret;
*handle = 0;
wine_server_send_fd( fd );
SERVER_START_REQ( alloc_file_handle )
{
req->access = access;
req->inherit = inherit;
req->fd = fd;
if (!(ret = wine_server_call( req ))) *handle = reply->handle;
}
SERVER_END_REQ;
return ret;
}
/*********************************************************************** /***********************************************************************
* wine_server_handle_to_fd (NTDLL.@) * wine_server_handle_to_fd (NTDLL.@)
* *

View File

@ -403,9 +403,13 @@ static BOOL process_init( char *argv[] )
/* no parent, and no new console requested, create a simple console with bare handles to /* no parent, and no new console requested, create a simple console with bare handles to
* unix stdio input & output streams (aka simple console) * unix stdio input & output streams (aka simple console)
*/ */
SetStdHandle( STD_INPUT_HANDLE, FILE_DupUnixHandle( 0, GENERIC_READ|SYNCHRONIZE, TRUE )); HANDLE handle;
SetStdHandle( STD_OUTPUT_HANDLE, FILE_DupUnixHandle( 1, GENERIC_WRITE|SYNCHRONIZE, TRUE )); wine_server_fd_to_handle( 0, GENERIC_READ|SYNCHRONIZE, TRUE, &handle );
SetStdHandle( STD_ERROR_HANDLE, FILE_DupUnixHandle( 1, GENERIC_WRITE|SYNCHRONIZE, TRUE )); SetStdHandle( STD_INPUT_HANDLE, handle );
wine_server_fd_to_handle( 1, GENERIC_WRITE|SYNCHRONIZE, TRUE, &handle );
SetStdHandle( STD_OUTPUT_HANDLE, handle );
wine_server_fd_to_handle( 1, GENERIC_WRITE|SYNCHRONIZE, TRUE, &handle );
SetStdHandle( STD_ERROR_HANDLE, handle );
} }
else if (!(main_create_flags & (DETACHED_PROCESS|CREATE_NEW_CONSOLE))) else if (!(main_create_flags & (DETACHED_PROCESS|CREATE_NEW_CONSOLE)))
{ {