Move semaphore objects into directory name space.
Vitaliy Margolen
wine-patch at kievinfo.com
Thu Dec 1 17:31:00 CST 2005
ChangeLog:
Move semaphore objects into directory name space.
dlls/kernel/sync.c | 4 ++--
dlls/ntdll/sync.c | 2 ++
server/protocol.def | 2 ++
server/semaphore.c | 22 +++++++++++++++++-----
4 files changed, 23 insertions(+), 7 deletions(-)
-------------- next part --------------
a9028cafea26c318030ce7313a14da805b4ffbd6
diff --git a/dlls/kernel/sync.c b/dlls/kernel/sync.c
index 8b96963..d8284be 100644
--- a/dlls/kernel/sync.c
+++ b/dlls/kernel/sync.c
@@ -793,7 +793,7 @@ HANDLE WINAPI CreateSemaphoreW( SECURITY
NTSTATUS status;
attr.Length = sizeof(attr);
- attr.RootDirectory = 0;
+ attr.RootDirectory = get_BaseNamedObjects_handle();
attr.ObjectName = NULL;
attr.Attributes = OBJ_CASE_INSENSITIVE | OBJ_OPENIF |
((sa && sa->bInheritHandle) ? OBJ_INHERIT : 0);
@@ -845,7 +845,7 @@ HANDLE WINAPI OpenSemaphoreW( DWORD acce
if (!is_version_nt()) access = SEMAPHORE_ALL_ACCESS;
attr.Length = sizeof(attr);
- attr.RootDirectory = 0;
+ attr.RootDirectory = get_BaseNamedObjects_handle();
attr.ObjectName = NULL;
attr.Attributes = OBJ_CASE_INSENSITIVE | (inherit ? OBJ_INHERIT : 0);
attr.SecurityDescriptor = NULL;
diff --git a/dlls/ntdll/sync.c b/dlls/ntdll/sync.c
index 6a43e05..fd8898f 100644
--- a/dlls/ntdll/sync.c
+++ b/dlls/ntdll/sync.c
@@ -85,6 +85,7 @@ NTSTATUS WINAPI NtCreateSemaphore( OUT P
{
req->access = access;
req->attributes = (attr) ? attr->Attributes : 0;
+ req->rootdir = (attr) ? attr->RootDirectory : 0;
req->initial = InitialCount;
req->max = MaximumCount;
if (len) wine_server_add_data( req, attr->ObjectName->Buffer, len );
@@ -111,6 +112,7 @@ NTSTATUS WINAPI NtOpenSemaphore( OUT PHA
{
req->access = access;
req->attributes = (attr) ? attr->Attributes : 0;
+ req->rootdir = (attr) ? attr->RootDirectory : 0;
if (len) wine_server_add_data( req, attr->ObjectName->Buffer, len );
ret = wine_server_call( req );
*SemaphoreHandle = reply->handle;
diff --git a/server/protocol.def b/server/protocol.def
index 9343a6d..1cdb246 100644
--- a/server/protocol.def
+++ b/server/protocol.def
@@ -558,6 +558,7 @@ enum event_op { PULSE_EVENT, SET_EVENT,
@REQ(create_semaphore)
unsigned int access; /* wanted access rights */
unsigned int attributes; /* object attributes */
+ obj_handle_t rootdir; /* root directory */
unsigned int initial; /* initial count */
unsigned int max; /* maximum count */
VARARG(name,unicode_str); /* object name */
@@ -579,6 +580,7 @@ enum event_op { PULSE_EVENT, SET_EVENT,
@REQ(open_semaphore)
unsigned int access; /* wanted access rights */
unsigned int attributes; /* object attributes */
+ obj_handle_t rootdir; /* root directory */
VARARG(name,unicode_str); /* object name */
@REPLY
obj_handle_t handle; /* handle to the semaphore */
diff --git a/server/semaphore.c b/server/semaphore.c
index bff60c5..e8d9cbb 100644
--- a/server/semaphore.c
+++ b/server/semaphore.c
@@ -63,8 +63,8 @@ static const struct object_ops semaphore
};
-static struct semaphore *create_semaphore( const struct unicode_str *name, unsigned int attr,
- unsigned int initial, unsigned int max )
+static struct semaphore *create_semaphore( struct directory *root, const struct unicode_str *name,
+ unsigned int attr, unsigned int initial, unsigned int max )
{
struct semaphore *sem;
@@ -73,7 +73,7 @@ static struct semaphore *create_semaphor
set_error( STATUS_INVALID_PARAMETER );
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)
{
@@ -150,24 +150,36 @@ DECL_HANDLER(create_semaphore)
{
struct semaphore *sem;
struct unicode_str name;
+ struct directory *root = NULL;
reply->handle = 0;
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,
req->attributes & OBJ_INHERIT );
release_object( sem );
}
+
+ if (root) release_object( root );
}
/* open a handle to a semaphore */
DECL_HANDLER(open_semaphore)
{
struct unicode_str name;
+ struct directory *root = NULL;
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 */
More information about the wine-patches
mailing list