[PATCH 3/3] server: Create named pipe device files as named objects under the Device directory.

Zebediah Figura z.figura12 at gmail.com
Sun Aug 16 19:36:05 CDT 2020


Signed-off-by: Zebediah Figura <z.figura12 at gmail.com>
---
 dlls/ntdll/tests/om.c |  2 +-
 server/named_pipe.c   | 19 ++++++++++++++++---
 2 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/dlls/ntdll/tests/om.c b/dlls/ntdll/tests/om.c
index ef050b062b2..be617ce8a1c 100644
--- a/dlls/ntdll/tests/om.c
+++ b/dlls/ntdll/tests/om.c
@@ -1461,7 +1461,7 @@ static void test_query_object(void)
     handle = CreateFileA( "\\\\.\\pipe", 0, 0, NULL, OPEN_EXISTING, 0, 0 );
     ok( handle != INVALID_HANDLE_VALUE, "CreateFile failed (%d)\n", GetLastError() );
 
-    test_object_name( handle, L"\\Device\\NamedPipe", TRUE );
+    test_object_name( handle, L"\\Device\\NamedPipe", FALSE );
     test_object_type( handle, L"File" );
     test_file_info( handle );
 
diff --git a/server/named_pipe.c b/server/named_pipe.c
index 2c7c45c2336..17d741263c0 100644
--- a/server/named_pipe.c
+++ b/server/named_pipe.c
@@ -267,6 +267,8 @@ static const struct object_ops named_pipe_device_ops =
 
 static void named_pipe_device_file_dump( struct object *obj, int verbose );
 static struct fd *named_pipe_device_file_get_fd( struct object *obj );
+static int named_pipe_device_file_link_name( struct object *obj, struct object_name *name, struct object *parent );
+static void named_pipe_device_file_unlink_name( struct object *obj, struct object_name *name );
 static int named_pipe_device_ioctl( struct fd *fd, ioctl_code_t code, struct async *async );
 static enum server_fd_type named_pipe_device_file_get_fd_type( struct fd *fd );
 static void named_pipe_device_file_destroy( struct object *obj );
@@ -286,8 +288,8 @@ static const struct object_ops named_pipe_device_file_ops =
     default_get_sd,                          /* get_sd */
     default_set_sd,                          /* set_sd */
     no_lookup_name,                          /* lookup_name */
-    no_link_name,                            /* link_name */
-    NULL,                                    /* unlink_name */
+    named_pipe_device_file_link_name,        /* link_name */
+    named_pipe_device_file_unlink_name,      /* unlink_name */
     no_open_file,                            /* open_file */
     no_kernel_obj_list,                      /* get_kernel_obj_list */
     fd_close_handle,                         /* close_handle */
@@ -482,9 +484,10 @@ static struct object *named_pipe_device_lookup_name( struct object *obj, struct
 static struct object *named_pipe_device_open_file( struct object *obj, unsigned int access,
                                                    unsigned int sharing, unsigned int options )
 {
+    struct unicode_str name = { obj->name->name, obj->name->len };
     struct named_pipe_device_file *file;
 
-    if (!(file = alloc_object( &named_pipe_device_file_ops ))) return NULL;
+    if (!(file = create_object( obj->name->parent, &named_pipe_device_file_ops, &name, 0, NULL ))) return NULL;
     file->device = (struct named_pipe_device *)grab_object( obj );
     if (!(file->fd = alloc_pseudo_fd( &named_pipe_device_fd_ops, obj, options )))
     {
@@ -532,6 +535,16 @@ static struct fd *named_pipe_device_file_get_fd( struct object *obj )
     return (struct fd *)grab_object( file->fd );
 }
 
+static int named_pipe_device_file_link_name( struct object *obj, struct object_name *name, struct object *parent )
+{
+    name->parent = grab_object( parent );
+    return 1;
+}
+
+static void named_pipe_device_file_unlink_name( struct object *obj, struct object_name *name )
+{
+}
+
 static enum server_fd_type named_pipe_device_file_get_fd_type( struct fd *fd )
 {
     return FD_TYPE_DEVICE;
-- 
2.27.0




More information about the wine-devel mailing list