wbemprox: Implement Win32_DesktopMonitor.PixelsPerXLogicalInch.
[wine.git] / server / device.c
blobe6dc15e465e7624b65a9fe2cb41d4c2fb56f252d
1 /*
2 * Server-side device support
4 * Copyright (C) 2007 Alexandre Julliard
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #include "config.h"
22 #include "wine/port.h"
24 #include <assert.h>
25 #include <fcntl.h>
26 #include <stdio.h>
27 #include <stdlib.h>
28 #include <stdarg.h>
30 #include "ntstatus.h"
31 #define WIN32_NO_STATUS
32 #include "windef.h"
33 #include "winternl.h"
34 #include "ddk/wdm.h"
36 #include "object.h"
37 #include "file.h"
38 #include "handle.h"
39 #include "request.h"
40 #include "process.h"
42 /* IRP object */
44 struct irp_call
46 struct object obj; /* object header */
47 struct list dev_entry; /* entry in device queue */
48 struct list mgr_entry; /* entry in manager queue */
49 struct device_file *file; /* file containing this irp */
50 struct thread *thread; /* thread that queued the irp */
51 client_ptr_t user_arg; /* user arg used to identify the request */
52 struct async *async; /* pending async op */
53 unsigned int status; /* resulting status (or STATUS_PENDING) */
54 irp_params_t params; /* irp parameters */
55 data_size_t result; /* size of result (input or output depending on the type) */
56 data_size_t in_size; /* size of input data */
57 void *in_data; /* input data */
58 data_size_t out_size; /* size of output data */
59 void *out_data; /* output data */
62 static void irp_call_dump( struct object *obj, int verbose );
63 static int irp_call_signaled( struct object *obj, struct wait_queue_entry *entry );
64 static void irp_call_destroy( struct object *obj );
66 static const struct object_ops irp_call_ops =
68 sizeof(struct irp_call), /* size */
69 irp_call_dump, /* dump */
70 no_get_type, /* get_type */
71 add_queue, /* add_queue */
72 remove_queue, /* remove_queue */
73 irp_call_signaled, /* signaled */
74 no_satisfied, /* satisfied */
75 no_signal, /* signal */
76 no_get_fd, /* get_fd */
77 no_map_access, /* map_access */
78 default_get_sd, /* get_sd */
79 default_set_sd, /* set_sd */
80 no_lookup_name, /* lookup_name */
81 no_open_file, /* open_file */
82 no_close_handle, /* close_handle */
83 irp_call_destroy /* destroy */
87 /* device manager (a list of devices managed by the same client process) */
89 struct device_manager
91 struct object obj; /* object header */
92 struct list devices; /* list of devices */
93 struct list requests; /* list of pending irps across all devices */
96 static void device_manager_dump( struct object *obj, int verbose );
97 static int device_manager_signaled( struct object *obj, struct wait_queue_entry *entry );
98 static void device_manager_destroy( struct object *obj );
100 static const struct object_ops device_manager_ops =
102 sizeof(struct device_manager), /* size */
103 device_manager_dump, /* dump */
104 no_get_type, /* get_type */
105 add_queue, /* add_queue */
106 remove_queue, /* remove_queue */
107 device_manager_signaled, /* signaled */
108 no_satisfied, /* satisfied */
109 no_signal, /* signal */
110 no_get_fd, /* get_fd */
111 no_map_access, /* map_access */
112 default_get_sd, /* get_sd */
113 default_set_sd, /* set_sd */
114 no_lookup_name, /* lookup_name */
115 no_open_file, /* open_file */
116 no_close_handle, /* close_handle */
117 device_manager_destroy /* destroy */
121 /* device (a single device object) */
123 struct device
125 struct object obj; /* object header */
126 struct device_manager *manager; /* manager for this device (or NULL if deleted) */
127 char *unix_path; /* path to unix device if any */
128 client_ptr_t user_ptr; /* opaque ptr for client side */
129 struct list entry; /* entry in device manager list */
130 struct list files; /* list of open files */
133 static void device_dump( struct object *obj, int verbose );
134 static struct object_type *device_get_type( struct object *obj );
135 static void device_destroy( struct object *obj );
136 static struct object *device_open_file( struct object *obj, unsigned int access,
137 unsigned int sharing, unsigned int options );
139 static const struct object_ops device_ops =
141 sizeof(struct device), /* size */
142 device_dump, /* dump */
143 device_get_type, /* get_type */
144 no_add_queue, /* add_queue */
145 NULL, /* remove_queue */
146 NULL, /* signaled */
147 no_satisfied, /* satisfied */
148 no_signal, /* signal */
149 no_get_fd, /* get_fd */
150 default_fd_map_access, /* map_access */
151 default_get_sd, /* get_sd */
152 default_set_sd, /* set_sd */
153 no_lookup_name, /* lookup_name */
154 device_open_file, /* open_file */
155 no_close_handle, /* close_handle */
156 device_destroy /* destroy */
160 /* device file (an open file handle to a device) */
162 struct device_file
164 struct object obj; /* object header */
165 struct device *device; /* device for this file */
166 struct fd *fd; /* file descriptor for irp */
167 client_ptr_t user_ptr; /* opaque ptr for client side */
168 struct list entry; /* entry in device list */
169 struct list requests; /* list of pending irp requests */
172 static void device_file_dump( struct object *obj, int verbose );
173 static struct fd *device_file_get_fd( struct object *obj );
174 static int device_file_close_handle( struct object *obj, struct process *process, obj_handle_t handle );
175 static void device_file_destroy( struct object *obj );
176 static enum server_fd_type device_file_get_fd_type( struct fd *fd );
177 static obj_handle_t device_file_read( struct fd *fd, const async_data_t *async_data, int blocking,
178 file_pos_t pos );
179 static obj_handle_t device_file_write( struct fd *fd, const async_data_t *async_data, int blocking,
180 file_pos_t pos, data_size_t *written );
181 static obj_handle_t device_file_flush( struct fd *fd, const async_data_t *async_data, int blocking );
182 static obj_handle_t device_file_ioctl( struct fd *fd, ioctl_code_t code, const async_data_t *async_data,
183 int blocking );
185 static const struct object_ops device_file_ops =
187 sizeof(struct device_file), /* size */
188 device_file_dump, /* dump */
189 no_get_type, /* get_type */
190 add_queue, /* add_queue */
191 remove_queue, /* remove_queue */
192 default_fd_signaled, /* signaled */
193 no_satisfied, /* satisfied */
194 no_signal, /* signal */
195 device_file_get_fd, /* get_fd */
196 default_fd_map_access, /* map_access */
197 default_get_sd, /* get_sd */
198 default_set_sd, /* set_sd */
199 no_lookup_name, /* lookup_name */
200 no_open_file, /* open_file */
201 device_file_close_handle, /* close_handle */
202 device_file_destroy /* destroy */
205 static const struct fd_ops device_file_fd_ops =
207 default_fd_get_poll_events, /* get_poll_events */
208 default_poll_event, /* poll_event */
209 device_file_get_fd_type, /* get_fd_type */
210 device_file_read, /* read */
211 device_file_write, /* write */
212 device_file_flush, /* flush */
213 device_file_ioctl, /* ioctl */
214 default_fd_queue_async, /* queue_async */
215 default_fd_reselect_async, /* reselect_async */
216 default_fd_cancel_async /* cancel_async */
220 static void irp_call_dump( struct object *obj, int verbose )
222 struct irp_call *irp = (struct irp_call *)obj;
223 fprintf( stderr, "IRP call file=%p\n", irp->file );
226 static int irp_call_signaled( struct object *obj, struct wait_queue_entry *entry )
228 struct irp_call *irp = (struct irp_call *)obj;
230 return !irp->file; /* file is cleared once the irp has completed */
233 static void irp_call_destroy( struct object *obj )
235 struct irp_call *irp = (struct irp_call *)obj;
237 free( irp->in_data );
238 free( irp->out_data );
239 if (irp->async)
241 async_terminate( irp->async, STATUS_CANCELLED );
242 release_object( irp->async );
244 if (irp->file) release_object( irp->file );
245 if (irp->thread) release_object( irp->thread );
248 static struct irp_call *create_irp( struct device_file *file, const irp_params_t *params,
249 const void *in_data, data_size_t in_size, data_size_t out_size )
251 struct irp_call *irp;
253 if (!file->device->manager) /* it has been deleted */
255 set_error( STATUS_FILE_DELETED );
256 return NULL;
259 if ((irp = alloc_object( &irp_call_ops )))
261 irp->file = (struct device_file *)grab_object( file );
262 irp->async = NULL;
263 irp->params = *params;
264 irp->status = STATUS_PENDING;
265 irp->result = 0;
266 irp->in_size = in_size;
267 irp->in_data = NULL;
268 irp->out_size = out_size;
269 irp->out_data = NULL;
271 if (irp->in_size && !(irp->in_data = memdup( in_data, in_size )))
273 release_object( irp );
274 irp = NULL;
277 return irp;
280 static void set_irp_result( struct irp_call *irp, unsigned int status,
281 const void *out_data, data_size_t out_size, data_size_t result )
283 struct device_file *file = irp->file;
285 if (!file) return; /* already finished */
287 /* FIXME: handle the STATUS_PENDING case */
288 irp->status = status;
289 irp->result = result;
290 irp->out_size = min( irp->out_size, out_size );
291 if (irp->out_size && !(irp->out_data = memdup( out_data, irp->out_size )))
292 irp->out_size = 0;
293 irp->file = NULL;
294 if (irp->async)
296 if (result) status = STATUS_ALERTED;
297 async_terminate( irp->async, status );
298 release_object( irp->async );
299 irp->async = NULL;
301 wake_up( &irp->obj, 0 );
303 if (status != STATUS_ALERTED)
305 /* remove it from the device queue */
306 /* (for STATUS_ALERTED this will be done in get_irp_result) */
307 list_remove( &irp->dev_entry );
308 release_object( irp ); /* no longer on the device queue */
310 release_object( file );
314 static void device_dump( struct object *obj, int verbose )
316 struct device *device = (struct device *)obj;
318 fprintf( stderr, "Device " );
319 dump_object_name( &device->obj );
320 fputc( '\n', stderr );
323 static struct object_type *device_get_type( struct object *obj )
325 static const WCHAR name[] = {'D','e','v','i','c','e'};
326 static const struct unicode_str str = { name, sizeof(name) };
327 return get_object_type( &str );
330 static void device_destroy( struct object *obj )
332 struct device *device = (struct device *)obj;
334 assert( list_empty( &device->files ));
336 free( device->unix_path );
337 if (device->manager) list_remove( &device->entry );
340 static void add_irp_to_queue( struct device_file *file, struct irp_call *irp, struct thread *thread )
342 struct device_manager *manager = file->device->manager;
344 assert( manager );
346 grab_object( irp ); /* grab reference for queued irp */
347 irp->thread = thread ? (struct thread *)grab_object( thread ) : NULL;
348 list_add_tail( &file->requests, &irp->dev_entry );
349 list_add_tail( &manager->requests, &irp->mgr_entry );
350 if (list_head( &manager->requests ) == &irp->mgr_entry) wake_up( &manager->obj, 0 ); /* first one */
353 static struct object *device_open_file( struct object *obj, unsigned int access,
354 unsigned int sharing, unsigned int options )
356 struct device *device = (struct device *)obj;
357 struct device_file *file;
359 if (!(file = alloc_object( &device_file_ops ))) return NULL;
361 file->device = (struct device *)grab_object( device );
362 file->user_ptr = 0;
363 list_init( &file->requests );
364 list_add_tail( &device->files, &file->entry );
365 if (device->unix_path)
367 mode_t mode = 0666;
368 access = file->obj.ops->map_access( &file->obj, access );
369 file->fd = open_fd( NULL, device->unix_path, O_NONBLOCK | O_LARGEFILE,
370 &mode, access, sharing, options );
371 if (file->fd) set_fd_user( file->fd, &device_file_fd_ops, &file->obj );
373 else file->fd = alloc_pseudo_fd( &device_file_fd_ops, &file->obj, 0 );
375 if (!file->fd)
377 release_object( file );
378 return NULL;
381 if (device->manager)
383 struct irp_call *irp;
384 irp_params_t params;
386 params.create.major = IRP_MJ_CREATE;
387 params.create.access = access;
388 params.create.sharing = sharing;
389 params.create.options = options;
390 params.create.device = file->device->user_ptr;
392 if ((irp = create_irp( file, &params, NULL, 0, 0 )))
394 add_irp_to_queue( file, irp, NULL );
395 release_object( irp );
398 return &file->obj;
401 static void device_file_dump( struct object *obj, int verbose )
403 struct device_file *file = (struct device_file *)obj;
405 fprintf( stderr, "File on device %p\n", file->device );
408 static struct fd *device_file_get_fd( struct object *obj )
410 struct device_file *file = (struct device_file *)obj;
412 return (struct fd *)grab_object( file->fd );
415 static int device_file_close_handle( struct object *obj, struct process *process, obj_handle_t handle )
417 struct device_file *file = (struct device_file *)obj;
419 if (file->device->manager && obj->handle_count == 1) /* last handle */
421 struct irp_call *irp;
422 irp_params_t params;
424 params.close.major = IRP_MJ_CLOSE;
425 params.close.file = file->user_ptr;
427 if ((irp = create_irp( file, &params, NULL, 0, 0 )))
429 add_irp_to_queue( file, irp, NULL );
430 release_object( irp );
433 return 1;
436 static void device_file_destroy( struct object *obj )
438 struct device_file *file = (struct device_file *)obj;
439 struct irp_call *irp, *next;
441 LIST_FOR_EACH_ENTRY_SAFE( irp, next, &file->requests, struct irp_call, dev_entry )
443 list_remove( &irp->dev_entry );
444 release_object( irp ); /* no longer on the device queue */
446 if (file->fd) release_object( file->fd );
447 list_remove( &file->entry );
448 release_object( file->device );
451 static struct irp_call *find_irp_call( struct device_file *file, struct thread *thread,
452 client_ptr_t user_arg )
454 struct irp_call *irp;
456 LIST_FOR_EACH_ENTRY( irp, &file->requests, struct irp_call, dev_entry )
457 if (irp->thread == thread && irp->user_arg == user_arg) return irp;
459 set_error( STATUS_INVALID_PARAMETER );
460 return NULL;
463 static void set_file_user_ptr( struct device_file *file, client_ptr_t ptr )
465 struct irp_call *irp;
467 if (file->user_ptr == ptr) return; /* nothing to do */
469 file->user_ptr = ptr;
471 /* update already queued irps */
473 LIST_FOR_EACH_ENTRY( irp, &file->requests, struct irp_call, dev_entry )
475 switch (irp->params.major)
477 case IRP_MJ_CLOSE: irp->params.close.file = ptr; break;
478 case IRP_MJ_READ: irp->params.read.file = ptr; break;
479 case IRP_MJ_WRITE: irp->params.write.file = ptr; break;
480 case IRP_MJ_FLUSH_BUFFERS: irp->params.flush.file = ptr; break;
481 case IRP_MJ_DEVICE_CONTROL: irp->params.ioctl.file = ptr; break;
486 /* queue an irp to the device */
487 static obj_handle_t queue_irp( struct device_file *file, struct irp_call *irp,
488 const async_data_t *async_data, int blocking )
490 obj_handle_t handle = 0;
492 if (blocking && !(handle = alloc_handle( current->process, irp, SYNCHRONIZE, 0 ))) return 0;
494 if (!(irp->async = fd_queue_async( file->fd, async_data, ASYNC_TYPE_WAIT )))
496 if (handle) close_handle( current->process, handle );
497 return 0;
499 irp->user_arg = async_data->arg;
500 add_irp_to_queue( file, irp, current );
501 set_error( STATUS_PENDING );
502 return handle;
505 static enum server_fd_type device_file_get_fd_type( struct fd *fd )
507 return FD_TYPE_DEVICE;
510 static obj_handle_t device_file_read( struct fd *fd, const async_data_t *async_data, int blocking,
511 file_pos_t pos )
513 struct device_file *file = get_fd_user( fd );
514 struct irp_call *irp;
515 obj_handle_t handle;
516 irp_params_t params;
518 params.read.major = IRP_MJ_READ;
519 params.read.key = 0;
520 params.read.pos = pos;
521 params.read.file = file->user_ptr;
523 irp = create_irp( file, &params, NULL, 0, get_reply_max_size() );
524 if (!irp) return 0;
526 handle = queue_irp( file, irp, async_data, blocking );
527 release_object( irp );
528 return handle;
531 static obj_handle_t device_file_write( struct fd *fd, const async_data_t *async_data, int blocking,
532 file_pos_t pos, data_size_t *written )
534 struct device_file *file = get_fd_user( fd );
535 struct irp_call *irp;
536 obj_handle_t handle;
537 irp_params_t params;
539 params.write.major = IRP_MJ_WRITE;
540 params.write.key = 0;
541 params.write.pos = pos;
542 params.write.file = file->user_ptr;
544 irp = create_irp( file, &params, get_req_data(), get_req_data_size(), 0 );
545 if (!irp) return 0;
547 handle = queue_irp( file, irp, async_data, blocking );
548 release_object( irp );
549 return handle;
552 static obj_handle_t device_file_flush( struct fd *fd, const async_data_t *async_data, int blocking )
554 struct device_file *file = get_fd_user( fd );
555 struct irp_call *irp;
556 obj_handle_t handle;
557 irp_params_t params;
559 params.flush.major = IRP_MJ_FLUSH_BUFFERS;
560 params.flush.file = file->user_ptr;
562 irp = create_irp( file, &params, NULL, 0, 0 );
563 if (!irp) return 0;
565 handle = queue_irp( file, irp, async_data, blocking );
566 release_object( irp );
567 return handle;
570 static obj_handle_t device_file_ioctl( struct fd *fd, ioctl_code_t code, const async_data_t *async_data,
571 int blocking )
573 struct device_file *file = get_fd_user( fd );
574 struct irp_call *irp;
575 obj_handle_t handle;
576 irp_params_t params;
578 params.ioctl.major = IRP_MJ_DEVICE_CONTROL;
579 params.ioctl.code = code;
580 params.ioctl.file = file->user_ptr;
582 irp = create_irp( file, &params, get_req_data(), get_req_data_size(),
583 get_reply_max_size() );
584 if (!irp) return 0;
586 handle = queue_irp( file, irp, async_data, blocking );
587 release_object( irp );
588 return handle;
591 static struct device *create_device( struct directory *root, const struct unicode_str *name,
592 struct device_manager *manager, unsigned int attr )
594 struct device *device;
596 if ((device = create_named_object_dir( root, name, attr, &device_ops )))
598 if (get_error() != STATUS_OBJECT_NAME_EXISTS)
600 /* initialize it if it didn't already exist */
601 device->unix_path = NULL;
602 device->manager = manager;
603 list_add_tail( &manager->devices, &device->entry );
604 list_init( &device->files );
607 return device;
610 struct device *create_unix_device( struct directory *root, const struct unicode_str *name,
611 const char *unix_path )
613 struct device *device;
615 if ((device = create_named_object_dir( root, name, 0, &device_ops )))
617 device->unix_path = strdup( unix_path );
618 device->manager = NULL; /* no manager, requests go straight to the Unix device */
619 list_init( &device->files );
620 make_object_static( &device->obj );
622 return device;
626 /* terminate requests when the underlying device is deleted */
627 static void delete_file( struct device_file *file )
629 struct irp_call *irp, *next;
631 /* terminate all pending requests */
632 LIST_FOR_EACH_ENTRY_SAFE( irp, next, &file->requests, struct irp_call, dev_entry )
634 list_remove( &irp->mgr_entry );
635 set_irp_result( irp, STATUS_FILE_DELETED, NULL, 0, 0 );
639 static void delete_device( struct device *device )
641 struct device_file *file, *next;
643 if (!device->manager) return; /* already deleted */
645 LIST_FOR_EACH_ENTRY_SAFE( file, next, &device->files, struct device_file, entry )
646 delete_file( file );
648 unlink_named_object( &device->obj );
649 list_remove( &device->entry );
650 device->manager = NULL;
654 static void device_manager_dump( struct object *obj, int verbose )
656 fprintf( stderr, "Device manager\n" );
659 static int device_manager_signaled( struct object *obj, struct wait_queue_entry *entry )
661 struct device_manager *manager = (struct device_manager *)obj;
663 return !list_empty( &manager->requests );
666 static void device_manager_destroy( struct object *obj )
668 struct device_manager *manager = (struct device_manager *)obj;
669 struct list *ptr;
671 while ((ptr = list_head( &manager->devices )))
673 struct device *device = LIST_ENTRY( ptr, struct device, entry );
674 delete_device( device );
678 static struct device_manager *create_device_manager(void)
680 struct device_manager *manager;
682 if ((manager = alloc_object( &device_manager_ops )))
684 list_init( &manager->devices );
685 list_init( &manager->requests );
687 return manager;
691 /* create a device manager */
692 DECL_HANDLER(create_device_manager)
694 struct device_manager *manager = create_device_manager();
696 if (manager)
698 reply->handle = alloc_handle( current->process, manager, req->access, req->attributes );
699 release_object( manager );
704 /* create a device */
705 DECL_HANDLER(create_device)
707 struct device *device;
708 struct unicode_str name;
709 struct device_manager *manager;
710 struct directory *root = NULL;
712 if (!(manager = (struct device_manager *)get_handle_obj( current->process, req->manager,
713 0, &device_manager_ops )))
714 return;
716 get_req_unicode_str( &name );
717 if (req->rootdir && !(root = get_directory_obj( current->process, req->rootdir, 0 )))
719 release_object( manager );
720 return;
723 if ((device = create_device( root, &name, manager, req->attributes )))
725 device->user_ptr = req->user_ptr;
726 reply->handle = alloc_handle( current->process, device, req->access, req->attributes );
727 release_object( device );
730 if (root) release_object( root );
731 release_object( manager );
735 /* delete a device */
736 DECL_HANDLER(delete_device)
738 struct device *device;
740 if ((device = (struct device *)get_handle_obj( current->process, req->handle, 0, &device_ops )))
742 delete_device( device );
743 release_object( device );
748 /* retrieve the next pending device irp request */
749 DECL_HANDLER(get_next_device_request)
751 struct irp_call *irp;
752 struct device_manager *manager;
753 struct list *ptr;
755 reply->params.major = IRP_MJ_MAXIMUM_FUNCTION + 1;
757 if (!(manager = (struct device_manager *)get_handle_obj( current->process, req->manager,
758 0, &device_manager_ops )))
759 return;
761 if (req->prev)
763 if ((irp = (struct irp_call *)get_handle_obj( current->process, req->prev, 0, &irp_call_ops )))
765 set_irp_result( irp, req->status, NULL, 0, 0 );
766 close_handle( current->process, req->prev ); /* avoid an extra round-trip for close */
767 release_object( irp );
769 clear_error();
772 if ((ptr = list_head( &manager->requests )))
774 irp = LIST_ENTRY( ptr, struct irp_call, mgr_entry );
775 if (irp->thread)
777 reply->client_pid = get_process_id( irp->thread->process );
778 reply->client_tid = get_thread_id( irp->thread );
780 reply->params = irp->params;
781 reply->in_size = irp->in_size;
782 reply->out_size = irp->out_size;
783 if (irp->in_size > get_reply_max_size()) set_error( STATUS_BUFFER_OVERFLOW );
784 else if ((reply->next = alloc_handle( current->process, irp, 0, 0 )))
786 set_reply_data_ptr( irp->in_data, irp->in_size );
787 irp->in_data = NULL;
788 irp->in_size = 0;
789 list_remove( &irp->mgr_entry );
790 list_init( &irp->mgr_entry );
793 else set_error( STATUS_PENDING );
795 release_object( manager );
799 /* store results of an async irp */
800 DECL_HANDLER(set_irp_result)
802 struct irp_call *irp;
803 struct device_manager *manager;
805 if (!(manager = (struct device_manager *)get_handle_obj( current->process, req->manager,
806 0, &device_manager_ops )))
807 return;
809 if ((irp = (struct irp_call *)get_handle_obj( current->process, req->handle, 0, &irp_call_ops )))
811 if (irp->file) set_file_user_ptr( irp->file, req->file_ptr );
812 set_irp_result( irp, req->status, get_req_data(), get_req_data_size(), req->size );
813 close_handle( current->process, req->handle ); /* avoid an extra round-trip for close */
814 release_object( irp );
816 release_object( manager );
820 /* retrieve results of an async irp */
821 DECL_HANDLER(get_irp_result)
823 struct device_file *file;
824 struct irp_call *irp;
826 if (!(file = (struct device_file *)get_handle_obj( current->process, req->handle,
827 0, &device_file_ops )))
828 return;
830 if ((irp = find_irp_call( file, current, req->user_arg )))
832 if (irp->out_data)
834 data_size_t size = min( irp->out_size, get_reply_max_size() );
835 if (size)
837 set_reply_data_ptr( irp->out_data, size );
838 irp->out_data = NULL;
841 reply->size = irp->result;
842 set_error( irp->status );
843 list_remove( &irp->dev_entry );
844 release_object( irp ); /* no longer on the device queue */
846 release_object( file );