server: Support opening file objects from any root, not only directories.

Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Alexandre Julliard 2016-02-09 20:19:34 +09:00
parent 39e60dc680
commit 6ccefdb7c5
2 changed files with 16 additions and 21 deletions

View File

@ -2393,27 +2393,13 @@ DECL_HANDLER(flush)
DECL_HANDLER(open_file_object) DECL_HANDLER(open_file_object)
{ {
struct unicode_str name = get_req_unicode_str(); struct unicode_str name = get_req_unicode_str();
struct directory *root = NULL; struct object *obj, *result, *root = NULL;
struct object *obj, *result;
if (req->rootdir && !(root = get_directory_obj( current->process, req->rootdir, 0 ))) if (req->rootdir && !(root = get_handle_obj( current->process, req->rootdir, 0, NULL ))) return;
{
if (get_error() != STATUS_OBJECT_TYPE_MISMATCH) return; obj = open_named_object( root, NULL, &name, req->attributes );
if (!(obj = (struct object *)get_file_obj( current->process, req->rootdir, 0 ))) return; if (root) release_object( root );
if (name.len) if (!obj) return;
{
release_object( obj );
set_error( STATUS_OBJECT_PATH_NOT_FOUND );
return;
}
clear_error();
}
else
{
obj = open_object_dir( root, &name, req->attributes, NULL );
if (root) release_object( root );
if (!obj) return;
}
if ((result = obj->ops->open_file( obj, req->access, req->sharing, req->options ))) if ((result = obj->ops->open_file( obj, req->access, req->sharing, req->options )))
{ {

View File

@ -68,6 +68,7 @@ static struct object_type *file_get_type( struct object *obj );
static struct fd *file_get_fd( struct object *obj ); static struct fd *file_get_fd( struct object *obj );
static struct security_descriptor *file_get_sd( struct object *obj ); static struct security_descriptor *file_get_sd( struct object *obj );
static int file_set_sd( struct object *obj, const struct security_descriptor *sd, unsigned int set_info ); static int file_set_sd( struct object *obj, const struct security_descriptor *sd, unsigned int set_info );
static struct object *file_lookup_name( struct object *obj, struct unicode_str *name, unsigned int attr );
static struct object *file_open_file( struct object *obj, unsigned int access, static struct object *file_open_file( struct object *obj, unsigned int access,
unsigned int sharing, unsigned int options ); unsigned int sharing, unsigned int options );
static void file_destroy( struct object *obj ); static void file_destroy( struct object *obj );
@ -90,7 +91,7 @@ static const struct object_ops file_ops =
default_fd_map_access, /* map_access */ default_fd_map_access, /* map_access */
file_get_sd, /* get_sd */ file_get_sd, /* get_sd */
file_set_sd, /* set_sd */ file_set_sd, /* set_sd */
no_lookup_name, /* lookup_name */ file_lookup_name, /* lookup_name */
no_link_name, /* link_name */ no_link_name, /* link_name */
NULL, /* unlink_name */ NULL, /* unlink_name */
file_open_file, /* open_file */ file_open_file, /* open_file */
@ -609,6 +610,14 @@ static int file_set_sd( struct object *obj, const struct security_descriptor *sd
return 1; return 1;
} }
static struct object *file_lookup_name( struct object *obj, struct unicode_str *name, unsigned int attr )
{
if (!name || !name->len) return NULL; /* open the file itself */
set_error( STATUS_OBJECT_PATH_NOT_FOUND );
return NULL;
}
static struct object *file_open_file( struct object *obj, unsigned int access, static struct object *file_open_file( struct object *obj, unsigned int access,
unsigned int sharing, unsigned int options ) unsigned int sharing, unsigned int options )
{ {