Module: wine Branch: master Commit: 41ea55294ed4d5735fd2e2c7be6510d85af11229 URL: http://source.winehq.org/git/wine.git/?a=commit;h=41ea55294ed4d5735fd2e2c7be...
Author: Alexandre Julliard julliard@winehq.org Date: Tue May 5 12:50:51 2015 +0900
server: Add read and write requests on file objects.
---
include/wine/server_protocol.h | 44 +++++++++++++++++++++++++++++++++++++++++- server/fd.c | 26 +++++++++++++++++++++++++ server/protocol.def | 25 ++++++++++++++++++++++++ server/request.h | 19 ++++++++++++++++++ server/trace.c | 35 +++++++++++++++++++++++++++++++++ 5 files changed, 148 insertions(+), 1 deletion(-)
diff --git a/include/wine/server_protocol.h b/include/wine/server_protocol.h index fabd3b4..b838f0b 100644 --- a/include/wine/server_protocol.h +++ b/include/wine/server_protocol.h @@ -3110,6 +3110,42 @@ struct cancel_async_reply
+struct read_request +{ + struct request_header __header; + int blocking; + async_data_t async; + file_pos_t pos; +}; +struct read_reply +{ + struct reply_header __header; + obj_handle_t wait; + unsigned int options; + /* VARARG(data,bytes); */ +}; + + + +struct write_request +{ + struct request_header __header; + int blocking; + async_data_t async; + file_pos_t pos; + /* VARARG(data,bytes); */ +}; +struct write_reply +{ + struct reply_header __header; + obj_handle_t wait; + unsigned int options; + data_size_t size; + char __pad_20[4]; +}; + + + struct ioctl_request { struct request_header __header; @@ -5319,6 +5355,8 @@ enum request REQ_set_serial_info, REQ_register_async, REQ_cancel_async, + REQ_read, + REQ_write, REQ_ioctl, REQ_set_irp_result, REQ_get_irp_result, @@ -5588,6 +5626,8 @@ union generic_request struct set_serial_info_request set_serial_info_request; struct register_async_request register_async_request; struct cancel_async_request cancel_async_request; + struct read_request read_request; + struct write_request write_request; struct ioctl_request ioctl_request; struct set_irp_result_request set_irp_result_request; struct get_irp_result_request get_irp_result_request; @@ -5855,6 +5895,8 @@ union generic_reply struct set_serial_info_reply set_serial_info_reply; struct register_async_reply register_async_reply; struct cancel_async_reply cancel_async_reply; + struct read_reply read_reply; + struct write_reply write_reply; struct ioctl_reply ioctl_reply; struct set_irp_result_reply set_irp_result_reply; struct get_irp_result_reply get_irp_result_reply; @@ -5978,6 +6020,6 @@ union generic_reply struct terminate_job_reply terminate_job_reply; };
-#define SERVER_PROTOCOL_VERSION 472 +#define SERVER_PROTOCOL_VERSION 473
#endif /* __WINE_WINE_SERVER_PROTOCOL_H */ diff --git a/server/fd.c b/server/fd.c index c5340ff..e7f151a 100644 --- a/server/fd.c +++ b/server/fd.c @@ -2303,6 +2303,32 @@ DECL_HANDLER(get_handle_fd) } }
+/* perform a read on a file object */ +DECL_HANDLER(read) +{ + struct fd *fd = get_handle_fd_obj( current->process, req->async.handle, FILE_READ_DATA ); + + if (fd) + { + reply->wait = fd->fd_ops->read( fd, &req->async, req->blocking, req->pos ); + reply->options = fd->options; + release_object( fd ); + } +} + +/* perform a write on a file object */ +DECL_HANDLER(write) +{ + struct fd *fd = get_handle_fd_obj( current->process, req->async.handle, FILE_WRITE_DATA ); + + if (fd) + { + reply->wait = fd->fd_ops->write( fd, &req->async, req->blocking, req->pos, &reply->size ); + reply->options = fd->options; + release_object( fd ); + } +} + /* perform an ioctl on a file */ DECL_HANDLER(ioctl) { diff --git a/server/protocol.def b/server/protocol.def index 3c03977..b2c417d 100644 --- a/server/protocol.def +++ b/server/protocol.def @@ -2250,6 +2250,31 @@ enum message_type @END
+/* Perform a read on a file object */ +@REQ(read) + int blocking; /* whether it's a blocking read */ + async_data_t async; /* async I/O parameters */ + file_pos_t pos; /* read position */ +@REPLY + obj_handle_t wait; /* handle to wait on for blocking read */ + unsigned int options; /* device open options */ + VARARG(data,bytes); /* read data */ +@END + + +/* Perform a write on a file object */ +@REQ(write) + int blocking; /* whether it's a blocking write */ + async_data_t async; /* async I/O parameters */ + file_pos_t pos; /* write position */ + VARARG(data,bytes); /* write data */ +@REPLY + obj_handle_t wait; /* handle to wait on for blocking write */ + unsigned int options; /* device open options */ + data_size_t size; /* size written */ +@END + + /* Perform an ioctl on a file */ @REQ(ioctl) ioctl_code_t code; /* ioctl code */ diff --git a/server/request.h b/server/request.h index 9ed815e..6d43e9f 100644 --- a/server/request.h +++ b/server/request.h @@ -247,6 +247,8 @@ DECL_HANDLER(get_serial_info); DECL_HANDLER(set_serial_info); DECL_HANDLER(register_async); DECL_HANDLER(cancel_async); +DECL_HANDLER(read); +DECL_HANDLER(write); DECL_HANDLER(ioctl); DECL_HANDLER(set_irp_result); DECL_HANDLER(get_irp_result); @@ -515,6 +517,8 @@ static const req_handler req_handlers[REQ_NB_REQUESTS] = (req_handler)req_set_serial_info, (req_handler)req_register_async, (req_handler)req_cancel_async, + (req_handler)req_read, + (req_handler)req_write, (req_handler)req_ioctl, (req_handler)req_set_irp_result, (req_handler)req_get_irp_result, @@ -1521,6 +1525,21 @@ C_ASSERT( FIELD_OFFSET(struct cancel_async_request, handle) == 12 ); C_ASSERT( FIELD_OFFSET(struct cancel_async_request, iosb) == 16 ); C_ASSERT( FIELD_OFFSET(struct cancel_async_request, only_thread) == 24 ); C_ASSERT( sizeof(struct cancel_async_request) == 32 ); +C_ASSERT( FIELD_OFFSET(struct read_request, blocking) == 12 ); +C_ASSERT( FIELD_OFFSET(struct read_request, async) == 16 ); +C_ASSERT( FIELD_OFFSET(struct read_request, pos) == 56 ); +C_ASSERT( sizeof(struct read_request) == 64 ); +C_ASSERT( FIELD_OFFSET(struct read_reply, wait) == 8 ); +C_ASSERT( FIELD_OFFSET(struct read_reply, options) == 12 ); +C_ASSERT( sizeof(struct read_reply) == 16 ); +C_ASSERT( FIELD_OFFSET(struct write_request, blocking) == 12 ); +C_ASSERT( FIELD_OFFSET(struct write_request, async) == 16 ); +C_ASSERT( FIELD_OFFSET(struct write_request, pos) == 56 ); +C_ASSERT( sizeof(struct write_request) == 64 ); +C_ASSERT( FIELD_OFFSET(struct write_reply, wait) == 8 ); +C_ASSERT( FIELD_OFFSET(struct write_reply, options) == 12 ); +C_ASSERT( FIELD_OFFSET(struct write_reply, size) == 16 ); +C_ASSERT( sizeof(struct write_reply) == 24 ); C_ASSERT( FIELD_OFFSET(struct ioctl_request, code) == 12 ); C_ASSERT( FIELD_OFFSET(struct ioctl_request, async) == 16 ); C_ASSERT( FIELD_OFFSET(struct ioctl_request, blocking) == 56 ); diff --git a/server/trace.c b/server/trace.c index 8d888d3..e8d19de 100644 --- a/server/trace.c +++ b/server/trace.c @@ -2726,6 +2726,35 @@ static void dump_cancel_async_request( const struct cancel_async_request *req ) fprintf( stderr, ", only_thread=%d", req->only_thread ); }
+static void dump_read_request( const struct read_request *req ) +{ + fprintf( stderr, " blocking=%d", req->blocking ); + dump_async_data( ", async=", &req->async ); + dump_uint64( ", pos=", &req->pos ); +} + +static void dump_read_reply( const struct read_reply *req ) +{ + fprintf( stderr, " wait=%04x", req->wait ); + fprintf( stderr, ", options=%08x", req->options ); + dump_varargs_bytes( ", data=", cur_size ); +} + +static void dump_write_request( const struct write_request *req ) +{ + fprintf( stderr, " blocking=%d", req->blocking ); + dump_async_data( ", async=", &req->async ); + dump_uint64( ", pos=", &req->pos ); + dump_varargs_bytes( ", data=", cur_size ); +} + +static void dump_write_reply( const struct write_reply *req ) +{ + fprintf( stderr, " wait=%04x", req->wait ); + fprintf( stderr, ", options=%08x", req->options ); + fprintf( stderr, ", size=%u", req->size ); +} + static void dump_ioctl_request( const struct ioctl_request *req ) { dump_ioctl_code( " code=", &req->code ); @@ -4292,6 +4321,8 @@ static const dump_func req_dumpers[REQ_NB_REQUESTS] = { (dump_func)dump_set_serial_info_request, (dump_func)dump_register_async_request, (dump_func)dump_cancel_async_request, + (dump_func)dump_read_request, + (dump_func)dump_write_request, (dump_func)dump_ioctl_request, (dump_func)dump_set_irp_result_request, (dump_func)dump_get_irp_result_request, @@ -4557,6 +4588,8 @@ static const dump_func reply_dumpers[REQ_NB_REQUESTS] = { NULL, NULL, NULL, + (dump_func)dump_read_reply, + (dump_func)dump_write_reply, (dump_func)dump_ioctl_reply, NULL, (dump_func)dump_get_irp_result_reply, @@ -4822,6 +4855,8 @@ static const char * const req_names[REQ_NB_REQUESTS] = { "set_serial_info", "register_async", "cancel_async", + "read", + "write", "ioctl", "set_irp_result", "get_irp_result",