Cleaned up and removed some no longer used code.

This commit is contained in:
Alexandre Julliard 1999-01-01 17:04:00 +00:00
parent 881708cc2d
commit 6ebbe3c949
11 changed files with 95 additions and 268 deletions

View File

@ -29,14 +29,10 @@ const K32OBJ_OPS CHANGE_Ops =
typedef struct typedef struct
{ {
K32OBJ header; K32OBJ header;
LPSTR lpPathName; LPSTR lpPathName;
BOOL32 bWatchSubtree; BOOL32 bWatchSubtree;
DWORD dwNotifyFilter; DWORD dwNotifyFilter;
THREAD_QUEUE wait_queue;
BOOL32 notify; BOOL32 notify;
} CHANGE_OBJECT; } CHANGE_OBJECT;
/**************************************************************************** /****************************************************************************
@ -67,13 +63,11 @@ HANDLE32 WINAPI FindFirstChangeNotification32A( LPCSTR lpPathName,
CHANGE_OBJECT *change; CHANGE_OBJECT *change;
struct create_change_notification_request req; struct create_change_notification_request req;
struct create_change_notification_reply reply; struct create_change_notification_reply reply;
int len;
req.subtree = bWatchSubtree; req.subtree = bWatchSubtree;
req.filter = dwNotifyFilter; req.filter = dwNotifyFilter;
CLIENT_SendRequest( REQ_CREATE_CHANGE_NOTIFICATION, -1, 1, &req, sizeof(req) ); CLIENT_SendRequest( REQ_CREATE_CHANGE_NOTIFICATION, -1, 1, &req, sizeof(req) );
CLIENT_WaitReply( &len, NULL, 1, &reply, sizeof(reply) ); CLIENT_WaitSimpleReply( &reply, sizeof(reply), NULL );
CHECK_LEN( len, sizeof(reply) );
if (reply.handle == -1) return INVALID_HANDLE_VALUE32; if (reply.handle == -1) return INVALID_HANDLE_VALUE32;
change = HeapAlloc( SystemHeap, 0, sizeof(CHANGE_OBJECT) ); change = HeapAlloc( SystemHeap, 0, sizeof(CHANGE_OBJECT) );
@ -89,8 +83,6 @@ HANDLE32 WINAPI FindFirstChangeNotification32A( LPCSTR lpPathName,
change->lpPathName = HEAP_strdupA( SystemHeap, 0, lpPathName ); change->lpPathName = HEAP_strdupA( SystemHeap, 0, lpPathName );
change->bWatchSubtree = bWatchSubtree; change->bWatchSubtree = bWatchSubtree;
change->dwNotifyFilter = dwNotifyFilter; change->dwNotifyFilter = dwNotifyFilter;
change->wait_queue = NULL;
change->notify = FALSE; change->notify = FALSE;
return HANDLE_Alloc( PROCESS_Current(), &change->header, return HANDLE_Alloc( PROCESS_Current(), &change->header,

View File

@ -652,10 +652,7 @@ HFILE32 DOSFS_OpenDevice( const char *name, int unixmode )
!strcmp(DOSFS_Devices[i].name,"HPSCAN")) !strcmp(DOSFS_Devices[i].name,"HPSCAN"))
{ {
int fd = open( "/dev/null", unixmode ); int fd = open( "/dev/null", unixmode );
if ((handle = FILE_Alloc( &file, fd )) == INVALID_HANDLE_VALUE32) return FILE_Alloc( &file, fd, DOSFS_Devices[i].name );
return HFILE_ERROR32;
file->unix_name = HEAP_strdupA( SystemHeap, 0, name );
return handle;
} }
FIXME(dosfs,"device open %s not supported (yet)\n",DOSFS_Devices[i].name); FIXME(dosfs,"device open %s not supported (yet)\n",DOSFS_Devices[i].name);
return HFILE_ERROR32; return HFILE_ERROR32;

View File

@ -71,19 +71,17 @@ static void DOS_RemoveFileLocks(FILE_OBJECT *file);
* *
* Allocate a file. The unix_handle is closed. * Allocate a file. The unix_handle is closed.
*/ */
HFILE32 FILE_Alloc( FILE_OBJECT **file, int unix_handle ) HFILE32 FILE_Alloc( FILE_OBJECT **file, int unix_handle, const char *unix_name )
{ {
HFILE32 handle; HFILE32 handle;
struct create_file_request req; struct create_file_request req;
struct create_file_reply reply; struct create_file_reply reply;
int len;
req.access = FILE_ALL_ACCESS | GENERIC_READ | req.access = FILE_ALL_ACCESS | GENERIC_READ |
GENERIC_WRITE | GENERIC_EXECUTE; /* FIXME */ GENERIC_WRITE | GENERIC_EXECUTE; /* FIXME */
req.inherit = 1; /* FIXME */ req.inherit = 1; /* FIXME */
CLIENT_SendRequest( REQ_CREATE_FILE, unix_handle, 1, &req, sizeof(req) ); CLIENT_SendRequest( REQ_CREATE_FILE, unix_handle, 1, &req, sizeof(req) );
CLIENT_WaitReply( &len, NULL, 1, &reply, sizeof(reply) ); CLIENT_WaitSimpleReply( &reply, sizeof(reply), NULL );
CHECK_LEN( len, sizeof(reply) );
if (reply.handle == -1) return INVALID_HANDLE_VALUE32; if (reply.handle == -1) return INVALID_HANDLE_VALUE32;
*file = HeapAlloc( SystemHeap, 0, sizeof(FILE_OBJECT) ); *file = HeapAlloc( SystemHeap, 0, sizeof(FILE_OBJECT) );
@ -95,10 +93,9 @@ HFILE32 FILE_Alloc( FILE_OBJECT **file, int unix_handle )
} }
(*file)->header.type = K32OBJ_FILE; (*file)->header.type = K32OBJ_FILE;
(*file)->header.refcount = 0; (*file)->header.refcount = 0;
(*file)->unix_name = NULL; (*file)->unix_name = unix_name ? HEAP_strdupA( SystemHeap, 0, unix_name ) : NULL;
(*file)->type = FILE_TYPE_DISK; (*file)->type = FILE_TYPE_DISK;
(*file)->mode = 0; (*file)->mode = 0;
(*file)->wait_queue = NULL;
handle = HANDLE_Alloc( PROCESS_Current(), &(*file)->header, req.access, handle = HANDLE_Alloc( PROCESS_Current(), &(*file)->header, req.access,
req.inherit, reply.handle ); req.inherit, reply.handle );
@ -151,28 +148,6 @@ void FILE_ReleaseFile( FILE_OBJECT *file )
} }
/***********************************************************************
* FILE_GetUnixHandle
*
* Return the Unix handle associated to a file handle.
* The Unix handle must be closed after use.
*/
int FILE_GetUnixHandle( HFILE32 hFile, DWORD access )
{
FILE_OBJECT *file;
int unix_handle;
struct get_unix_handle_request req;
file = (FILE_OBJECT *)HANDLE_GetObjPtr( PROCESS_Current(), hFile,
K32OBJ_FILE, access, &req.handle );
if (!file) return -1;
req.access = access;
CLIENT_SendRequest( REQ_GET_UNIX_HANDLE, -1, 1, &req, sizeof(req) );
CLIENT_WaitReply( NULL, &unix_handle, 0 );
K32OBJ_DecCount( &file->header );
return unix_handle;
}
/*********************************************************************** /***********************************************************************
* FILE_UnixToDosMode * FILE_UnixToDosMode
* *
@ -503,7 +478,7 @@ HFILE32 FILE_DupUnixHandle( int fd )
FILE_SetDosError(); FILE_SetDosError();
return INVALID_HANDLE_VALUE32; return INVALID_HANDLE_VALUE32;
} }
return FILE_Alloc( &file, unix_handle ); return FILE_Alloc( &file, unix_handle, NULL );
} }
@ -512,7 +487,6 @@ HFILE32 FILE_DupUnixHandle( int fd )
*/ */
HFILE32 FILE_OpenUnixFile( const char *name, int mode ) HFILE32 FILE_OpenUnixFile( const char *name, int mode )
{ {
HFILE32 handle;
int unix_handle; int unix_handle;
FILE_OBJECT *file; FILE_OBJECT *file;
struct stat st; struct stat st;
@ -534,12 +508,9 @@ HFILE32 FILE_OpenUnixFile( const char *name, int mode )
return INVALID_HANDLE_VALUE32; return INVALID_HANDLE_VALUE32;
} }
/* File opened OK, now fill the FILE_OBJECT */ /* File opened OK, now allocate a handle */
if ((handle = FILE_Alloc( &file, unix_handle )) == INVALID_HANDLE_VALUE32) return FILE_Alloc( &file, unix_handle, name );
return INVALID_HANDLE_VALUE32;
file->unix_name = HEAP_strdupA( SystemHeap, 0, name );
return handle;
} }
@ -650,9 +621,9 @@ static HFILE32 FILE_Create( LPCSTR path, int mode, int unique )
/* File created OK, now fill the FILE_OBJECT */ /* File created OK, now fill the FILE_OBJECT */
if ((handle = FILE_Alloc( &file, unix_handle )) == INVALID_HANDLE_VALUE32) if ((handle = FILE_Alloc( &file, unix_handle,
full_name.long_name )) == INVALID_HANDLE_VALUE32)
return INVALID_HANDLE_VALUE32; return INVALID_HANDLE_VALUE32;
file->unix_name = HEAP_strdupA( SystemHeap, 0, full_name.long_name );
file->mode = dosMode; file->mode = dosMode;
return handle; return handle;
} }
@ -712,18 +683,16 @@ BOOL32 FILE_Stat( LPCSTR unixName, BY_HANDLE_FILE_INFORMATION *info )
DWORD WINAPI GetFileInformationByHandle( HFILE32 hFile, DWORD WINAPI GetFileInformationByHandle( HFILE32 hFile,
BY_HANDLE_FILE_INFORMATION *info ) BY_HANDLE_FILE_INFORMATION *info )
{ {
FILE_OBJECT *file;
struct get_file_info_request req; struct get_file_info_request req;
struct get_file_info_reply reply; struct get_file_info_reply reply;
int len;
if (!info) return 0; if (!info) return 0;
if (!(file = FILE_GetFile( hFile, 0, &req.handle ))) return 0; if ((req.handle = HANDLE_GetServerHandle( PROCESS_Current(), hFile,
K32OBJ_FILE, 0 )) == -1)
return 0;
CLIENT_SendRequest( REQ_GET_FILE_INFO, -1, 1, &req, sizeof(req) ); CLIENT_SendRequest( REQ_GET_FILE_INFO, -1, 1, &req, sizeof(req) );
CLIENT_WaitReply( &len, NULL, 1, &reply, sizeof(reply) ); if (CLIENT_WaitSimpleReply( &reply, sizeof(reply), NULL ))
CHECK_LEN( len, sizeof(reply) ); return 0;
FILE_ReleaseFile( file );
DOSFS_UnixTimeToFileTime( reply.write_time, &info->ftCreationTime, 0 ); DOSFS_UnixTimeToFileTime( reply.write_time, &info->ftCreationTime, 0 );
DOSFS_UnixTimeToFileTime( reply.write_time, &info->ftLastWriteTime, 0 ); DOSFS_UnixTimeToFileTime( reply.write_time, &info->ftLastWriteTime, 0 );
DOSFS_UnixTimeToFileTime( reply.access_time, &info->ftLastAccessTime, 0 ); DOSFS_UnixTimeToFileTime( reply.access_time, &info->ftLastAccessTime, 0 );
@ -1175,7 +1144,6 @@ HFILE32 WINAPI _lclose32( HFILE32 hFile )
BOOL32 WINAPI ReadFile( HANDLE32 hFile, LPVOID buffer, DWORD bytesToRead, BOOL32 WINAPI ReadFile( HANDLE32 hFile, LPVOID buffer, DWORD bytesToRead,
LPDWORD bytesRead, LPOVERLAPPED overlapped ) LPDWORD bytesRead, LPOVERLAPPED overlapped )
{ {
K32OBJ *ptr;
struct get_read_fd_request req; struct get_read_fd_request req;
int unix_handle, result; int unix_handle, result;
@ -1184,18 +1152,11 @@ BOOL32 WINAPI ReadFile( HANDLE32 hFile, LPVOID buffer, DWORD bytesToRead,
if (bytesRead) *bytesRead = 0; /* Do this before anything else */ if (bytesRead) *bytesRead = 0; /* Do this before anything else */
if (!bytesToRead) return TRUE; if (!bytesToRead) return TRUE;
if (!(ptr = HANDLE_GetObjPtr( PROCESS_Current(), hFile, if ((req.handle = HANDLE_GetServerHandle( PROCESS_Current(), hFile,
K32OBJ_UNKNOWN, GENERIC_READ, &req.handle ))) K32OBJ_UNKNOWN, GENERIC_READ )) == -1)
return FALSE; return FALSE;
if (req.handle == -1) /* We need a server handle */
{
K32OBJ_DecCount( ptr );
return FALSE;
}
CLIENT_SendRequest( REQ_GET_READ_FD, -1, 1, &req, sizeof(req) ); CLIENT_SendRequest( REQ_GET_READ_FD, -1, 1, &req, sizeof(req) );
CLIENT_WaitReply( NULL, &unix_handle, 0 ); CLIENT_WaitReply( NULL, &unix_handle, 0 );
K32OBJ_DecCount( ptr );
if (unix_handle == -1) return FALSE; if (unix_handle == -1) return FALSE;
while ((result = read( unix_handle, buffer, bytesToRead )) == -1) while ((result = read( unix_handle, buffer, bytesToRead )) == -1)
{ {
@ -1216,7 +1177,6 @@ BOOL32 WINAPI ReadFile( HANDLE32 hFile, LPVOID buffer, DWORD bytesToRead,
BOOL32 WINAPI WriteFile( HANDLE32 hFile, LPCVOID buffer, DWORD bytesToWrite, BOOL32 WINAPI WriteFile( HANDLE32 hFile, LPCVOID buffer, DWORD bytesToWrite,
LPDWORD bytesWritten, LPOVERLAPPED overlapped ) LPDWORD bytesWritten, LPOVERLAPPED overlapped )
{ {
K32OBJ *ptr;
struct get_write_fd_request req; struct get_write_fd_request req;
int unix_handle, result; int unix_handle, result;
@ -1225,18 +1185,11 @@ BOOL32 WINAPI WriteFile( HANDLE32 hFile, LPCVOID buffer, DWORD bytesToWrite,
if (bytesWritten) *bytesWritten = 0; /* Do this before anything else */ if (bytesWritten) *bytesWritten = 0; /* Do this before anything else */
if (!bytesToWrite) return TRUE; if (!bytesToWrite) return TRUE;
if (!(ptr = HANDLE_GetObjPtr( PROCESS_Current(), hFile, if ((req.handle = HANDLE_GetServerHandle( PROCESS_Current(), hFile,
K32OBJ_UNKNOWN, GENERIC_WRITE, &req.handle ))) K32OBJ_UNKNOWN, GENERIC_READ )) == -1)
return FALSE; return FALSE;
if (req.handle == -1) /* We need a server handle */
{
K32OBJ_DecCount( ptr );
return FALSE;
}
CLIENT_SendRequest( REQ_GET_WRITE_FD, -1, 1, &req, sizeof(req) ); CLIENT_SendRequest( REQ_GET_WRITE_FD, -1, 1, &req, sizeof(req) );
CLIENT_WaitReply( NULL, &unix_handle, 0 ); CLIENT_WaitReply( NULL, &unix_handle, 0 );
K32OBJ_DecCount( ptr );
if (unix_handle == -1) return FALSE; if (unix_handle == -1) return FALSE;
while ((result = write( unix_handle, buffer, bytesToWrite )) == -1) while ((result = write( unix_handle, buffer, bytesToWrite )) == -1)
{ {
@ -1336,10 +1289,8 @@ HFILE32 _lcreat_uniq( LPCSTR path, INT32 attr )
DWORD WINAPI SetFilePointer( HFILE32 hFile, LONG distance, LONG *highword, DWORD WINAPI SetFilePointer( HFILE32 hFile, LONG distance, LONG *highword,
DWORD method ) DWORD method )
{ {
FILE_OBJECT *file;
struct set_file_pointer_request req; struct set_file_pointer_request req;
struct set_file_pointer_reply reply; struct set_file_pointer_reply reply;
int len, err;
if (highword && *highword) if (highword && *highword)
{ {
@ -1350,18 +1301,15 @@ DWORD WINAPI SetFilePointer( HFILE32 hFile, LONG distance, LONG *highword,
TRACE(file, "handle %d offset %ld origin %ld\n", TRACE(file, "handle %d offset %ld origin %ld\n",
hFile, distance, method ); hFile, distance, method );
if (!(file = FILE_GetFile( hFile, 0, &req.handle ))) return 0xffffffff; if ((req.handle = HANDLE_GetServerHandle( PROCESS_Current(), hFile,
assert( req.handle != -1 ); K32OBJ_FILE, 0 )) == -1)
return 0xffffffff;
req.low = distance; req.low = distance;
req.high = highword ? *highword : 0; req.high = highword ? *highword : 0;
/* FIXME: assumes 1:1 mapping between Windows and Unix seek constants */ /* FIXME: assumes 1:1 mapping between Windows and Unix seek constants */
req.whence = method; req.whence = method;
CLIENT_SendRequest( REQ_SET_FILE_POINTER, -1, 1, &req, sizeof(req) ); CLIENT_SendRequest( REQ_SET_FILE_POINTER, -1, 1, &req, sizeof(req) );
err = CLIENT_WaitReply( &len, NULL, 1, &reply, sizeof(reply) ); if (CLIENT_WaitSimpleReply( &reply, sizeof(reply), NULL )) return 0xffffffff;
CHECK_LEN( len, sizeof(reply) );
FILE_ReleaseFile( file );
if (err) return 0xffffffff;
SetLastError( 0 ); SetLastError( 0 );
if (highword) *highword = reply.high; if (highword) *highword = reply.high;
return reply.low; return reply.low;
@ -1552,17 +1500,13 @@ UINT32 WINAPI SetHandleCount32( UINT32 count )
*/ */
BOOL32 WINAPI FlushFileBuffers( HFILE32 hFile ) BOOL32 WINAPI FlushFileBuffers( HFILE32 hFile )
{ {
FILE_OBJECT *file;
BOOL32 ret;
struct flush_file_request req; struct flush_file_request req;
if (!(file = FILE_GetFile( hFile, GENERIC_WRITE, &req.handle ))) return FALSE; if ((req.handle = HANDLE_GetServerHandle( PROCESS_Current(), hFile,
assert( req.handle != -1 ); K32OBJ_FILE, 0 )) == -1)
return FALSE;
CLIENT_SendRequest( REQ_FLUSH_FILE, -1, 1, &req, sizeof(req) ); CLIENT_SendRequest( REQ_FLUSH_FILE, -1, 1, &req, sizeof(req) );
ret = !CLIENT_WaitReply( NULL, NULL, 0 ); return !CLIENT_WaitReply( NULL, NULL, 0 );
FILE_ReleaseFile( file );
return ret;
} }
@ -1571,17 +1515,13 @@ BOOL32 WINAPI FlushFileBuffers( HFILE32 hFile )
*/ */
BOOL32 WINAPI SetEndOfFile( HFILE32 hFile ) BOOL32 WINAPI SetEndOfFile( HFILE32 hFile )
{ {
FILE_OBJECT *file;
BOOL32 ret;
struct truncate_file_request req; struct truncate_file_request req;
if (!(file = FILE_GetFile( hFile, GENERIC_WRITE, &req.handle ))) return FALSE; if ((req.handle = HANDLE_GetServerHandle( PROCESS_Current(), hFile,
assert( req.handle != -1 ); K32OBJ_FILE, 0 )) == -1)
return FALSE;
CLIENT_SendRequest( REQ_TRUNCATE_FILE, -1, 1, &req, sizeof(req) ); CLIENT_SendRequest( REQ_TRUNCATE_FILE, -1, 1, &req, sizeof(req) );
ret = !CLIENT_WaitReply( NULL, NULL, 0 ); return !CLIENT_WaitReply( NULL, NULL, 0 );
FILE_ReleaseFile( file );
return ret;
} }
@ -1648,7 +1588,7 @@ BOOL32 FILE_SetFileType( HFILE32 hFile, DWORD type )
/*********************************************************************** /***********************************************************************
* FILE_dommap * FILE_dommap
*/ */
LPVOID FILE_dommap( FILE_OBJECT *file, int unix_handle, LPVOID start, LPVOID FILE_dommap( int unix_handle, LPVOID start,
DWORD size_high, DWORD size_low, DWORD size_high, DWORD size_low,
DWORD offset_high, DWORD offset_low, DWORD offset_high, DWORD offset_low,
int prot, int flags ) int prot, int flags )
@ -1660,7 +1600,7 @@ LPVOID FILE_dommap( FILE_OBJECT *file, int unix_handle, LPVOID start,
if (size_high || offset_high) if (size_high || offset_high)
FIXME(file, "offsets larger than 4Gb not supported\n"); FIXME(file, "offsets larger than 4Gb not supported\n");
if (!file) if (unix_handle == -1)
{ {
#ifdef MAP_ANON #ifdef MAP_ANON
flags |= MAP_ANON; flags |= MAP_ANON;
@ -1695,7 +1635,7 @@ LPVOID FILE_dommap( FILE_OBJECT *file, int unix_handle, LPVOID start,
/* page-aligned (EINVAL), or because the underlying filesystem */ /* page-aligned (EINVAL), or because the underlying filesystem */
/* does not support mmap() (ENOEXEC), we do it by hand. */ /* does not support mmap() (ENOEXEC), we do it by hand. */
if (!file) return ret; if (unix_handle == -1) return ret;
if ((errno != ENOEXEC) && (errno != EINVAL)) return ret; if ((errno != ENOEXEC) && (errno != EINVAL)) return ret;
if (prot & PROT_WRITE) if (prot & PROT_WRITE)
{ {
@ -1709,7 +1649,7 @@ LPVOID FILE_dommap( FILE_OBJECT *file, int unix_handle, LPVOID start,
} }
/* printf( "FILE_mmap: mmap failed (%d), faking it\n", errno );*/ /* printf( "FILE_mmap: mmap failed (%d), faking it\n", errno );*/
/* Reserve the memory with an anonymous mmap */ /* Reserve the memory with an anonymous mmap */
ret = FILE_dommap( NULL, -1, start, size_high, size_low, 0, 0, ret = FILE_dommap( -1, start, size_high, size_low, 0, 0,
PROT_READ | PROT_WRITE, flags ); PROT_READ | PROT_WRITE, flags );
if (ret == (LPVOID)-1) return ret; if (ret == (LPVOID)-1) return ret;
/* Now read in the file */ /* Now read in the file */
@ -2269,5 +2209,3 @@ BOOL32 WINAPI GetFileAttributesEx32W(
HeapFree( GetProcessHeap(), 0, nameA ); HeapFree( GetProcessHeap(), 0, nameA );
return res; return res;
} }

View File

@ -10,7 +10,6 @@
#include <time.h> #include <time.h>
#include "windows.h" #include "windows.h"
#include "k32obj.h" #include "k32obj.h"
#include "thread.h"
#define MAX_PATHNAME_LEN 1024 #define MAX_PATHNAME_LEN 1024
@ -21,7 +20,6 @@ typedef struct
int mode; int mode;
char *unix_name; char *unix_name;
DWORD type; /* Type for win32 apps */ DWORD type; /* Type for win32 apps */
THREAD_QUEUE wait_queue;
} FILE_OBJECT; } FILE_OBJECT;
/* Definition of a full DOS file name */ /* Definition of a full DOS file name */
@ -62,9 +60,8 @@ typedef struct
extern FILE_OBJECT *FILE_GetFile( HFILE32 handle, DWORD access, extern FILE_OBJECT *FILE_GetFile( HFILE32 handle, DWORD access,
int *server_handle ); int *server_handle );
extern void FILE_ReleaseFile( FILE_OBJECT *file ); extern void FILE_ReleaseFile( FILE_OBJECT *file );
extern HFILE32 FILE_Alloc( FILE_OBJECT **file, int unix_handle ); extern HFILE32 FILE_Alloc( FILE_OBJECT **file, int unix_handle, const char *unix_name );
extern void FILE_SetDosError(void); extern void FILE_SetDosError(void);
extern int FILE_GetUnixHandle( HFILE32 hFile, DWORD access );
extern HFILE32 FILE_DupUnixHandle( int fd ); extern HFILE32 FILE_DupUnixHandle( int fd );
extern BOOL32 FILE_Stat( LPCSTR unixName, BY_HANDLE_FILE_INFORMATION *info ); extern BOOL32 FILE_Stat( LPCSTR unixName, BY_HANDLE_FILE_INFORMATION *info );
extern HFILE32 FILE_Dup( HFILE32 hFile ); extern HFILE32 FILE_Dup( HFILE32 hFile );
@ -72,7 +69,7 @@ extern HFILE32 FILE_Dup2( HFILE32 hFile1, HFILE32 hFile2 );
extern HFILE32 FILE_Open( LPCSTR path, INT32 mode ,INT32 sharemode); extern HFILE32 FILE_Open( LPCSTR path, INT32 mode ,INT32 sharemode);
extern HFILE32 FILE_OpenUnixFile( LPCSTR path, INT32 mode ); extern HFILE32 FILE_OpenUnixFile( LPCSTR path, INT32 mode );
extern BOOL32 FILE_SetFileType( HFILE32 hFile, DWORD type ); extern BOOL32 FILE_SetFileType( HFILE32 hFile, DWORD type );
extern LPVOID FILE_dommap( FILE_OBJECT *file, int unix_handle, LPVOID start, extern LPVOID FILE_dommap( int unix_handle, LPVOID start,
DWORD size_high, DWORD size_low, DWORD size_high, DWORD size_low,
DWORD offset_high, DWORD offset_low, DWORD offset_high, DWORD offset_low,
int prot, int flags ); int prot, int flags );

View File

@ -28,7 +28,7 @@
/*********************************************************************** /***********************************************************************
* CLIENT_ProtocolError * CLIENT_ProtocolError
*/ */
void CLIENT_ProtocolError( const char *err, ... ) static void CLIENT_ProtocolError( const char *err, ... )
{ {
THDB *thdb = THREAD_Current(); THDB *thdb = THREAD_Current();
va_list args; va_list args;
@ -215,6 +215,26 @@ unsigned int CLIENT_WaitReply( int *len, int *passed_fd,
} }
/***********************************************************************
* CLIENT_WaitSimpleReply
*
* Wait for a simple fixed-length reply from the server.
*/
unsigned int CLIENT_WaitSimpleReply( void *reply, int len, int *passed_fd )
{
struct iovec vec[2];
unsigned int ret;
int got;
vec[1].iov_base = reply;
vec[1].iov_len = len;
ret = CLIENT_WaitReply_v( &got, passed_fd, vec, 2 );
if (got != len)
CLIENT_ProtocolError( "WaitSimpleReply: len %d != %d\n", len, got );
return ret;
}
/*********************************************************************** /***********************************************************************
* CLIENT_NewThread * CLIENT_NewThread
* *
@ -224,7 +244,7 @@ int CLIENT_NewThread( THDB *thdb, int *thandle, int *phandle )
{ {
struct new_thread_request request; struct new_thread_request request;
struct new_thread_reply reply; struct new_thread_reply reply;
int len, fd[2]; int fd[2];
extern BOOL32 THREAD_InitDone; extern BOOL32 THREAD_InitDone;
extern void server_init( int fd ); extern void server_init( int fd );
extern void select_loop(void); extern void select_loop(void);
@ -273,16 +293,13 @@ int CLIENT_NewThread( THDB *thdb, int *thandle, int *phandle )
request.pid = thdb->process->server_pid; request.pid = thdb->process->server_pid;
CLIENT_SendRequest( REQ_NEW_THREAD, fd[1], 1, &request, sizeof(request) ); CLIENT_SendRequest( REQ_NEW_THREAD, fd[1], 1, &request, sizeof(request) );
if (CLIENT_WaitSimpleReply( &reply, sizeof(reply), NULL )) goto error;
if (CLIENT_WaitReply( &len, NULL, 1, &reply, sizeof(reply) )) goto error;
if (len < sizeof(reply)) goto error;
thdb->server_tid = reply.tid; thdb->server_tid = reply.tid;
thdb->process->server_pid = reply.pid; thdb->process->server_pid = reply.pid;
if (thdb->socket != -1) close( thdb->socket ); if (thdb->socket != -1) close( thdb->socket );
thdb->socket = fd[0]; thdb->socket = fd[0];
thdb->seq = 0; /* reset the sequence number for the new fd */ thdb->seq = 0; /* reset the sequence number for the new fd */
/* we don't need the handles for now */
if (thandle) *thandle = reply.thandle; if (thandle) *thandle = reply.thandle;
else if (reply.thandle != -1) CLIENT_CloseHandle( reply.thandle ); else if (reply.thandle != -1) CLIENT_CloseHandle( reply.thandle );
if (phandle) *phandle = reply.phandle; if (phandle) *phandle = reply.phandle;
@ -359,44 +376,11 @@ int CLIENT_DuplicateHandle( int src_process, int src_handle, int dst_process, in
req.options = options; req.options = options;
CLIENT_SendRequest( REQ_DUP_HANDLE, -1, 1, &req, sizeof(req) ); CLIENT_SendRequest( REQ_DUP_HANDLE, -1, 1, &req, sizeof(req) );
CLIENT_WaitReply( &len, NULL, 1, &reply, sizeof(reply) ); CLIENT_WaitSimpleReply( &reply, sizeof(reply), NULL );
CHECK_LEN( len, sizeof(reply) );
return reply.handle; return reply.handle;
} }
/***********************************************************************
* CLIENT_GetProcessInfo
*
* Send a get process info request. Return 0 if OK.
*/
int CLIENT_GetProcessInfo( int handle, struct get_process_info_reply *reply )
{
int len, err;
CLIENT_SendRequest( REQ_GET_PROCESS_INFO, -1, 1, &handle, sizeof(handle) );
err = CLIENT_WaitReply( &len, NULL, 1, reply, sizeof(*reply) );
CHECK_LEN( len, sizeof(*reply) );
return err;
}
/***********************************************************************
* CLIENT_GetThreadInfo
*
* Send a get thread info request. Return 0 if OK.
*/
int CLIENT_GetThreadInfo( int handle, struct get_thread_info_reply *reply )
{
int len, err;
CLIENT_SendRequest( REQ_GET_THREAD_INFO, -1, 1, &handle, sizeof(handle) );
err = CLIENT_WaitReply( &len, NULL, 1, reply, sizeof(*reply) );
CHECK_LEN( len, sizeof(*reply) );
return err;
}
/*********************************************************************** /***********************************************************************
* CLIENT_OpenProcess * CLIENT_OpenProcess
* *
@ -406,15 +390,13 @@ int CLIENT_OpenProcess( void *pid, DWORD access, BOOL32 inherit )
{ {
struct open_process_request req; struct open_process_request req;
struct open_process_reply reply; struct open_process_reply reply;
int len;
req.pid = pid; req.pid = pid;
req.access = access; req.access = access;
req.inherit = inherit; req.inherit = inherit;
CLIENT_SendRequest( REQ_OPEN_PROCESS, -1, 1, &req, sizeof(req) ); CLIENT_SendRequest( REQ_OPEN_PROCESS, -1, 1, &req, sizeof(req) );
CLIENT_WaitReply( &len, NULL, 1, &reply, sizeof(reply) ); CLIENT_WaitSimpleReply( &reply, sizeof(reply), NULL );
CHECK_LEN( len, sizeof(reply) );
return reply.handle; return reply.handle;
} }
@ -435,7 +417,6 @@ int CLIENT_Select( int count, int *handles, int flags, int timeout )
CLIENT_SendRequest( REQ_SELECT, -1, 2, CLIENT_SendRequest( REQ_SELECT, -1, 2,
&req, sizeof(req), &req, sizeof(req),
handles, count * sizeof(int) ); handles, count * sizeof(int) );
CLIENT_WaitReply( &len, NULL, 1, &reply, sizeof(reply) ); CLIENT_WaitSimpleReply( &reply, sizeof(reply), NULL );
CHECK_LEN( len, sizeof(reply) );
return reply.signaled; return reply.signaled;
} }

View File

@ -20,13 +20,6 @@ typedef struct
K32OBJ header; K32OBJ header;
} EVENT; } EVENT;
static void EVENT_Destroy( K32OBJ *obj );
const K32OBJ_OPS EVENT_Ops =
{
EVENT_Destroy /* destroy */
};
/*********************************************************************** /***********************************************************************
* CreateEvent32A (KERNEL32.156) * CreateEvent32A (KERNEL32.156)
@ -45,8 +38,7 @@ HANDLE32 WINAPI CreateEvent32A( SECURITY_ATTRIBUTES *sa, BOOL32 manual_reset,
req.inherit = (sa && (sa->nLength>=sizeof(*sa)) && sa->bInheritHandle); req.inherit = (sa && (sa->nLength>=sizeof(*sa)) && sa->bInheritHandle);
CLIENT_SendRequest( REQ_CREATE_EVENT, -1, 2, &req, sizeof(req), name, len ); CLIENT_SendRequest( REQ_CREATE_EVENT, -1, 2, &req, sizeof(req), name, len );
CLIENT_WaitReply( &len, NULL, 1, &reply, sizeof(reply) ); CLIENT_WaitSimpleReply( &reply, sizeof(reply), NULL );
CHECK_LEN( len, sizeof(reply) );
if (reply.handle == -1) return 0; if (reply.handle == -1) return 0;
SYSTEM_LOCK(); SYSTEM_LOCK();
@ -96,8 +88,7 @@ HANDLE32 WINAPI OpenEvent32A( DWORD access, BOOL32 inherit, LPCSTR name )
req.access = access; req.access = access;
req.inherit = inherit; req.inherit = inherit;
CLIENT_SendRequest( REQ_OPEN_NAMED_OBJ, -1, 2, &req, sizeof(req), name, len ); CLIENT_SendRequest( REQ_OPEN_NAMED_OBJ, -1, 2, &req, sizeof(req), name, len );
CLIENT_WaitReply( &len, NULL, 1, &reply, sizeof(reply) ); CLIENT_WaitSimpleReply( &reply, sizeof(reply), NULL );
CHECK_LEN( len, sizeof(reply) );
if (reply.handle != -1) if (reply.handle != -1)
{ {
SYSTEM_LOCK(); SYSTEM_LOCK();
@ -172,20 +163,6 @@ BOOL32 WINAPI ResetEvent( HANDLE32 handle )
} }
/***********************************************************************
* EVENT_Destroy
*/
static void EVENT_Destroy( K32OBJ *obj )
{
EVENT *event = (EVENT *)obj;
assert( obj->type == K32OBJ_EVENT );
obj->type = K32OBJ_UNKNOWN;
HeapFree( SystemHeap, 0, event );
}
/*********************************************************************** /***********************************************************************
* NOTE: The Win95 VWin32_Event routines given below are really low-level * NOTE: The Win95 VWin32_Event routines given below are really low-level
* routines implemented directly by VWin32. The user-mode libraries * routines implemented directly by VWin32. The user-mode libraries

View File

@ -21,23 +21,25 @@ extern const K32OBJ_OPS DEVICE_Ops;
extern const K32OBJ_OPS CONSOLE_Ops; extern const K32OBJ_OPS CONSOLE_Ops;
extern const K32OBJ_OPS SNAPSHOT_Ops; extern const K32OBJ_OPS SNAPSHOT_Ops;
/* The following are fully implemented in the server and could be removed */
extern const K32OBJ_OPS SEMAPHORE_Ops;
extern const K32OBJ_OPS EVENT_Ops;
extern const K32OBJ_OPS MUTEX_Ops;
extern const K32OBJ_OPS PIPE_Ops;
static const K32OBJ_OPS K32OBJ_NullOps = static const K32OBJ_OPS K32OBJ_NullOps =
{ {
NULL /* destroy */ NULL /* destroy */
}; };
static void K32OBJ_Destroy( K32OBJ *obj );
static const K32OBJ_OPS K32OBJ_DefaultOps =
{
K32OBJ_Destroy /* destroy */
};
const K32OBJ_OPS * const K32OBJ_Ops[K32OBJ_NBOBJECTS] = const K32OBJ_OPS * const K32OBJ_Ops[K32OBJ_NBOBJECTS] =
{ {
NULL, NULL,
&SEMAPHORE_Ops, /* K32OBJ_SEMAPHORE */ &K32OBJ_DefaultOps, /* K32OBJ_SEMAPHORE */
&EVENT_Ops, /* K32OBJ_EVENT */ &K32OBJ_DefaultOps, /* K32OBJ_EVENT */
&MUTEX_Ops, /* K32OBJ_MUTEX */ &K32OBJ_DefaultOps, /* K32OBJ_MUTEX */
&K32OBJ_NullOps, /* K32OBJ_CRITICAL_SECTION */ &K32OBJ_NullOps, /* K32OBJ_CRITICAL_SECTION */
&PROCESS_Ops, /* K32OBJ_PROCESS */ &PROCESS_Ops, /* K32OBJ_PROCESS */
&THREAD_Ops, /* K32OBJ_THREAD */ &THREAD_Ops, /* K32OBJ_THREAD */
@ -48,7 +50,7 @@ const K32OBJ_OPS * const K32OBJ_Ops[K32OBJ_NBOBJECTS] =
&MEM_MAPPED_FILE_Ops, /* K32OBJ_MEM_MAPPED_FILE */ &MEM_MAPPED_FILE_Ops, /* K32OBJ_MEM_MAPPED_FILE */
&K32OBJ_NullOps, /* K32OBJ_SERIAL */ &K32OBJ_NullOps, /* K32OBJ_SERIAL */
&DEVICE_Ops, /* K32OBJ_DEVICE_IOCTL */ &DEVICE_Ops, /* K32OBJ_DEVICE_IOCTL */
&PIPE_Ops, /* K32OBJ_PIPE */ &K32OBJ_DefaultOps, /* K32OBJ_PIPE */
&K32OBJ_NullOps, /* K32OBJ_MAILSLOT */ &K32OBJ_NullOps, /* K32OBJ_MAILSLOT */
&K32OBJ_NullOps, /* K32OBJ_TOOLHELP_SNAPSHOT */ &K32OBJ_NullOps, /* K32OBJ_TOOLHELP_SNAPSHOT */
&K32OBJ_NullOps /* K32OBJ_SOCKET */ &K32OBJ_NullOps /* K32OBJ_SOCKET */
@ -112,6 +114,18 @@ void K32OBJ_DecCount( K32OBJ *ptr )
} }
/***********************************************************************
* K32OBJ_Destroy
*
* Generic destroy functions for objects that don't need any special treatment.
*/
static void K32OBJ_Destroy( K32OBJ *obj )
{
obj->type = K32OBJ_UNKNOWN;
HeapFree( SystemHeap, 0, obj );
}
/*********************************************************************** /***********************************************************************
* K32OBJ_IsValid * K32OBJ_IsValid
* *

View File

@ -19,13 +19,6 @@ typedef struct _MUTEX
K32OBJ header; K32OBJ header;
} MUTEX; } MUTEX;
static void MUTEX_Destroy( K32OBJ *obj );
const K32OBJ_OPS MUTEX_Ops =
{
MUTEX_Destroy /* destroy */
};
/*********************************************************************** /***********************************************************************
* CreateMutex32A (KERNEL32.166) * CreateMutex32A (KERNEL32.166)
@ -43,8 +36,7 @@ HANDLE32 WINAPI CreateMutex32A( SECURITY_ATTRIBUTES *sa, BOOL32 owner,
req.inherit = (sa && (sa->nLength>=sizeof(*sa)) && sa->bInheritHandle); req.inherit = (sa && (sa->nLength>=sizeof(*sa)) && sa->bInheritHandle);
CLIENT_SendRequest( REQ_CREATE_MUTEX, -1, 2, &req, sizeof(req), name, len ); CLIENT_SendRequest( REQ_CREATE_MUTEX, -1, 2, &req, sizeof(req), name, len );
CLIENT_WaitReply( &len, NULL, 1, &reply, sizeof(reply) ); CLIENT_WaitSimpleReply( &reply, sizeof(reply), NULL );
CHECK_LEN( len, sizeof(reply) );
if (reply.handle == -1) return 0; if (reply.handle == -1) return 0;
SYSTEM_LOCK(); SYSTEM_LOCK();
@ -86,8 +78,7 @@ HANDLE32 WINAPI OpenMutex32A( DWORD access, BOOL32 inherit, LPCSTR name )
req.access = access; req.access = access;
req.inherit = inherit; req.inherit = inherit;
CLIENT_SendRequest( REQ_OPEN_NAMED_OBJ, -1, 2, &req, sizeof(req), name, len ); CLIENT_SendRequest( REQ_OPEN_NAMED_OBJ, -1, 2, &req, sizeof(req), name, len );
CLIENT_WaitReply( &len, NULL, 1, &reply, sizeof(reply) ); CLIENT_WaitSimpleReply( &reply, sizeof(reply), NULL );
CHECK_LEN( len, sizeof(reply) );
if (reply.handle != -1) if (reply.handle != -1)
{ {
SYSTEM_LOCK(); SYSTEM_LOCK();
@ -130,15 +121,3 @@ BOOL32 WINAPI ReleaseMutex( HANDLE32 handle )
CLIENT_SendRequest( REQ_RELEASE_MUTEX, -1, 1, &req, sizeof(req) ); CLIENT_SendRequest( REQ_RELEASE_MUTEX, -1, 1, &req, sizeof(req) );
return !CLIENT_WaitReply( NULL, NULL, 0 ); return !CLIENT_WaitReply( NULL, NULL, 0 );
} }
/***********************************************************************
* MUTEX_Destroy
*/
static void MUTEX_Destroy( K32OBJ *obj )
{
MUTEX *mutex = (MUTEX *)obj;
assert( obj->type == K32OBJ_MUTEX );
obj->type = K32OBJ_UNKNOWN;
HeapFree( SystemHeap, 0, mutex );
}

View File

@ -19,13 +19,6 @@ typedef struct _PIPE
K32OBJ header; K32OBJ header;
} PIPE; } PIPE;
static void PIPE_Destroy( K32OBJ *obj );
const K32OBJ_OPS PIPE_Ops =
{
PIPE_Destroy /* destroy */
};
/*********************************************************************** /***********************************************************************
* CreatePipe (KERNEL32.170) * CreatePipe (KERNEL32.170)
@ -71,16 +64,3 @@ BOOL32 WINAPI CreatePipe( PHANDLE hReadPipe, PHANDLE hWritePipe,
SYSTEM_UNLOCK(); SYSTEM_UNLOCK();
return TRUE; return TRUE;
} }
/***********************************************************************
* PIPE_Destroy
*/
static void PIPE_Destroy( K32OBJ *obj )
{
PIPE *pipe = (PIPE *)obj;
assert( obj->type == K32OBJ_PIPE );
obj->type = K32OBJ_UNKNOWN;
HeapFree( SystemHeap, 0, pipe );
}

View File

@ -19,13 +19,6 @@ typedef struct
K32OBJ header; K32OBJ header;
} SEMAPHORE; } SEMAPHORE;
static void SEMAPHORE_Destroy( K32OBJ *obj );
const K32OBJ_OPS SEMAPHORE_Ops =
{
SEMAPHORE_Destroy /* destroy */
};
/*********************************************************************** /***********************************************************************
* CreateSemaphore32A (KERNEL32.174) * CreateSemaphore32A (KERNEL32.174)
@ -52,8 +45,7 @@ HANDLE32 WINAPI CreateSemaphore32A( SECURITY_ATTRIBUTES *sa, LONG initial,
req.inherit = (sa && (sa->nLength>=sizeof(*sa)) && sa->bInheritHandle); req.inherit = (sa && (sa->nLength>=sizeof(*sa)) && sa->bInheritHandle);
CLIENT_SendRequest( REQ_CREATE_SEMAPHORE, -1, 2, &req, sizeof(req), name, len ); CLIENT_SendRequest( REQ_CREATE_SEMAPHORE, -1, 2, &req, sizeof(req), name, len );
CLIENT_WaitReply( &len, NULL, 1, &reply, sizeof(reply) ); CLIENT_WaitSimpleReply( &reply, sizeof(reply), NULL );
CHECK_LEN( len, sizeof(reply) );
if (reply.handle == -1) return 0; if (reply.handle == -1) return 0;
SYSTEM_LOCK(); SYSTEM_LOCK();
@ -95,8 +87,7 @@ HANDLE32 WINAPI OpenSemaphore32A( DWORD access, BOOL32 inherit, LPCSTR name )
req.access = access; req.access = access;
req.inherit = inherit; req.inherit = inherit;
CLIENT_SendRequest( REQ_OPEN_NAMED_OBJ, -1, 2, &req, sizeof(req), name, len ); CLIENT_SendRequest( REQ_OPEN_NAMED_OBJ, -1, 2, &req, sizeof(req), name, len );
CLIENT_WaitReply( &len, NULL, 1, &reply, sizeof(reply) ); CLIENT_WaitSimpleReply( &reply, sizeof(reply), NULL );
CHECK_LEN( len, sizeof(reply) );
if (reply.handle != -1) if (reply.handle != -1)
{ {
SYSTEM_LOCK(); SYSTEM_LOCK();
@ -133,7 +124,6 @@ BOOL32 WINAPI ReleaseSemaphore( HANDLE32 handle, LONG count, LONG *previous )
{ {
struct release_semaphore_request req; struct release_semaphore_request req;
struct release_semaphore_reply reply; struct release_semaphore_reply reply;
int len;
if (count < 0) if (count < 0)
{ {
@ -145,21 +135,7 @@ BOOL32 WINAPI ReleaseSemaphore( HANDLE32 handle, LONG count, LONG *previous )
if (req.handle == -1) return FALSE; if (req.handle == -1) return FALSE;
req.count = (unsigned int)count; req.count = (unsigned int)count;
CLIENT_SendRequest( REQ_RELEASE_SEMAPHORE, -1, 1, &req, sizeof(req) ); CLIENT_SendRequest( REQ_RELEASE_SEMAPHORE, -1, 1, &req, sizeof(req) );
if (CLIENT_WaitReply( &len, NULL, 1, &reply, sizeof(reply) )) return FALSE; if (CLIENT_WaitSimpleReply( &reply, sizeof(reply), NULL )) return FALSE;
CHECK_LEN( len, sizeof(reply) );
if (previous) *previous = reply.prev_count; if (previous) *previous = reply.prev_count;
return TRUE; return TRUE;
} }
/***********************************************************************
* SEMAPHORE_Destroy
*/
static void SEMAPHORE_Destroy( K32OBJ *obj )
{
SEMAPHORE *sem = (SEMAPHORE *)obj;
assert( obj->type == K32OBJ_SEMAPHORE );
/* There cannot be any thread on the list since the ref count is 0 */
obj->type = K32OBJ_UNKNOWN;
HeapFree( SystemHeap, 0, sem );
}

View File

@ -60,7 +60,6 @@ typedef struct _CONSOLE {
LPSTR title; /* title of console */ LPSTR title; /* title of console */
INPUT_RECORD *irs; /* buffered input records */ INPUT_RECORD *irs; /* buffered input records */
int nrofirs;/* nr of buffered input records */ int nrofirs;/* nr of buffered input records */
THREAD_QUEUE wait_queue;
} CONSOLE; } CONSOLE;
static void CONSOLE_Destroy( K32OBJ *obj ); static void CONSOLE_Destroy( K32OBJ *obj );
@ -644,7 +643,6 @@ BOOL32 WINAPI AllocConsole(VOID)
{ {
struct create_console_request req; struct create_console_request req;
struct create_console_reply reply; struct create_console_reply reply;
int len;
PDB32 *pdb = PROCESS_Current(); PDB32 *pdb = PROCESS_Current();
CONSOLE *console; CONSOLE *console;
HANDLE32 hIn, hOut, hErr; HANDLE32 hIn, hOut, hErr;
@ -674,7 +672,6 @@ BOOL32 WINAPI AllocConsole(VOID)
console->pid = -1; console->pid = -1;
console->title = NULL; console->title = NULL;
console->nrofirs = 0; console->nrofirs = 0;
console->wait_queue = NULL;
console->irs = HeapAlloc(GetProcessHeap(),0,1);; console->irs = HeapAlloc(GetProcessHeap(),0,1);;
console->mode = ENABLE_PROCESSED_INPUT console->mode = ENABLE_PROCESSED_INPUT
| ENABLE_LINE_INPUT | ENABLE_LINE_INPUT
@ -685,13 +682,12 @@ BOOL32 WINAPI AllocConsole(VOID)
console->hread = console->hwrite = -1; console->hread = console->hwrite = -1;
CLIENT_SendRequest( REQ_CREATE_CONSOLE, -1, 1, &req, sizeof(req) ); CLIENT_SendRequest( REQ_CREATE_CONSOLE, -1, 1, &req, sizeof(req) );
if (CLIENT_WaitReply( &len, NULL, 1, &reply, sizeof(reply) ) != ERROR_SUCCESS) if (CLIENT_WaitSimpleReply( &reply, sizeof(reply), NULL ) != ERROR_SUCCESS)
{ {
K32OBJ_DecCount(&console->header); K32OBJ_DecCount(&console->header);
SYSTEM_UNLOCK(); SYSTEM_UNLOCK();
return FALSE; return FALSE;
} }
CHECK_LEN( len, sizeof(reply) );
console->hread = reply.handle_read; console->hread = reply.handle_read;
console->hwrite = reply.handle_write; console->hwrite = reply.handle_write;