Commit 41ea5529 authored by Alexandre Julliard's avatar Alexandre Julliard

server: Add read and write requests on file objects.

parent 860091d2
......@@ -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 */
......@@ -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)
{
......
......@@ -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 */
......
......@@ -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 );
......
......@@ -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",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment