server: Move handle allocation out of open_object_dir.

This commit is contained in:
Alexandre Julliard 2005-12-05 12:52:05 +01:00
parent 1f872df26c
commit 3764da68de
8 changed files with 55 additions and 18 deletions

View File

@ -260,11 +260,9 @@ void *create_named_object_dir( struct directory *root, const struct unicode_str
}
/* open a new handle to an existing object */
obj_handle_t open_object_dir( struct directory *root, const struct unicode_str *name,
unsigned int attr, const struct object_ops *ops,
unsigned int access )
void *open_object_dir( struct directory *root, const struct unicode_str *name,
unsigned int attr, const struct object_ops *ops )
{
obj_handle_t handle = 0;
struct unicode_str name_left;
struct object *obj;
@ -275,11 +273,11 @@ obj_handle_t open_object_dir( struct directory *root, const struct unicode_str *
else if (ops && obj->ops != ops)
set_error( STATUS_OBJECT_TYPE_MISMATCH );
else
handle = alloc_handle( current->process, obj, access, attr & OBJ_INHERIT );
return obj;
release_object( obj );
}
return handle;
return NULL;
}
@ -367,13 +365,18 @@ DECL_HANDLER(create_directory)
DECL_HANDLER(open_directory)
{
struct unicode_str name;
struct directory *root = NULL;
struct directory *dir, *root = NULL;
get_req_unicode_str( &name );
if (req->rootdir && !(root = get_directory_obj( current->process, req->rootdir, 0 )))
return;
reply->handle = open_object_dir( root, &name, req->attributes, &directory_ops, req->access );
if ((dir = open_object_dir( root, &name, req->attributes, &directory_ops )))
{
reply->handle = alloc_handle( current->process, &dir->obj, req->access,
req->attributes & OBJ_INHERIT );
release_object( dir );
}
if (root) release_object( root );
}

View File

@ -172,12 +172,18 @@ DECL_HANDLER(open_event)
{
struct unicode_str name;
struct directory *root = NULL;
struct event *event;
get_req_unicode_str( &name );
if (req->rootdir && !(root = get_directory_obj( current->process, req->rootdir, 0 )))
return;
reply->handle = open_object_dir( root, &name, req->attributes, &event_ops, req->access );
if ((event = open_object_dir( root, &name, req->attributes, &event_ops )))
{
reply->handle = alloc_handle( current->process, &event->obj, req->access,
req->attributes & OBJ_INHERIT );
release_object( event );
}
if (root) release_object( root );
}

View File

@ -402,12 +402,18 @@ DECL_HANDLER(open_mapping)
{
struct unicode_str name;
struct directory *root = NULL;
struct mapping *mapping;
get_req_unicode_str( &name );
if (req->rootdir && !(root = get_directory_obj( current->process, req->rootdir, 0 )))
return;
reply->handle = open_object_dir( root, &name, req->attributes, &mapping_ops, req->access );
if ((mapping = open_object_dir( root, &name, req->attributes, &mapping_ops )))
{
reply->handle = alloc_handle( current->process, &mapping->obj, req->access,
req->attributes & OBJ_INHERIT );
release_object( mapping );
}
if (root) release_object( root );
}

View File

@ -198,12 +198,18 @@ DECL_HANDLER(open_mutex)
{
struct unicode_str name;
struct directory *root = NULL;
struct mutex *mutex;
get_req_unicode_str( &name );
if (req->rootdir && !(root = get_directory_obj( current->process, req->rootdir, 0 )))
return;
reply->handle = open_object_dir( root, &name, req->attributes, &mutex_ops, req->access );
if ((mutex = open_object_dir( root, &name, req->attributes, &mutex_ops )))
{
reply->handle = alloc_handle( current->process, &mutex->obj, req->access,
req->attributes & OBJ_INHERIT );
release_object( mutex );
}
if (root) release_object( root );
}

View File

@ -187,9 +187,8 @@ extern struct object *find_object_dir( struct directory *root, const struct unic
unsigned int attr, struct unicode_str *name_left );
extern void *create_named_object_dir( struct directory *root, const struct unicode_str *name,
unsigned int attr, const struct object_ops *ops );
extern obj_handle_t open_object_dir( struct directory *root, const struct unicode_str *name,
unsigned int attr, const struct object_ops *ops,
unsigned int access );
extern void *open_object_dir( struct directory *root, const struct unicode_str *name,
unsigned int attr, const struct object_ops *ops );
extern void init_directories(void);
extern void close_directories(void);

View File

@ -172,12 +172,18 @@ DECL_HANDLER(open_semaphore)
{
struct unicode_str name;
struct directory *root = NULL;
struct semaphore *sem;
get_req_unicode_str( &name );
if (req->rootdir && !(root = get_directory_obj( current->process, req->rootdir, 0 )))
return;
reply->handle = open_object_dir( root, &name, req->attributes, &semaphore_ops, req->access );
if ((sem = open_object_dir( root, &name, req->attributes, &semaphore_ops )))
{
reply->handle = alloc_handle( current->process, &sem->obj, req->access,
req->attributes & OBJ_INHERIT );
release_object( sem );
}
if (root) release_object( root );
}

View File

@ -168,13 +168,18 @@ DECL_HANDLER(open_symlink)
{
struct unicode_str name;
struct directory *root = NULL;
struct symlink *symlink;
get_req_unicode_str( &name );
if (req->rootdir && !(root = get_directory_obj( current->process, req->rootdir, 0 )))
return;
reply->handle = open_object_dir( root, &name, req->attributes | OBJ_OPENLINK,
&symlink_ops, req->access );
if ((symlink = open_object_dir( root, &name, req->attributes | OBJ_OPENLINK, &symlink_ops )))
{
reply->handle = alloc_handle( current->process, &symlink->obj, req->access,
req->attributes & OBJ_INHERIT );
release_object( symlink );
}
if (root) release_object( root );
}

View File

@ -231,12 +231,18 @@ DECL_HANDLER(open_timer)
{
struct unicode_str name;
struct directory *root = NULL;
struct timer *timer;
get_req_unicode_str( &name );
if (req->rootdir && !(root = get_directory_obj( current->process, req->rootdir, 0 )))
return;
reply->handle = open_object_dir( root, &name, req->attributes, &timer_ops, req->access );
if ((timer = open_object_dir( root, &name, req->attributes, &timer_ops )))
{
reply->handle = alloc_handle( current->process, &timer->obj, req->access,
req->attributes & OBJ_INHERIT );
release_object( timer );
}
if (root) release_object( root );
}