server: Implement the open_file method for mailslots.
Get rid of the open_mailslot request, we can now use a normal open_file_object.
This commit is contained in:
parent
ee478bbada
commit
806bb49eda
|
@ -143,7 +143,6 @@ NTSTATUS WINAPI NtCreateFile( PHANDLE handle, ACCESS_MASK access, POBJECT_ATTRIB
|
|||
ULONG options, PVOID ea_buffer, ULONG ea_length )
|
||||
{
|
||||
static const WCHAR pipeW[] = {'\\','?','?','\\','p','i','p','e','\\'};
|
||||
static const WCHAR mailslotW[] = {'\\','?','?','\\','M','A','I','L','S','L','O','T','\\'};
|
||||
ANSI_STRING unix_name;
|
||||
int created = FALSE;
|
||||
|
||||
|
@ -179,28 +178,6 @@ NTSTATUS WINAPI NtCreateFile( PHANDLE handle, ACCESS_MASK access, POBJECT_ATTRIB
|
|||
return io->u.Status;
|
||||
}
|
||||
|
||||
/* check for mailslot */
|
||||
|
||||
if (attr->ObjectName->Length > sizeof(mailslotW) &&
|
||||
!memicmpW( attr->ObjectName->Buffer, mailslotW, sizeof(mailslotW)/sizeof(WCHAR) ))
|
||||
{
|
||||
if (attr->SecurityQualityOfService)
|
||||
FIXME("SecurityQualityOfService ignored\n");
|
||||
SERVER_START_REQ( open_mailslot )
|
||||
{
|
||||
req->access = access & GENERIC_WRITE;
|
||||
req->attributes = attr->Attributes;
|
||||
req->rootdir = attr->RootDirectory;
|
||||
req->sharing = sharing;
|
||||
wine_server_add_data( req, attr->ObjectName->Buffer,
|
||||
attr->ObjectName->Length );
|
||||
io->u.Status = wine_server_call( req );
|
||||
*handle = reply->handle;
|
||||
}
|
||||
SERVER_END_REQ;
|
||||
return io->u.Status;
|
||||
}
|
||||
|
||||
if (attr->RootDirectory)
|
||||
{
|
||||
FIXME( "RootDirectory %p not supported\n", attr->RootDirectory );
|
||||
|
|
|
@ -3881,23 +3881,6 @@ struct create_mailslot_reply
|
|||
|
||||
|
||||
|
||||
struct open_mailslot_request
|
||||
{
|
||||
struct request_header __header;
|
||||
unsigned int access;
|
||||
unsigned int attributes;
|
||||
obj_handle_t rootdir;
|
||||
unsigned int sharing;
|
||||
/* VARARG(name,unicode_str); */
|
||||
};
|
||||
struct open_mailslot_reply
|
||||
{
|
||||
struct reply_header __header;
|
||||
obj_handle_t handle;
|
||||
};
|
||||
|
||||
|
||||
|
||||
struct set_mailslot_info_request
|
||||
{
|
||||
struct request_header __header;
|
||||
|
@ -4240,7 +4223,6 @@ enum request
|
|||
REQ_get_token_groups,
|
||||
REQ_set_security_object,
|
||||
REQ_create_mailslot,
|
||||
REQ_open_mailslot,
|
||||
REQ_set_mailslot_info,
|
||||
REQ_create_directory,
|
||||
REQ_open_directory,
|
||||
|
@ -4465,7 +4447,6 @@ union generic_request
|
|||
struct get_token_groups_request get_token_groups_request;
|
||||
struct set_security_object_request set_security_object_request;
|
||||
struct create_mailslot_request create_mailslot_request;
|
||||
struct open_mailslot_request open_mailslot_request;
|
||||
struct set_mailslot_info_request set_mailslot_info_request;
|
||||
struct create_directory_request create_directory_request;
|
||||
struct open_directory_request open_directory_request;
|
||||
|
@ -4688,7 +4669,6 @@ union generic_reply
|
|||
struct get_token_groups_reply get_token_groups_reply;
|
||||
struct set_security_object_reply set_security_object_reply;
|
||||
struct create_mailslot_reply create_mailslot_reply;
|
||||
struct open_mailslot_reply open_mailslot_reply;
|
||||
struct set_mailslot_info_reply set_mailslot_info_reply;
|
||||
struct create_directory_reply create_directory_reply;
|
||||
struct open_directory_reply open_directory_reply;
|
||||
|
@ -4700,6 +4680,6 @@ union generic_reply
|
|||
struct allocate_locally_unique_id_reply allocate_locally_unique_id_reply;
|
||||
};
|
||||
|
||||
#define SERVER_PROTOCOL_VERSION 286
|
||||
#define SERVER_PROTOCOL_VERSION 287
|
||||
|
||||
#endif /* __WINE_WINE_SERVER_PROTOCOL_H */
|
||||
|
|
|
@ -66,6 +66,8 @@ struct mailslot
|
|||
static void mailslot_dump( struct object*, int );
|
||||
static struct fd *mailslot_get_fd( struct object * );
|
||||
static unsigned int mailslot_map_access( struct object *obj, unsigned int access );
|
||||
static struct object *mailslot_open_file( struct object *obj, unsigned int access,
|
||||
unsigned int sharing, unsigned int options );
|
||||
static void mailslot_destroy( struct object * );
|
||||
|
||||
static const struct object_ops mailslot_ops =
|
||||
|
@ -80,7 +82,7 @@ static const struct object_ops mailslot_ops =
|
|||
mailslot_get_fd, /* get_fd */
|
||||
mailslot_map_access, /* map_access */
|
||||
no_lookup_name, /* lookup_name */
|
||||
no_open_file, /* open_file */
|
||||
mailslot_open_file, /* open_file */
|
||||
fd_close_handle, /* close_handle */
|
||||
mailslot_destroy /* destroy */
|
||||
};
|
||||
|
@ -241,6 +243,43 @@ static unsigned int mailslot_map_access( struct object *obj, unsigned int access
|
|||
return access & ~(GENERIC_READ | GENERIC_WRITE | GENERIC_EXECUTE | GENERIC_ALL);
|
||||
}
|
||||
|
||||
static struct object *mailslot_open_file( struct object *obj, unsigned int access,
|
||||
unsigned int sharing, unsigned int options )
|
||||
{
|
||||
struct mailslot *mailslot = (struct mailslot *)obj;
|
||||
struct mail_writer *writer;
|
||||
|
||||
if (!(sharing & FILE_SHARE_READ))
|
||||
{
|
||||
set_error( STATUS_SHARING_VIOLATION );
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!list_empty( &mailslot->writers ))
|
||||
{
|
||||
/* Readers and writers cannot be mixed.
|
||||
* If there's more than one writer, all writers must open with FILE_SHARE_WRITE
|
||||
*/
|
||||
writer = LIST_ENTRY( list_head(&mailslot->writers), struct mail_writer, entry );
|
||||
|
||||
if (((access & (GENERIC_WRITE|FILE_WRITE_DATA)) || (writer->access & FILE_WRITE_DATA)) &&
|
||||
!((sharing & FILE_SHARE_WRITE) && (writer->sharing & FILE_SHARE_WRITE)))
|
||||
{
|
||||
set_error( STATUS_SHARING_VIOLATION );
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if (!(writer = alloc_object( &mail_writer_ops ))) return NULL;
|
||||
grab_object( mailslot );
|
||||
writer->mailslot = mailslot;
|
||||
writer->access = mail_writer_map_access( &writer->obj, access );
|
||||
writer->sharing = sharing;
|
||||
|
||||
list_add_head( &mailslot->writers, &writer->entry );
|
||||
return &writer->obj;
|
||||
}
|
||||
|
||||
static void mailslot_queue_async( struct fd *fd, const async_data_t *data, int type, int count )
|
||||
{
|
||||
struct mailslot *mailslot = get_fd_user( fd );
|
||||
|
@ -427,48 +466,12 @@ static struct fd *mail_writer_get_fd( struct object *obj )
|
|||
|
||||
static unsigned int mail_writer_map_access( struct object *obj, unsigned int access )
|
||||
{
|
||||
if (access & GENERIC_READ) access |= FILE_GENERIC_READ;
|
||||
/* mailslot writers can only get write access */
|
||||
if (access & GENERIC_WRITE) access |= FILE_GENERIC_WRITE;
|
||||
if (access & GENERIC_EXECUTE) access |= FILE_GENERIC_EXECUTE;
|
||||
if (access & GENERIC_ALL) access |= FILE_ALL_ACCESS;
|
||||
if (access & GENERIC_ALL) access |= FILE_GENERIC_WRITE;
|
||||
return access & ~(GENERIC_READ | GENERIC_WRITE | GENERIC_EXECUTE | GENERIC_ALL);
|
||||
}
|
||||
|
||||
/*
|
||||
* Readers and writers cannot be mixed.
|
||||
* If there's more than one writer, all writers must open with FILE_SHARE_WRITE
|
||||
*/
|
||||
static struct mail_writer *create_mail_writer( struct mailslot *mailslot, unsigned int access,
|
||||
unsigned int sharing )
|
||||
{
|
||||
struct mail_writer *writer;
|
||||
|
||||
if (!list_empty( &mailslot->writers ))
|
||||
{
|
||||
writer = LIST_ENTRY( list_head(&mailslot->writers), struct mail_writer, entry );
|
||||
|
||||
if (((access & (GENERIC_WRITE|FILE_WRITE_DATA)) || (writer->access & FILE_WRITE_DATA)) &&
|
||||
!((sharing & FILE_SHARE_WRITE) && (writer->sharing & FILE_SHARE_WRITE)))
|
||||
{
|
||||
set_error( STATUS_SHARING_VIOLATION );
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
writer = alloc_object( &mail_writer_ops );
|
||||
if (!writer)
|
||||
return NULL;
|
||||
|
||||
grab_object( mailslot );
|
||||
writer->mailslot = mailslot;
|
||||
writer->access = mail_writer_map_access( &writer->obj, access );
|
||||
writer->sharing = sharing;
|
||||
|
||||
list_add_head( &mailslot->writers, &writer->entry );
|
||||
|
||||
return writer;
|
||||
}
|
||||
|
||||
static struct mailslot *get_mailslot_obj( struct process *process, obj_handle_t handle,
|
||||
unsigned int access )
|
||||
{
|
||||
|
@ -499,44 +502,6 @@ DECL_HANDLER(create_mailslot)
|
|||
}
|
||||
|
||||
|
||||
/* open an existing mailslot */
|
||||
DECL_HANDLER(open_mailslot)
|
||||
{
|
||||
struct mailslot *mailslot;
|
||||
struct unicode_str name;
|
||||
struct directory *root = NULL;
|
||||
|
||||
reply->handle = 0;
|
||||
get_req_unicode_str( &name );
|
||||
|
||||
if (!(req->sharing & FILE_SHARE_READ))
|
||||
{
|
||||
set_error( STATUS_SHARING_VIOLATION );
|
||||
return;
|
||||
}
|
||||
|
||||
if (req->rootdir && !(root = get_directory_obj( current->process, req->rootdir, 0 )))
|
||||
return;
|
||||
mailslot = open_object_dir( root, &name, req->attributes, &mailslot_ops );
|
||||
if (root) release_object( root );
|
||||
|
||||
if (mailslot)
|
||||
{
|
||||
struct mail_writer *writer;
|
||||
|
||||
writer = create_mail_writer( mailslot, req->access, req->sharing );
|
||||
if (writer)
|
||||
{
|
||||
reply->handle = alloc_handle( current->process, writer, req->access, req->attributes );
|
||||
release_object( writer );
|
||||
}
|
||||
release_object( mailslot );
|
||||
}
|
||||
else
|
||||
set_error( STATUS_NO_SUCH_FILE );
|
||||
}
|
||||
|
||||
|
||||
/* set mailslot information */
|
||||
DECL_HANDLER(set_mailslot_info)
|
||||
{
|
||||
|
|
|
@ -2792,18 +2792,6 @@ enum message_type
|
|||
@END
|
||||
|
||||
|
||||
/* Open an existing mailslot */
|
||||
@REQ(open_mailslot)
|
||||
unsigned int access;
|
||||
unsigned int attributes; /* object attributes */
|
||||
obj_handle_t rootdir; /* root directory */
|
||||
unsigned int sharing; /* sharing mode */
|
||||
VARARG(name,unicode_str); /* mailslot name */
|
||||
@REPLY
|
||||
obj_handle_t handle; /* handle to the mailslot */
|
||||
@END
|
||||
|
||||
|
||||
/* Set mailslot information */
|
||||
@REQ(set_mailslot_info)
|
||||
obj_handle_t handle; /* handle to the mailslot */
|
||||
|
|
|
@ -318,7 +318,6 @@ DECL_HANDLER(get_token_user);
|
|||
DECL_HANDLER(get_token_groups);
|
||||
DECL_HANDLER(set_security_object);
|
||||
DECL_HANDLER(create_mailslot);
|
||||
DECL_HANDLER(open_mailslot);
|
||||
DECL_HANDLER(set_mailslot_info);
|
||||
DECL_HANDLER(create_directory);
|
||||
DECL_HANDLER(open_directory);
|
||||
|
@ -542,7 +541,6 @@ static const req_handler req_handlers[REQ_NB_REQUESTS] =
|
|||
(req_handler)req_get_token_groups,
|
||||
(req_handler)req_set_security_object,
|
||||
(req_handler)req_create_mailslot,
|
||||
(req_handler)req_open_mailslot,
|
||||
(req_handler)req_set_mailslot_info,
|
||||
(req_handler)req_create_directory,
|
||||
(req_handler)req_open_directory,
|
||||
|
|
|
@ -3348,21 +3348,6 @@ static void dump_create_mailslot_reply( const struct create_mailslot_reply *req
|
|||
fprintf( stderr, " handle=%p", req->handle );
|
||||
}
|
||||
|
||||
static void dump_open_mailslot_request( const struct open_mailslot_request *req )
|
||||
{
|
||||
fprintf( stderr, " access=%08x,", req->access );
|
||||
fprintf( stderr, " attributes=%08x,", req->attributes );
|
||||
fprintf( stderr, " rootdir=%p,", req->rootdir );
|
||||
fprintf( stderr, " sharing=%08x,", req->sharing );
|
||||
fprintf( stderr, " name=" );
|
||||
dump_varargs_unicode_str( cur_size );
|
||||
}
|
||||
|
||||
static void dump_open_mailslot_reply( const struct open_mailslot_reply *req )
|
||||
{
|
||||
fprintf( stderr, " handle=%p", req->handle );
|
||||
}
|
||||
|
||||
static void dump_set_mailslot_info_request( const struct set_mailslot_info_request *req )
|
||||
{
|
||||
fprintf( stderr, " handle=%p,", req->handle );
|
||||
|
@ -3687,7 +3672,6 @@ static const dump_func req_dumpers[REQ_NB_REQUESTS] = {
|
|||
(dump_func)dump_get_token_groups_request,
|
||||
(dump_func)dump_set_security_object_request,
|
||||
(dump_func)dump_create_mailslot_request,
|
||||
(dump_func)dump_open_mailslot_request,
|
||||
(dump_func)dump_set_mailslot_info_request,
|
||||
(dump_func)dump_create_directory_request,
|
||||
(dump_func)dump_open_directory_request,
|
||||
|
@ -3908,7 +3892,6 @@ static const dump_func reply_dumpers[REQ_NB_REQUESTS] = {
|
|||
(dump_func)dump_get_token_groups_reply,
|
||||
(dump_func)0,
|
||||
(dump_func)dump_create_mailslot_reply,
|
||||
(dump_func)dump_open_mailslot_reply,
|
||||
(dump_func)dump_set_mailslot_info_reply,
|
||||
(dump_func)dump_create_directory_reply,
|
||||
(dump_func)dump_open_directory_reply,
|
||||
|
@ -4129,7 +4112,6 @@ static const char * const req_names[REQ_NB_REQUESTS] = {
|
|||
"get_token_groups",
|
||||
"set_security_object",
|
||||
"create_mailslot",
|
||||
"open_mailslot",
|
||||
"set_mailslot_info",
|
||||
"create_directory",
|
||||
"open_directory",
|
||||
|
|
Loading…
Reference in New Issue