server: Use the lookup_name operation when creating a named object.

Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Alexandre Julliard 2016-02-08 14:10:18 +09:00
parent e2ccc978a3
commit 0458a7d0e3
4 changed files with 17 additions and 42 deletions

View File

@ -254,36 +254,7 @@ struct object *find_object_dir( struct directory *root, const struct unicode_str
void *create_named_object_dir( struct directory *root, const struct unicode_str *name,
unsigned int attributes, const struct object_ops *ops )
{
struct object *obj, *new_obj = NULL;
struct unicode_str new_name;
if (!name || !name->len)
{
if ((new_obj = alloc_object( ops ))) clear_error();
return new_obj;
}
if (!(obj = find_object_dir( root, name, attributes, &new_name ))) return NULL;
if (!new_name.len)
{
if (attributes & OBJ_OPENIF && obj->ops == ops)
set_error( STATUS_OBJECT_NAME_EXISTS );
else
{
release_object( obj );
obj = NULL;
if (attributes & OBJ_OPENIF)
set_error( STATUS_OBJECT_TYPE_MISMATCH );
else
set_error( STATUS_OBJECT_NAME_COLLISION );
}
return obj;
}
if ((new_obj = create_object( obj, ops, &new_name ))) clear_error();
release_object( obj );
return new_obj;
return create_named_object( &root->obj, ops, name, attributes );
}
/* open a new handle to an existing object */

View File

@ -282,18 +282,20 @@ void *create_object( struct object *parent, const struct object_ops *ops, const
return obj;
}
void *create_named_object( struct object *parent, struct namespace *namespace, const struct object_ops *ops,
/* create an object as named child under the specified parent */
void *create_named_object( struct object *parent, const struct object_ops *ops,
const struct unicode_str *name, unsigned int attributes )
{
struct object *obj;
struct object *obj, *new_obj;
struct unicode_str new_name;
if (!name || !name->len)
{
if ((obj = alloc_object( ops ))) clear_error();
return obj;
}
clear_error();
if ((obj = find_object( namespace, name, attributes )))
if (!name || !name->len) return alloc_object( ops );
if (!(obj = lookup_named_object( parent, name, attributes, &new_name ))) return NULL;
if (!new_name.len)
{
if (attributes & OBJ_OPENIF && obj->ops == ops)
set_error( STATUS_OBJECT_NAME_EXISTS );
@ -308,8 +310,10 @@ void *create_named_object( struct object *parent, struct namespace *namespace, c
}
return obj;
}
if ((obj = create_object( parent, ops, name ))) clear_error();
return obj;
new_obj = create_object( obj, ops, &new_name );
release_object( obj );
return new_obj;
}
/* recursive helper for dump_object_name */

View File

@ -136,7 +136,7 @@ extern struct object *lookup_named_object( struct object *root, const struct uni
unsigned int attr, struct unicode_str *name_left );
extern void *create_object( struct object *parent, const struct object_ops *ops,
const struct unicode_str *name );
extern void *create_named_object( struct object *parent, struct namespace *namespace, const struct object_ops *ops,
extern void *create_named_object( struct object *parent, const struct object_ops *ops,
const struct unicode_str *name, unsigned int attributes );
extern void unlink_named_object( struct object *obj );
extern void make_object_static( struct object *obj );

View File

@ -217,7 +217,7 @@ static struct desktop *create_desktop( const struct unicode_str *name, unsigned
{
struct desktop *desktop;
if ((desktop = create_named_object( &winstation->obj, winstation->desktop_names, &desktop_ops, name, attr )))
if ((desktop = create_named_object( &winstation->obj, &desktop_ops, name, attr )))
{
if (get_error() != STATUS_OBJECT_NAME_EXISTS)
{