[PATCH 1/3] server: Introduce a callback to retrieve the parent device from a file descriptor.
Zebediah Figura
z.figura12 at gmail.com
Mon Aug 3 20:14:42 CDT 2020
Signed-off-by: Zebediah Figura <z.figura12 at gmail.com>
---
This patch series doesn't handle ntoskrnl device files. It is written with the
ntoskrnl tests previously written in mind, and therefore is structured to make
implementation somewhat easier, but the implementation is rather nontrivial and
so far not known to be necessary.
The equivalent Staging patch uses the object tree for device files. At least two
problems immediately arise from this: firstly, there is no clean way to
distinguish the root file name '\\' from the directly opened device (a
distinction particularly important for file systems, but in fact even visible
with named pipes); secondly, this cannot accomodate an implementation that must
plumb requests through ntoskrnl, since object names are set at creation time. In
general it also smacks of hacking a name into the object tree, since that name
is not actually looked up directly as other names are.
Another possible design would be to handle it all on the server side. This would
mean changing the parameters of get_file_info to handle arbitrary buffers (or
else adding a new callback specifically for ObjectNameInformation). It would
also mean making get_object_info eventually asynchronous. After trying out that
approach, this one seemed architecturally simpler.
The equivalent Staging patch was originally written for msys2's strace.exe.
msys2 and cygwin have been broken in Wine for a long time, perhaps unfixably.
I'm not aware of other applications that need pipes, or similar objects, to
return accurate names from ObjectNameInformation. I'm submitting this patch
partly to upstream a long-standing Staging patch and fix tests, and partly
because I believe it will help implementation of object/file name information
for regular files with some of my local/planned changes to volume
infrastructure.
server/change.c | 1 +
server/console.c | 3 +++
server/device.c | 1 +
server/fd.c | 5 +++++
server/file.c | 1 +
server/file.h | 3 +++
server/mailslot.c | 3 +++
server/mapping.c | 1 +
server/named_pipe.c | 3 +++
server/serial.c | 1 +
server/sock.c | 2 ++
11 files changed, 24 insertions(+)
diff --git a/server/change.c b/server/change.c
index a8f3329c722..1eba2e4dd88 100644
--- a/server/change.c
+++ b/server/change.c
@@ -138,6 +138,7 @@ static const struct fd_ops dir_fd_ops =
dir_get_poll_events, /* get_poll_events */
default_poll_event, /* poll_event */
dir_get_fd_type, /* get_fd_type */
+ no_fd_get_parent, /* get_parent */
no_fd_read, /* read */
no_fd_write, /* write */
no_fd_flush, /* flush */
diff --git a/server/console.c b/server/console.c
index 53910b3f46e..bd8cb1995e7 100644
--- a/server/console.c
+++ b/server/console.c
@@ -111,6 +111,7 @@ static const struct fd_ops console_input_fd_ops =
default_fd_get_poll_events, /* get_poll_events */
default_poll_event, /* poll_event */
console_get_fd_type, /* get_fd_type */
+ no_fd_get_parent, /* get_parent */
no_fd_read, /* read */
no_fd_write, /* write */
no_fd_flush, /* flush */
@@ -168,6 +169,7 @@ static const struct fd_ops console_input_events_fd_ops =
default_fd_get_poll_events, /* get_poll_events */
default_poll_event, /* poll_event */
console_get_fd_type, /* get_fd_type */
+ no_fd_get_parent, /* get_parent */
no_fd_read, /* read */
no_fd_write, /* write */
no_fd_flush, /* flush */
@@ -248,6 +250,7 @@ static const struct fd_ops screen_buffer_fd_ops =
default_fd_get_poll_events, /* get_poll_events */
default_poll_event, /* poll_event */
console_get_fd_type, /* get_fd_type */
+ no_fd_get_parent, /* get_parent */
no_fd_read, /* read */
no_fd_write, /* write */
no_fd_flush, /* flush */
diff --git a/server/device.c b/server/device.c
index 01e08f295f7..73c6edcb078 100644
--- a/server/device.c
+++ b/server/device.c
@@ -219,6 +219,7 @@ static const struct fd_ops device_file_fd_ops =
default_fd_get_poll_events, /* get_poll_events */
default_poll_event, /* poll_event */
device_file_get_fd_type, /* get_fd_type */
+ no_fd_get_parent, /* get_parent */
device_file_read, /* read */
device_file_write, /* write */
device_file_flush, /* flush */
diff --git a/server/fd.c b/server/fd.c
index 7ea8ac273e5..064defc34e8 100644
--- a/server/fd.c
+++ b/server/fd.c
@@ -2246,6 +2246,11 @@ static void unmount_device( struct fd *device_fd )
release_object( device );
}
+struct object *no_fd_get_parent( struct fd *fd )
+{
+ return NULL;
+}
+
/* default read() routine */
int no_fd_read( struct fd *fd, struct async *async, file_pos_t pos )
{
diff --git a/server/file.c b/server/file.c
index 38260cfd2b3..0b92d6aae46 100644
--- a/server/file.c
+++ b/server/file.c
@@ -105,6 +105,7 @@ static const struct fd_ops file_fd_ops =
file_get_poll_events, /* get_poll_events */
default_poll_event, /* poll_event */
file_get_fd_type, /* get_fd_type */
+ no_fd_get_parent, /* get_parent */
no_fd_read, /* read */
no_fd_write, /* write */
no_fd_flush, /* flush */
diff --git a/server/file.h b/server/file.h
index e8ace7f49e4..b407c725db2 100644
--- a/server/file.h
+++ b/server/file.h
@@ -56,6 +56,8 @@ struct fd_ops
void (*poll_event)(struct fd *,int event);
/* get file information */
enum server_fd_type (*get_fd_type)(struct fd *fd);
+ /* get the parent (device) object */
+ struct object *(*get_parent)(struct fd *fd);
/* perform a read on the file */
int (*read)(struct fd *, struct async *, file_pos_t );
/* perform a write on the file */
@@ -109,6 +111,7 @@ extern void default_poll_event( struct fd *fd, int event );
extern void fd_queue_async( struct fd *fd, struct async *async, int type );
extern void fd_async_wake_up( struct fd *fd, int type, unsigned int status );
extern void fd_reselect_async( struct fd *fd, struct async_queue *queue );
+extern struct object *no_fd_get_parent( struct fd *fd );
extern int no_fd_read( struct fd *fd, struct async *async, file_pos_t pos );
extern int no_fd_write( struct fd *fd, struct async *async, file_pos_t pos );
extern int no_fd_flush( struct fd *fd, struct async *async );
diff --git a/server/mailslot.c b/server/mailslot.c
index 58d650cbb25..03f5308fcbf 100644
--- a/server/mailslot.c
+++ b/server/mailslot.c
@@ -101,6 +101,7 @@ static const struct fd_ops mailslot_fd_ops =
default_fd_get_poll_events, /* get_poll_events */
default_poll_event, /* poll_event */
mailslot_get_fd_type, /* get_fd_type */
+ no_fd_get_parent, /* get_parent */
no_fd_read, /* read */
no_fd_write, /* write */
no_fd_flush, /* flush */
@@ -157,6 +158,7 @@ static const struct fd_ops mail_writer_fd_ops =
default_fd_get_poll_events, /* get_poll_events */
default_poll_event, /* poll_event */
mail_writer_get_fd_type, /* get_fd_type */
+ no_fd_get_parent, /* get_parent */
no_fd_read, /* read */
no_fd_write, /* write */
no_fd_flush, /* flush */
@@ -245,6 +247,7 @@ static const struct fd_ops mailslot_device_fd_ops =
default_fd_get_poll_events, /* get_poll_events */
default_poll_event, /* poll_event */
mailslot_device_file_get_fd_type, /* get_fd_type */
+ no_fd_get_parent, /* get_parent */
no_fd_read, /* read */
no_fd_write, /* write */
no_fd_flush, /* flush */
diff --git a/server/mapping.c b/server/mapping.c
index db0debe0af5..5d0a1c402b5 100644
--- a/server/mapping.c
+++ b/server/mapping.c
@@ -180,6 +180,7 @@ static const struct fd_ops mapping_fd_ops =
default_fd_get_poll_events, /* get_poll_events */
default_poll_event, /* poll_event */
mapping_get_fd_type, /* get_fd_type */
+ no_fd_get_parent, /* get_parent */
no_fd_read, /* read */
no_fd_write, /* write */
no_fd_flush, /* flush */
diff --git a/server/named_pipe.c b/server/named_pipe.c
index b259abb8de4..7eb0905293e 100644
--- a/server/named_pipe.c
+++ b/server/named_pipe.c
@@ -180,6 +180,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_read, /* read */
pipe_end_write, /* write */
pipe_end_flush, /* flush */
@@ -222,6 +223,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_read, /* read */
pipe_end_write, /* write */
pipe_end_flush, /* flush */
@@ -297,6 +299,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 */
no_fd_read, /* read */
no_fd_write, /* write */
no_fd_flush, /* flush */
diff --git a/server/serial.c b/server/serial.c
index 4292472613a..4d112b8c6ff 100644
--- a/server/serial.c
+++ b/server/serial.c
@@ -112,6 +112,7 @@ static const struct fd_ops serial_fd_ops =
default_fd_get_poll_events, /* get_poll_events */
default_poll_event, /* poll_event */
serial_get_fd_type, /* get_fd_type */
+ no_fd_get_parent, /* get_parent */
no_fd_read, /* read */
no_fd_write, /* write */
no_fd_flush, /* flush */
diff --git a/server/sock.c b/server/sock.c
index 1a53ce4b091..9f33bc0b95c 100644
--- a/server/sock.c
+++ b/server/sock.c
@@ -164,6 +164,7 @@ static const struct fd_ops sock_fd_ops =
sock_get_poll_events, /* get_poll_events */
sock_poll_event, /* poll_event */
sock_get_fd_type, /* get_fd_type */
+ no_fd_get_parent, /* get_parent */
no_fd_read, /* read */
no_fd_write, /* write */
no_fd_flush, /* flush */
@@ -979,6 +980,7 @@ static const struct fd_ops ifchange_fd_ops =
ifchange_get_poll_events, /* get_poll_events */
ifchange_poll_event, /* poll_event */
NULL, /* get_fd_type */
+ no_fd_get_parent, /* get_parent */
no_fd_read, /* read */
no_fd_write, /* write */
no_fd_flush, /* flush */
--
2.27.0
More information about the wine-devel
mailing list