Move mutant objects into directory name space.
Vitaliy Margolen
wine-patch at kievinfo.com
Thu Dec 1 11:14:20 CST 2005
ChangeLog:
Move mutant objects into directory name space.
Change tests accordingly.
dlls/kernel/sync.c | 4 ++--
dlls/ntdll/sync.c | 2 ++
dlls/ntdll/tests/om.c | 12 ++++++------
server/mutex.c | 21 +++++++++++++++++----
server/protocol.def | 2 ++
5 files changed, 29 insertions(+), 12 deletions(-)
-------------- next part --------------
62b047641aa6111f6f0ddf379431a808e78cdec7
diff --git a/dlls/kernel/sync.c b/dlls/kernel/sync.c
index 8ccc651..158eaa1 100644
--- a/dlls/kernel/sync.c
+++ b/dlls/kernel/sync.c
@@ -661,7 +661,7 @@ HANDLE WINAPI CreateMutexW( SECURITY_ATT
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);
@@ -713,7 +713,7 @@ HANDLE WINAPI OpenMutexW( DWORD access,
if (!is_version_nt()) access = MUTEX_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 3132fdb..6a43e05 100644
--- a/dlls/ntdll/sync.c
+++ b/dlls/ntdll/sync.c
@@ -326,6 +326,7 @@ NTSTATUS WINAPI NtCreateMutant(OUT HANDL
{
req->access = access;
req->attributes = (attr) ? attr->Attributes : 0;
+ req->rootdir = (attr) ? attr->RootDirectory : 0;
req->owned = InitialOwner;
if (len) wine_server_add_data( req, attr->ObjectName->Buffer, len );
status = wine_server_call( req );
@@ -352,6 +353,7 @@ NTSTATUS WINAPI NtOpenMutant(OUT HANDLE*
{
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 );
status = wine_server_call( req );
*MutantHandle = reply->handle;
diff --git a/dlls/ntdll/tests/om.c b/dlls/ntdll/tests/om.c
index 79bd6b6..492033d 100644
--- a/dlls/ntdll/tests/om.c
+++ b/dlls/ntdll/tests/om.c
@@ -90,7 +90,7 @@ void test_case_sensitive (void)
attr.Attributes = 0;
status = pNtCreateMutant(&Mutant, GENERIC_ALL, &attr, FALSE);
- todo_wine ok(status == STATUS_OBJECT_PATH_NOT_FOUND,
+ ok(status == STATUS_OBJECT_PATH_NOT_FOUND,
"NtCreateMutant should have failed with STATUS_OBJECT_PATH_NOT_FOUND got(%08lx)\n", status);
pNtClose(Event);
@@ -191,13 +191,13 @@ static void test_name_collisions(void)
DIR_TEST_CREATE_FAILURE(&h, STATUS_OBJECT_NAME_EXISTS)
pNtClose(h);
status = pNtCreateMutant(&h, GENERIC_ALL, &attr, FALSE);
- todo_wine ok(status == STATUS_OBJECT_TYPE_MISMATCH,
+ ok(status == STATUS_OBJECT_TYPE_MISMATCH,
"NtCreateMutant should have failed with STATUS_OBJECT_TYPE_MISMATCH got(%08lx)\n", status);
pRtlFreeUnicodeString(&str);
pRtlCreateUnicodeStringFromAsciiz(&str, "\\??\\PIPE\\om.c-mutant");
status = pNtCreateMutant(&h, GENERIC_ALL, &attr, FALSE);
- todo_wine ok(status == STATUS_OBJECT_TYPE_MISMATCH || status == STATUS_OBJECT_PATH_NOT_FOUND,
+ ok(status == STATUS_OBJECT_TYPE_MISMATCH || status == STATUS_OBJECT_PATH_NOT_FOUND,
"NtCreateMutant should have failed with STATUS_OBJECT_TYPE_MISMATCH got(%08lx)\n", status);
pRtlFreeUnicodeString(&str);
@@ -420,18 +420,18 @@ void test_directory(void)
/* Test inavalid paths */
pRtlCreateUnicodeStringFromAsciiz(&str, "\\om.c-mutant");
status = pNtCreateMutant(&h, GENERIC_ALL, &attr, FALSE);
- todo_wine ok(status == STATUS_OBJECT_PATH_SYNTAX_BAD,
+ ok(status == STATUS_OBJECT_PATH_SYNTAX_BAD,
"NtCreateMutant should have failed with STATUS_OBJECT_PATH_SYNTAX_BAD got(%08lx)\n", status);
pRtlFreeUnicodeString(&str);
pRtlCreateUnicodeStringFromAsciiz(&str, "\\om.c-mutant\\");
status = pNtCreateMutant(&h, GENERIC_ALL, &attr, FALSE);
- todo_wine ok(status == STATUS_OBJECT_PATH_SYNTAX_BAD,
+ ok(status == STATUS_OBJECT_PATH_SYNTAX_BAD,
"NtCreateMutant should have failed with STATUS_OBJECT_PATH_SYNTAX_BAD got(%08lx)\n", status);
pRtlFreeUnicodeString(&str);
pRtlCreateUnicodeStringFromAsciiz(&str, "om.c\\-mutant");
status = pNtCreateMutant(&h, GENERIC_ALL, &attr, FALSE);
- todo_wine ok(status == STATUS_OBJECT_PATH_NOT_FOUND,
+ ok(status == STATUS_OBJECT_PATH_NOT_FOUND,
"NtCreateMutant should have failed with STATUS_OBJECT_PATH_NOT_FOUND got(%08lx)\n", status);
pRtlFreeUnicodeString(&str);
diff --git a/server/mutex.c b/server/mutex.c
index 0953f3f..9e3bdc3 100644
--- a/server/mutex.c
+++ b/server/mutex.c
@@ -66,11 +66,12 @@ static const struct object_ops mutex_ops
};
-static struct mutex *create_mutex( const struct unicode_str *name, unsigned int attr, int owned )
+static struct mutex *create_mutex( struct directory *root, const struct unicode_str *name,
+ unsigned int attr, int owned )
{
struct mutex *mutex;
- if ((mutex = create_named_object( sync_namespace, &mutex_ops, name, attr )))
+ if ((mutex = create_named_object_dir( root, name, attr, &mutex_ops )))
{
if (get_error() != STATUS_OBJECT_NAME_EXISTS)
{
@@ -175,24 +176,36 @@ DECL_HANDLER(create_mutex)
{
struct mutex *mutex;
struct unicode_str name;
+ struct directory *root = NULL;
reply->handle = 0;
get_req_unicode_str( &name );
- if ((mutex = create_mutex( &name, req->attributes, req->owned )))
+ if (req->rootdir && !(root = get_directory_obj( current->process, req->rootdir, 0 )))
+ return;
+
+ if ((mutex = create_mutex( root, &name, req->attributes, req->owned )))
{
reply->handle = alloc_handle( current->process, mutex, req->access,
req->attributes & OBJ_INHERIT );
release_object( mutex );
}
+
+ if (root) release_object( root );
}
/* open a handle to a mutex */
DECL_HANDLER(open_mutex)
{
struct unicode_str name;
+ struct directory *root = NULL;
get_req_unicode_str( &name );
- reply->handle = open_object( sync_namespace, &name, &mutex_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, &mutex_ops, req->access );
+
+ if (root) release_object( root );
}
/* release a mutex */
diff --git a/server/protocol.def b/server/protocol.def
index afd57d6..934ae42 100644
--- a/server/protocol.def
+++ b/server/protocol.def
@@ -527,6 +527,7 @@ enum event_op { PULSE_EVENT, SET_EVENT,
@REQ(create_mutex)
unsigned int access; /* wanted access rights */
unsigned int attributes; /* object attributes */
+ obj_handle_t rootdir; /* root directory */
int owned; /* initially owned? */
VARARG(name,unicode_str); /* object name */
@REPLY
@@ -546,6 +547,7 @@ enum event_op { PULSE_EVENT, SET_EVENT,
@REQ(open_mutex)
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 mutex */
More information about the wine-patches
mailing list