server: Use the generic named object functions for named pipes.

Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Alexandre Julliard 2016-02-08 14:30:07 +09:00
parent 4e380b9e2b
commit 7646df9f4b

View file

@ -668,47 +668,6 @@ static obj_handle_t pipe_server_ioctl( struct fd *fd, ioctl_code_t code, const a
} }
} }
static struct named_pipe *create_named_pipe( struct directory *root, const struct unicode_str *name,
unsigned int attr, const struct security_descriptor *sd )
{
struct object *obj;
struct named_pipe *pipe = NULL;
struct unicode_str new_name;
if (!name || !name->len)
{
if ((pipe = alloc_object( &named_pipe_ops ))) clear_error();
return pipe;
}
if (!(obj = find_object_dir( root, name, attr, &new_name )))
{
set_error( STATUS_OBJECT_NAME_INVALID );
return NULL;
}
if (!new_name.len)
{
if (attr & OBJ_OPENIF && obj->ops == &named_pipe_ops)
set_error( STATUS_OBJECT_NAME_EXISTS );
else
{
release_object( obj );
obj = NULL;
if (attr & OBJ_OPENIF)
set_error( STATUS_OBJECT_TYPE_MISMATCH );
else
set_error( STATUS_OBJECT_NAME_COLLISION );
}
return (struct named_pipe *)obj;
}
if ((pipe = create_object( obj, &named_pipe_ops, &new_name )))
clear_error();
release_object( obj );
return pipe;
}
static struct pipe_server *get_pipe_server_obj( struct process *process, static struct pipe_server *get_pipe_server_obj( struct process *process,
obj_handle_t handle, unsigned int access ) obj_handle_t handle, unsigned int access )
{ {
@ -896,11 +855,8 @@ static obj_handle_t named_pipe_device_ioctl( struct fd *fd, ioctl_code_t code,
} }
name.str = buffer->Name; name.str = buffer->Name;
name.len = (buffer->NameLength / sizeof(WCHAR)) * sizeof(WCHAR); name.len = (buffer->NameLength / sizeof(WCHAR)) * sizeof(WCHAR);
if (!(pipe = (struct named_pipe *)find_object( device->pipes, &name, OBJ_CASE_INSENSITIVE ))) if (!(pipe = open_named_object( &device->obj, &named_pipe_ops, &name, 0 ))) return 0;
{
set_error( STATUS_OBJECT_NAME_NOT_FOUND );
return 0;
}
if (!(server = find_available_server( pipe ))) if (!(server = find_available_server( pipe )))
{ {
struct async *async; struct async *async;
@ -957,7 +913,7 @@ DECL_HANDLER(create_named_pipe)
else if (!(root = get_directory_obj( current->process, objattr->rootdir, 0 ))) return; else if (!(root = get_directory_obj( current->process, objattr->rootdir, 0 ))) return;
} }
pipe = create_named_pipe( root, &name, objattr->attributes | OBJ_OPENIF, sd ); pipe = create_named_object_dir( root, &name, objattr->attributes | OBJ_OPENIF, &named_pipe_ops );
if (root) release_object( root ); if (root) release_object( root );
if (!pipe) return; if (!pipe) return;