[PATCH 3/3] server: Report the parent device for named pipe files.

Zebediah Figura z.figura12 at gmail.com
Mon Aug 3 20:14:44 CDT 2020


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

diff --git a/dlls/ntdll/tests/om.c b/dlls/ntdll/tests/om.c
index a9da114cb5c..20028cf5e9a 100644
--- a/dlls/ntdll/tests/om.c
+++ b/dlls/ntdll/tests/om.c
@@ -1455,7 +1455,7 @@ static void test_query_object(void)
                                1, 1000, 1000, 1000, NULL );
     ok( handle != INVALID_HANDLE_VALUE, "CreateNamedPipe failed err %u\n", GetLastError() );
 
-    test_object_name( handle, L"\\Device\\NamedPipe\\test_pipe", TRUE );
+    test_object_name( handle, L"\\Device\\NamedPipe\\test_pipe", FALSE );
     test_object_type( handle, L"File" );
     test_file_info( handle );
 
@@ -1472,7 +1472,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_todo( handle, L"File" );
     test_file_info( handle );
 
diff --git a/server/directory.c b/server/directory.c
index 198fc48ece2..e988ab8bad5 100644
--- a/server/directory.c
+++ b/server/directory.c
@@ -404,7 +404,7 @@ void init_directories(void)
     struct directory *dir_driver, *dir_device, *dir_global, *dir_kernel;
     struct object *link_dosdev, *link_global, *link_nul, *link_pipe, *link_mailslot;
     struct object *link_conin, *link_conout, *link_con;
-    struct object *named_pipe_device, *mailslot_device, *null_device, *user_data_mapping, *console_device;
+    struct object *mailslot_device, *null_device, *user_data_mapping, *console_device;
     struct keyed_event *keyed_event;
     unsigned int i;
 
diff --git a/server/file.h b/server/file.h
index b24f0b943ec..d869c53cdbc 100644
--- a/server/file.h
+++ b/server/file.h
@@ -181,6 +181,8 @@ extern struct object *create_user_data_mapping( struct object *root, const struc
 
 /* device functions */
 
+extern struct object *named_pipe_device;
+
 extern struct object *create_named_pipe_device( struct object *root, const struct unicode_str *name );
 extern struct object *create_mailslot_device( struct object *root, const struct unicode_str *name );
 extern struct object *create_console_device( struct object *root, const struct unicode_str *name );
diff --git a/server/named_pipe.c b/server/named_pipe.c
index 7eb0905293e..2a6a341b24c 100644
--- a/server/named_pipe.c
+++ b/server/named_pipe.c
@@ -42,6 +42,8 @@
 #include "security.h"
 #include "process.h"
 
+struct object *named_pipe_device;
+
 struct named_pipe;
 
 struct pipe_message
@@ -136,6 +138,7 @@ static const struct object_ops named_pipe_ops =
 /* common server and client pipe end functions */
 static void pipe_end_destroy( struct object *obj );
 static enum server_fd_type pipe_end_get_fd_type( struct fd *fd );
+static struct object *pipe_end_get_parent( struct fd *fd );
 static struct fd *pipe_end_get_fd( struct object *obj );
 static struct security_descriptor *pipe_end_get_sd( struct object *obj );
 static int pipe_end_set_sd( struct object *obj, const struct security_descriptor *sd,
@@ -180,7 +183,7 @@ static const struct fd_ops pipe_server_fd_ops =
     default_fd_get_poll_events,   /* get_poll_events */
     default_poll_event,           /* poll_event */
     pipe_end_get_fd_type,         /* get_fd_type */
-    no_fd_get_parent,             /* get_parent */
+    pipe_end_get_parent,          /* get_parent */
     pipe_end_read,                /* read */
     pipe_end_write,               /* write */
     pipe_end_flush,               /* flush */
@@ -223,7 +226,7 @@ static const struct fd_ops pipe_client_fd_ops =
     default_fd_get_poll_events,   /* get_poll_events */
     default_poll_event,           /* poll_event */
     pipe_end_get_fd_type,         /* get_fd_type */
-    no_fd_get_parent,             /* get_parent */
+    pipe_end_get_parent,          /* get_parent */
     pipe_end_read,                /* read */
     pipe_end_write,               /* write */
     pipe_end_flush,               /* flush */
@@ -269,6 +272,7 @@ 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_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 struct object *named_pipe_device_file_get_parent( struct fd *fd );
 static void named_pipe_device_file_destroy( struct object *obj );
 
 static const struct object_ops named_pipe_device_file_ops =
@@ -299,7 +303,7 @@ static const struct fd_ops named_pipe_device_fd_ops =
     default_fd_get_poll_events,              /* get_poll_events */
     default_poll_event,                      /* poll_event */
     named_pipe_device_file_get_fd_type,      /* get_fd_type */
-    no_fd_get_parent,                        /* get_parent */
+    named_pipe_device_file_get_parent,       /* get_parent */
     no_fd_read,                              /* read */
     no_fd_write,                             /* write */
     no_fd_flush,                             /* flush */
@@ -538,6 +542,11 @@ static enum server_fd_type named_pipe_device_file_get_fd_type( struct fd *fd )
     return FD_TYPE_DEVICE;
 }
 
+static struct object *named_pipe_device_file_get_parent( struct fd *fd )
+{
+    return named_pipe_device;
+}
+
 static void named_pipe_device_file_destroy( struct object *obj )
 {
     struct named_pipe_device_file *file = (struct named_pipe_device_file*)obj;
@@ -936,6 +945,11 @@ static enum server_fd_type pipe_end_get_fd_type( struct fd *fd )
     return FD_TYPE_PIPE;
 }
 
+static struct object *pipe_end_get_parent( struct fd *fd )
+{
+    return named_pipe_device;
+}
+
 static int pipe_end_peek( struct pipe_end *pipe_end )
 {
     unsigned reply_size = get_reply_max_size();
-- 
2.27.0




More information about the wine-devel mailing list