Move semaphore objects into directory name space.

This commit is contained in:
Vitaliy Margolen 2005-12-02 16:01:17 +01:00 committed by Alexandre Julliard
parent f676bc8d85
commit 5daae3dfa9
6 changed files with 28 additions and 6 deletions

View File

@ -807,6 +807,7 @@ HANDLE WINAPI CreateSemaphoreW( SECURITY_ATTRIBUTES *sa, LONG initial,
{ {
RtlInitUnicodeString( &nameW, name ); RtlInitUnicodeString( &nameW, name );
attr.ObjectName = &nameW; attr.ObjectName = &nameW;
attr.RootDirectory = get_BaseNamedObjects_handle();
} }
status = NtCreateSemaphore( &ret, SEMAPHORE_ALL_ACCESS, &attr, initial, max ); status = NtCreateSemaphore( &ret, SEMAPHORE_ALL_ACCESS, &attr, initial, max );
@ -858,6 +859,7 @@ HANDLE WINAPI OpenSemaphoreW( DWORD access, BOOL inherit, LPCWSTR name )
{ {
RtlInitUnicodeString( &nameW, name ); RtlInitUnicodeString( &nameW, name );
attr.ObjectName = &nameW; attr.ObjectName = &nameW;
attr.RootDirectory = get_BaseNamedObjects_handle();
} }
status = NtOpenSemaphore( &ret, access, &attr ); status = NtOpenSemaphore( &ret, access, &attr );

View File

@ -85,6 +85,7 @@ NTSTATUS WINAPI NtCreateSemaphore( OUT PHANDLE SemaphoreHandle,
{ {
req->access = access; req->access = access;
req->attributes = (attr) ? attr->Attributes : 0; req->attributes = (attr) ? attr->Attributes : 0;
req->rootdir = attr ? attr->RootDirectory : 0;
req->initial = InitialCount; req->initial = InitialCount;
req->max = MaximumCount; req->max = MaximumCount;
if (len) wine_server_add_data( req, attr->ObjectName->Buffer, len ); if (len) wine_server_add_data( req, attr->ObjectName->Buffer, len );
@ -111,6 +112,7 @@ NTSTATUS WINAPI NtOpenSemaphore( OUT PHANDLE SemaphoreHandle,
{ {
req->access = access; req->access = access;
req->attributes = (attr) ? attr->Attributes : 0; req->attributes = (attr) ? attr->Attributes : 0;
req->rootdir = attr ? attr->RootDirectory : 0;
if (len) wine_server_add_data( req, attr->ObjectName->Buffer, len ); if (len) wine_server_add_data( req, attr->ObjectName->Buffer, len );
ret = wine_server_call( req ); ret = wine_server_call( req );
*SemaphoreHandle = reply->handle; *SemaphoreHandle = reply->handle;

View File

@ -707,6 +707,7 @@ struct create_semaphore_request
struct request_header __header; struct request_header __header;
unsigned int access; unsigned int access;
unsigned int attributes; unsigned int attributes;
obj_handle_t rootdir;
unsigned int initial; unsigned int initial;
unsigned int max; unsigned int max;
/* VARARG(name,unicode_str); */ /* VARARG(name,unicode_str); */
@ -738,6 +739,7 @@ struct open_semaphore_request
struct request_header __header; struct request_header __header;
unsigned int access; unsigned int access;
unsigned int attributes; unsigned int attributes;
obj_handle_t rootdir;
/* VARARG(name,unicode_str); */ /* VARARG(name,unicode_str); */
}; };
struct open_semaphore_reply struct open_semaphore_reply
@ -4306,6 +4308,6 @@ union generic_reply
struct query_symlink_reply query_symlink_reply; struct query_symlink_reply query_symlink_reply;
}; };
#define SERVER_PROTOCOL_VERSION 202 #define SERVER_PROTOCOL_VERSION 203
#endif /* __WINE_WINE_SERVER_PROTOCOL_H */ #endif /* __WINE_WINE_SERVER_PROTOCOL_H */

View File

@ -558,6 +558,7 @@ enum event_op { PULSE_EVENT, SET_EVENT, RESET_EVENT };
@REQ(create_semaphore) @REQ(create_semaphore)
unsigned int access; /* wanted access rights */ unsigned int access; /* wanted access rights */
unsigned int attributes; /* object attributes */ unsigned int attributes; /* object attributes */
obj_handle_t rootdir; /* root directory */
unsigned int initial; /* initial count */ unsigned int initial; /* initial count */
unsigned int max; /* maximum count */ unsigned int max; /* maximum count */
VARARG(name,unicode_str); /* object name */ VARARG(name,unicode_str); /* object name */
@ -579,6 +580,7 @@ enum event_op { PULSE_EVENT, SET_EVENT, RESET_EVENT };
@REQ(open_semaphore) @REQ(open_semaphore)
unsigned int access; /* wanted access rights */ unsigned int access; /* wanted access rights */
unsigned int attributes; /* object attributes */ unsigned int attributes; /* object attributes */
obj_handle_t rootdir; /* root directory */
VARARG(name,unicode_str); /* object name */ VARARG(name,unicode_str); /* object name */
@REPLY @REPLY
obj_handle_t handle; /* handle to the semaphore */ obj_handle_t handle; /* handle to the semaphore */

View File

@ -63,8 +63,8 @@ static const struct object_ops semaphore_ops =
}; };
static struct semaphore *create_semaphore( const struct unicode_str *name, unsigned int attr, static struct semaphore *create_semaphore( struct directory *root, const struct unicode_str *name,
unsigned int initial, unsigned int max ) unsigned int attr, unsigned int initial, unsigned int max )
{ {
struct semaphore *sem; struct semaphore *sem;
@ -73,7 +73,7 @@ static struct semaphore *create_semaphore( const struct unicode_str *name, unsig
set_error( STATUS_INVALID_PARAMETER ); set_error( STATUS_INVALID_PARAMETER );
return NULL; return NULL;
} }
if ((sem = create_named_object( sync_namespace, &semaphore_ops, name, attr ))) if ((sem = create_named_object_dir( root, name, attr, &semaphore_ops )))
{ {
if (get_error() != STATUS_OBJECT_NAME_EXISTS) if (get_error() != STATUS_OBJECT_NAME_EXISTS)
{ {
@ -150,24 +150,36 @@ DECL_HANDLER(create_semaphore)
{ {
struct semaphore *sem; struct semaphore *sem;
struct unicode_str name; struct unicode_str name;
struct directory *root = NULL;
reply->handle = 0; reply->handle = 0;
get_req_unicode_str( &name ); get_req_unicode_str( &name );
if ((sem = create_semaphore( &name, req->attributes, req->initial, req->max ))) if (req->rootdir && !(root = get_directory_obj( current->process, req->rootdir, 0 )))
return;
if ((sem = create_semaphore( root, &name, req->attributes, req->initial, req->max )))
{ {
reply->handle = alloc_handle( current->process, sem, req->access, reply->handle = alloc_handle( current->process, sem, req->access,
req->attributes & OBJ_INHERIT ); req->attributes & OBJ_INHERIT );
release_object( sem ); release_object( sem );
} }
if (root) release_object( root );
} }
/* open a handle to a semaphore */ /* open a handle to a semaphore */
DECL_HANDLER(open_semaphore) DECL_HANDLER(open_semaphore)
{ {
struct unicode_str name; struct unicode_str name;
struct directory *root = NULL;
get_req_unicode_str( &name ); get_req_unicode_str( &name );
reply->handle = open_object( sync_namespace, &name, &semaphore_ops, req->access, req->attributes ); 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 (root) release_object( root );
} }
/* release a semaphore */ /* release a semaphore */

View File

@ -968,6 +968,7 @@ static void dump_create_semaphore_request( const struct create_semaphore_request
{ {
fprintf( stderr, " access=%08x,", req->access ); fprintf( stderr, " access=%08x,", req->access );
fprintf( stderr, " attributes=%08x,", req->attributes ); fprintf( stderr, " attributes=%08x,", req->attributes );
fprintf( stderr, " rootdir=%p,", req->rootdir );
fprintf( stderr, " initial=%08x,", req->initial ); fprintf( stderr, " initial=%08x,", req->initial );
fprintf( stderr, " max=%08x,", req->max ); fprintf( stderr, " max=%08x,", req->max );
fprintf( stderr, " name=" ); fprintf( stderr, " name=" );
@ -994,6 +995,7 @@ static void dump_open_semaphore_request( const struct open_semaphore_request *re
{ {
fprintf( stderr, " access=%08x,", req->access ); fprintf( stderr, " access=%08x,", req->access );
fprintf( stderr, " attributes=%08x,", req->attributes ); fprintf( stderr, " attributes=%08x,", req->attributes );
fprintf( stderr, " rootdir=%p,", req->rootdir );
fprintf( stderr, " name=" ); fprintf( stderr, " name=" );
dump_varargs_unicode_str( cur_size ); dump_varargs_unicode_str( cur_size );
} }