From 875d112dd70881c149c57b5ed20147ac46a63791 Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Sun, 28 Feb 1999 10:12:48 +0000 Subject: [PATCH] Removed dst_handle in duplicate_handle request. Added inherit flag in create_mapping request. --- include/server.h | 2 +- include/server/process.h | 2 +- scheduler/client.c | 1 - server/process.c | 31 ++----------------------------- server/request.c | 6 +++--- server/trace.c | 2 +- 6 files changed, 8 insertions(+), 36 deletions(-) diff --git a/include/server.h b/include/server.h index c0edcbf3d36..fcce2a57b8e 100644 --- a/include/server.h +++ b/include/server.h @@ -201,7 +201,6 @@ struct dup_handle_request int src_process; /* src process handle */ int src_handle; /* src handle to duplicate */ int dst_process; /* dst process handle */ - int dst_handle; /* handle to duplicate to (or -1 for any) */ unsigned int access; /* wanted access rights */ int inherit; /* inherit flag */ int options; /* duplicate options (see below) */ @@ -573,6 +572,7 @@ struct create_mapping_request int size_high; /* mapping size */ int size_low; /* mapping size */ int protect; /* protection flags (see below) */ + int inherit; /* inherit flag */ int handle; /* file handle */ char name[0]; /* object name */ }; diff --git a/include/server/process.h b/include/server/process.h index b155cbc738d..ed080834a8a 100644 --- a/include/server/process.h +++ b/include/server/process.h @@ -56,7 +56,7 @@ extern int set_handle_info( struct process *process, int handle, extern struct object *get_handle_obj( struct process *process, int handle, unsigned int access, const struct object_ops *ops ); extern int duplicate_handle( struct process *src, int src_handle, struct process *dst, - int dst_handle, unsigned int access, int inherit, int options ); + unsigned int access, int inherit, int options ); extern int open_object( const char *name, const struct object_ops *ops, unsigned int access, int inherit ); diff --git a/scheduler/client.c b/scheduler/client.c index b1c688ea00c..94ff2874952 100644 --- a/scheduler/client.c +++ b/scheduler/client.c @@ -356,7 +356,6 @@ int CLIENT_DuplicateHandle( int src_process, int src_handle, int dst_process, in req.src_process = src_process; req.src_handle = src_handle; req.dst_process = dst_process; - req.dst_handle = dst_handle; req.access = access; req.inherit = inherit; req.options = options; diff --git a/server/process.c b/server/process.c index 6e65433ab64..967773130ee 100644 --- a/server/process.c +++ b/server/process.c @@ -288,33 +288,6 @@ int alloc_handle( struct process *process, void *obj, unsigned int access, return handle + 1; /* avoid handle 0 */ } -/* allocate a specific handle for an object, incrementing its refcount */ -static int alloc_specific_handle( struct process *process, void *obj, int handle, - unsigned int access, int inherit ) -{ - struct handle_entry *entry; - struct object *old; - - if (handle == -1) return alloc_handle( process, obj, access, inherit ); - - assert( !(access & RESERVED_ALL) ); - if (inherit) access |= RESERVED_INHERIT; - - handle--; /* handles start at 1 */ - if ((handle < 0) || (handle > process->handle_last)) - { - SET_ERROR( ERROR_INVALID_HANDLE ); - return -1; - } - entry = process->entries + handle; - - old = entry->ptr; - entry->ptr = grab_object( obj ); - entry->access = access; - if (old) release_object( old ); - return handle + 1; -} - /* return an handle entry, or NULL if the handle is invalid */ static struct handle_entry *get_handle( struct process *process, int handle ) { @@ -469,7 +442,7 @@ int set_handle_info( struct process *process, int handle, int mask, int flags ) /* duplicate a handle */ int duplicate_handle( struct process *src, int src_handle, struct process *dst, - int dst_handle, unsigned int access, int inherit, int options ) + unsigned int access, int inherit, int options ) { int res; struct handle_entry *entry = get_handle( src, src_handle ); @@ -478,7 +451,7 @@ int duplicate_handle( struct process *src, int src_handle, struct process *dst, if (options & DUP_HANDLE_SAME_ACCESS) access = entry->access; if (options & DUP_HANDLE_MAKE_GLOBAL) dst = initial_process; access &= ~RESERVED_ALL; - res = alloc_specific_handle( dst, entry->ptr, dst_handle, access, inherit ); + res = alloc_handle( dst, entry->ptr, access, inherit ); if (options & DUP_HANDLE_MAKE_GLOBAL) res = HANDLE_LOCAL_TO_GLOBAL(res); return res; } diff --git a/server/request.c b/server/request.c index 453fecb1811..7e5b682e739 100644 --- a/server/request.c +++ b/server/request.c @@ -223,12 +223,12 @@ DECL_HANDLER(dup_handle) { if (req->options & DUP_HANDLE_MAKE_GLOBAL) { - reply.handle = duplicate_handle( src, req->src_handle, NULL, -1, + reply.handle = duplicate_handle( src, req->src_handle, NULL, req->access, req->inherit, req->options ); } else if ((dst = get_process_from_handle( req->dst_process, PROCESS_DUP_HANDLE ))) { - reply.handle = duplicate_handle( src, req->src_handle, dst, req->dst_handle, + reply.handle = duplicate_handle( src, req->src_handle, dst, req->access, req->inherit, req->options ); release_object( dst ); } @@ -742,7 +742,7 @@ DECL_HANDLER(create_mapping) { int access = FILE_MAP_ALL_ACCESS; if (!(req->protect & VPROT_WRITE)) access &= ~FILE_MAP_WRITE; - reply.handle = alloc_handle( current->process, obj, access, 0 ); + reply.handle = alloc_handle( current->process, obj, access, req->inherit ); release_object( obj ); } send_reply( current, -1, 1, &reply, sizeof(reply) ); diff --git a/server/trace.c b/server/trace.c index cc84f96de8d..8a35b817530 100644 --- a/server/trace.c +++ b/server/trace.c @@ -159,7 +159,6 @@ static int dump_dup_handle_request( struct dup_handle_request *req, int len ) fprintf( stderr, " src_process=%d,", req->src_process ); fprintf( stderr, " src_handle=%d,", req->src_handle ); fprintf( stderr, " dst_process=%d,", req->dst_process ); - fprintf( stderr, " dst_handle=%d,", req->dst_handle ); fprintf( stderr, " access=%08x,", req->access ); fprintf( stderr, " inherit=%d,", req->inherit ); fprintf( stderr, " options=%d", req->options ); @@ -522,6 +521,7 @@ static int dump_create_mapping_request( struct create_mapping_request *req, int fprintf( stderr, " size_high=%d,", req->size_high ); fprintf( stderr, " size_low=%d,", req->size_low ); fprintf( stderr, " protect=%d,", req->protect ); + fprintf( stderr, " inherit=%d,", req->inherit ); fprintf( stderr, " handle=%d,", req->handle ); fprintf( stderr, " name=\"%.*s\"", len - (int)sizeof(*req), (char *)(req+1) ); return len;