msado15: Implement Dispatch functions in _Connection.
[wine.git] / server / console.c
blob92bda51846c628c5618834819ba42e7532b00a6a
1 /*
2 * Server-side console management
4 * Copyright (C) 1998 Alexandre Julliard
5 * 2001 Eric Pouech
6 * Copyright 2020 Jacek Caban for CodeWeavers
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or (at your option) any later version.
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this library; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
24 #include "config.h"
25 #include "wine/port.h"
27 #include <assert.h>
28 #include <string.h>
29 #include <stdio.h>
30 #include <unistd.h>
31 #include <signal.h>
32 #include <sys/ioctl.h>
33 #include <termios.h>
35 #include "ntstatus.h"
36 #define WIN32_NO_STATUS
37 #include "handle.h"
38 #include "process.h"
39 #include "request.h"
40 #include "file.h"
41 #include "unicode.h"
42 #include "wincon.h"
43 #include "winternl.h"
44 #include "wine/condrv.h"
46 struct screen_buffer;
48 struct history_line
50 data_size_t len;
51 WCHAR text[1];
54 struct console
56 struct object obj; /* object header */
57 int signaled; /* is console signaled */
58 struct thread *renderer; /* console renderer thread */
59 struct screen_buffer *active; /* active screen buffer */
60 struct console_server *server; /* console server object */
61 unsigned int last_id; /* id of last created console buffer */
62 struct fd *fd; /* for bare console, attached input fd */
63 struct async_queue ioctl_q; /* ioctl queue */
64 struct async_queue read_q; /* read queue */
67 static void console_dump( struct object *obj, int verbose );
68 static void console_destroy( struct object *obj );
69 static int console_signaled( struct object *obj, struct wait_queue_entry *entry );
70 static struct fd *console_get_fd( struct object *obj );
71 static struct object *console_lookup_name( struct object *obj, struct unicode_str *name,
72 unsigned int attr, struct object *root );
73 static struct object *console_open_file( struct object *obj, unsigned int access,
74 unsigned int sharing, unsigned int options );
76 static const struct object_ops console_ops =
78 sizeof(struct console), /* size */
79 &file_type, /* type */
80 console_dump, /* dump */
81 add_queue, /* add_queue */
82 remove_queue, /* remove_queue */
83 console_signaled, /* signaled */
84 no_satisfied, /* satisfied */
85 no_signal, /* signal */
86 console_get_fd, /* get_fd */
87 default_map_access, /* map_access */
88 default_get_sd, /* get_sd */
89 default_set_sd, /* set_sd */
90 no_get_full_name, /* get_full_name */
91 console_lookup_name, /* lookup_name */
92 no_link_name, /* link_name */
93 NULL, /* unlink_name */
94 console_open_file, /* open_file */
95 no_kernel_obj_list, /* get_kernel_obj_list */
96 no_close_handle, /* close_handle */
97 console_destroy /* destroy */
100 static enum server_fd_type console_get_fd_type( struct fd *fd );
101 static void console_get_file_info( struct fd *fd, obj_handle_t handle, unsigned int info_class );
102 static int console_get_volume_info( struct fd *fd, struct async *async, unsigned int info_class );
103 static int console_read( struct fd *fd, struct async *async, file_pos_t pos );
104 static int console_flush( struct fd *fd, struct async *async );
105 static int console_ioctl( struct fd *fd, ioctl_code_t code, struct async *async );
107 static const struct fd_ops console_fd_ops =
109 default_fd_get_poll_events, /* get_poll_events */
110 default_poll_event, /* poll_event */
111 console_get_fd_type, /* get_fd_type */
112 console_read, /* read */
113 no_fd_write, /* write */
114 console_flush, /* flush */
115 console_get_file_info, /* get_file_info */
116 console_get_volume_info, /* get_volume_info */
117 console_ioctl, /* ioctl */
118 default_fd_queue_async, /* queue_async */
119 default_fd_reselect_async /* reselect_async */
122 struct console_host_ioctl
124 unsigned int code; /* ioctl code */
125 int output; /* output id for screen buffer ioctls */
126 struct async *async; /* ioctl async */
127 struct list entry; /* list entry */
130 struct console_server
132 struct object obj; /* object header */
133 struct fd *fd; /* pseudo-fd for ioctls */
134 struct console *console; /* attached console */
135 struct list queue; /* ioctl queue */
136 struct list read_queue; /* blocking read queue */
137 int busy; /* flag if server processing an ioctl */
138 int term_fd; /* UNIX terminal fd */
139 struct termios termios; /* original termios */
142 static void console_server_dump( struct object *obj, int verbose );
143 static void console_server_destroy( struct object *obj );
144 static int console_server_signaled( struct object *obj, struct wait_queue_entry *entry );
145 static struct fd *console_server_get_fd( struct object *obj );
146 static struct object *console_server_lookup_name( struct object *obj, struct unicode_str *name,
147 unsigned int attr, struct object *root );
148 static struct object *console_server_open_file( struct object *obj, unsigned int access,
149 unsigned int sharing, unsigned int options );
151 static const struct object_ops console_server_ops =
153 sizeof(struct console_server), /* size */
154 &file_type, /* type */
155 console_server_dump, /* dump */
156 add_queue, /* add_queue */
157 remove_queue, /* remove_queue */
158 console_server_signaled, /* signaled */
159 no_satisfied, /* satisfied */
160 no_signal, /* signal */
161 console_server_get_fd, /* get_fd */
162 default_map_access, /* map_access */
163 default_get_sd, /* get_sd */
164 default_set_sd, /* set_sd */
165 no_get_full_name, /* get_full_name */
166 console_server_lookup_name, /* lookup_name */
167 no_link_name, /* link_name */
168 NULL, /* unlink_name */
169 console_server_open_file, /* open_file */
170 no_kernel_obj_list, /* get_kernel_obj_list */
171 fd_close_handle, /* close_handle */
172 console_server_destroy /* destroy */
175 static int console_server_ioctl( struct fd *fd, ioctl_code_t code, struct async *async );
177 static const struct fd_ops console_server_fd_ops =
179 default_fd_get_poll_events, /* get_poll_events */
180 default_poll_event, /* poll_event */
181 console_get_fd_type, /* get_fd_type */
182 no_fd_read, /* read */
183 no_fd_write, /* write */
184 no_fd_flush, /* flush */
185 no_fd_get_file_info, /* get_file_info */
186 no_fd_get_volume_info, /* get_volume_info */
187 console_server_ioctl, /* ioctl */
188 default_fd_queue_async, /* queue_async */
189 default_fd_reselect_async /* reselect_async */
192 struct font_info
194 short int width;
195 short int height;
196 short int weight;
197 short int pitch_family;
198 WCHAR *face_name;
199 data_size_t face_len;
202 struct screen_buffer
204 struct object obj; /* object header */
205 struct list entry; /* entry in list of all screen buffers */
206 struct console *input; /* associated console input */
207 unsigned int id; /* buffer id */
208 struct fd *fd; /* for bare console, attached output fd */
209 struct async_queue ioctl_q; /* ioctl queue */
212 static void screen_buffer_dump( struct object *obj, int verbose );
213 static void screen_buffer_destroy( struct object *obj );
214 static int screen_buffer_add_queue( struct object *obj, struct wait_queue_entry *entry );
215 static struct fd *screen_buffer_get_fd( struct object *obj );
216 static struct object *screen_buffer_open_file( struct object *obj, unsigned int access,
217 unsigned int sharing, unsigned int options );
219 static const struct object_ops screen_buffer_ops =
221 sizeof(struct screen_buffer), /* size */
222 &file_type, /* type */
223 screen_buffer_dump, /* dump */
224 screen_buffer_add_queue, /* add_queue */
225 NULL, /* remove_queue */
226 NULL, /* signaled */
227 NULL, /* satisfied */
228 no_signal, /* signal */
229 screen_buffer_get_fd, /* get_fd */
230 default_map_access, /* map_access */
231 default_get_sd, /* get_sd */
232 default_set_sd, /* set_sd */
233 no_get_full_name, /* get_full_name */
234 no_lookup_name, /* lookup_name */
235 no_link_name, /* link_name */
236 NULL, /* unlink_name */
237 screen_buffer_open_file, /* open_file */
238 no_kernel_obj_list, /* get_kernel_obj_list */
239 no_close_handle, /* close_handle */
240 screen_buffer_destroy /* destroy */
243 static int screen_buffer_write( struct fd *fd, struct async *async, file_pos_t pos );
244 static int screen_buffer_ioctl( struct fd *fd, ioctl_code_t code, struct async *async );
246 static const struct fd_ops screen_buffer_fd_ops =
248 default_fd_get_poll_events, /* get_poll_events */
249 default_poll_event, /* poll_event */
250 console_get_fd_type, /* get_fd_type */
251 no_fd_read, /* read */
252 screen_buffer_write, /* write */
253 no_fd_flush, /* flush */
254 console_get_file_info, /* get_file_info */
255 console_get_volume_info, /* get_volume_info */
256 screen_buffer_ioctl, /* ioctl */
257 default_fd_queue_async, /* queue_async */
258 default_fd_reselect_async /* reselect_async */
261 static void console_device_dump( struct object *obj, int verbose );
262 static struct object *console_device_lookup_name( struct object *obj, struct unicode_str *name,
263 unsigned int attr, struct object *root );
264 static struct object *console_device_open_file( struct object *obj, unsigned int access,
265 unsigned int sharing, unsigned int options );
267 static const struct object_ops console_device_ops =
269 sizeof(struct object), /* size */
270 &device_type, /* type */
271 console_device_dump, /* dump */
272 no_add_queue, /* add_queue */
273 NULL, /* remove_queue */
274 NULL, /* signaled */
275 no_satisfied, /* satisfied */
276 no_signal, /* signal */
277 no_get_fd, /* get_fd */
278 default_map_access, /* map_access */
279 default_get_sd, /* get_sd */
280 default_set_sd, /* set_sd */
281 default_get_full_name, /* get_full_name */
282 console_device_lookup_name, /* lookup_name */
283 directory_link_name, /* link_name */
284 default_unlink_name, /* unlink_name */
285 console_device_open_file, /* open_file */
286 no_kernel_obj_list, /* get_kernel_obj_list */
287 no_close_handle, /* close_handle */
288 no_destroy /* destroy */
291 struct console_input
293 struct object obj; /* object header */
294 struct fd *fd; /* pseudo-fd */
297 static void console_input_dump( struct object *obj, int verbose );
298 static struct object *console_input_open_file( struct object *obj, unsigned int access,
299 unsigned int sharing, unsigned int options );
300 static int console_input_add_queue( struct object *obj, struct wait_queue_entry *entry );
301 static struct fd *console_input_get_fd( struct object *obj );
302 static void console_input_destroy( struct object *obj );
304 static const struct object_ops console_input_ops =
306 sizeof(struct console_input), /* size */
307 &device_type, /* type */
308 console_input_dump, /* dump */
309 console_input_add_queue, /* add_queue */
310 NULL, /* remove_queue */
311 NULL, /* signaled */
312 no_satisfied, /* satisfied */
313 no_signal, /* signal */
314 console_input_get_fd, /* get_fd */
315 default_map_access, /* map_access */
316 default_get_sd, /* get_sd */
317 default_set_sd, /* set_sd */
318 no_get_full_name, /* get_full_name */
319 no_lookup_name, /* lookup_name */
320 directory_link_name, /* link_name */
321 default_unlink_name, /* unlink_name */
322 console_input_open_file, /* open_file */
323 no_kernel_obj_list, /* get_kernel_obj_list */
324 no_close_handle, /* close_handle */
325 console_input_destroy /* destroy */
328 static int console_input_read( struct fd *fd, struct async *async, file_pos_t pos );
329 static int console_input_flush( struct fd *fd, struct async *async );
330 static int console_input_ioctl( struct fd *fd, ioctl_code_t code, struct async *async );
332 static const struct fd_ops console_input_fd_ops =
334 default_fd_get_poll_events, /* get_poll_events */
335 default_poll_event, /* poll_event */
336 console_get_fd_type, /* get_fd_type */
337 console_input_read, /* read */
338 no_fd_write, /* write */
339 console_input_flush, /* flush */
340 console_get_file_info, /* get_file_info */
341 console_get_volume_info, /* get_volume_info */
342 console_input_ioctl, /* ioctl */
343 default_fd_queue_async, /* queue_async */
344 default_fd_reselect_async /* reselect_async */
347 struct console_output
349 struct object obj; /* object header */
350 struct fd *fd; /* pseudo-fd */
353 static void console_output_dump( struct object *obj, int verbose );
354 static int console_output_add_queue( struct object *obj, struct wait_queue_entry *entry );
355 static struct fd *console_output_get_fd( struct object *obj );
356 static struct object *console_output_open_file( struct object *obj, unsigned int access,
357 unsigned int sharing, unsigned int options );
358 static void console_output_destroy( struct object *obj );
360 static const struct object_ops console_output_ops =
362 sizeof(struct console_output), /* size */
363 &device_type, /* type */
364 console_output_dump, /* dump */
365 console_output_add_queue, /* add_queue */
366 NULL, /* remove_queue */
367 NULL, /* signaled */
368 no_satisfied, /* satisfied */
369 no_signal, /* signal */
370 console_output_get_fd, /* get_fd */
371 default_map_access, /* map_access */
372 default_get_sd, /* get_sd */
373 default_set_sd, /* set_sd */
374 no_get_full_name, /* get_full_name */
375 no_lookup_name, /* lookup_name */
376 directory_link_name, /* link_name */
377 default_unlink_name, /* unlink_name */
378 console_output_open_file, /* open_file */
379 no_kernel_obj_list, /* get_kernel_obj_list */
380 no_close_handle, /* close_handle */
381 console_output_destroy /* destroy */
384 static int console_output_write( struct fd *fd, struct async *async, file_pos_t pos );
385 static int console_output_ioctl( struct fd *fd, ioctl_code_t code, struct async *async );
387 static const struct fd_ops console_output_fd_ops =
389 default_fd_get_poll_events, /* get_poll_events */
390 default_poll_event, /* poll_event */
391 console_get_fd_type, /* get_fd_type */
392 no_fd_read, /* read */
393 console_output_write, /* write */
394 no_fd_flush, /* flush */
395 console_get_file_info, /* get_file_info */
396 console_get_volume_info, /* get_volume_info */
397 console_output_ioctl, /* ioctl */
398 default_fd_queue_async, /* queue_async */
399 default_fd_reselect_async /* reselect_async */
402 struct console_connection
404 struct object obj; /* object header */
405 struct fd *fd; /* pseudo-fd for ioctls */
408 static void console_connection_dump( struct object *obj, int verbose );
409 static struct fd *console_connection_get_fd( struct object *obj );
410 static struct object *console_connection_lookup_name( struct object *obj, struct unicode_str *name,
411 unsigned int attr, struct object *root );
412 static struct object *console_connection_open_file( struct object *obj, unsigned int access,
413 unsigned int sharing, unsigned int options );
414 static int console_connection_close_handle( struct object *obj, struct process *process, obj_handle_t handle );
415 static void console_connection_destroy( struct object *obj );
417 static const struct object_ops console_connection_ops =
419 sizeof(struct console_connection),/* size */
420 &device_type, /* type */
421 console_connection_dump, /* dump */
422 no_add_queue, /* add_queue */
423 NULL, /* remove_queue */
424 NULL, /* signaled */
425 no_satisfied, /* satisfied */
426 no_signal, /* signal */
427 console_connection_get_fd, /* get_fd */
428 default_map_access, /* map_access */
429 default_get_sd, /* get_sd */
430 default_set_sd, /* set_sd */
431 no_get_full_name, /* get_full_name */
432 console_connection_lookup_name, /* lookup_name */
433 directory_link_name, /* link_name */
434 default_unlink_name, /* unlink_name */
435 console_connection_open_file, /* open_file */
436 no_kernel_obj_list, /* get_kernel_obj_list */
437 console_connection_close_handle, /* close_handle */
438 console_connection_destroy /* destroy */
441 static int console_connection_ioctl( struct fd *fd, ioctl_code_t code, struct async *async );
443 static const struct fd_ops console_connection_fd_ops =
445 default_fd_get_poll_events, /* get_poll_events */
446 default_poll_event, /* poll_event */
447 console_get_fd_type, /* get_fd_type */
448 no_fd_read, /* read */
449 no_fd_write, /* write */
450 no_fd_flush, /* flush */
451 no_fd_get_file_info, /* get_file_info */
452 no_fd_get_volume_info, /* get_volume_info */
453 console_connection_ioctl, /* ioctl */
454 default_fd_queue_async, /* queue_async */
455 default_fd_reselect_async /* reselect_async */
458 static struct list screen_buffer_list = LIST_INIT(screen_buffer_list);
460 static int console_signaled( struct object *obj, struct wait_queue_entry *entry )
462 struct console *console = (struct console*)obj;
463 return console->signaled;
466 static struct fd *console_get_fd( struct object *obj )
468 struct console *console = (struct console *)obj;
469 assert( obj->ops == &console_ops );
470 return (struct fd *)grab_object( console->fd );
473 static enum server_fd_type console_get_fd_type( struct fd *fd )
475 return FD_TYPE_CHAR;
478 static void console_get_file_info( struct fd *fd, obj_handle_t handle, unsigned int info_class )
480 set_error( STATUS_INVALID_DEVICE_REQUEST );
483 static int console_get_volume_info( struct fd *fd, struct async *async, unsigned int info_class )
485 switch (info_class)
487 case FileFsDeviceInformation:
489 static const FILE_FS_DEVICE_INFORMATION device_info =
491 FILE_DEVICE_CONSOLE,
492 FILE_DEVICE_ALLOW_APPCONTAINER_TRAVERSAL
494 if (get_reply_max_size() >= sizeof(device_info))
495 set_reply_data( &device_info, sizeof(device_info) );
496 else
497 set_error( STATUS_BUFFER_TOO_SMALL );
498 break;
500 default:
501 set_error( STATUS_NOT_IMPLEMENTED );
503 return 0;
506 static struct object *create_console(void)
508 struct console *console;
510 if (!(console = alloc_object( &console_ops )))
511 return NULL;
513 console->renderer = NULL;
514 console->signaled = 0;
515 console->active = NULL;
516 console->server = NULL;
517 console->fd = NULL;
518 console->last_id = 0;
519 init_async_queue( &console->ioctl_q );
520 init_async_queue( &console->read_q );
522 console->fd = alloc_pseudo_fd( &console_fd_ops, &console->obj, FILE_SYNCHRONOUS_IO_NONALERT );
523 if (!console->fd)
525 release_object( console );
526 return NULL;
528 allow_fd_caching( console->fd );
529 return &console->obj;
532 static void console_host_ioctl_terminate( struct console_host_ioctl *call, unsigned int status )
534 if (call->async)
536 async_terminate( call->async, status );
537 release_object( call->async );
539 free( call );
542 static int queue_host_ioctl( struct console_server *server, unsigned int code, unsigned int output,
543 struct async *async, struct async_queue *queue )
545 struct console_host_ioctl *ioctl;
547 if (!(ioctl = mem_alloc( sizeof(*ioctl) ))) return 0;
548 ioctl->code = code;
549 ioctl->output = output;
550 ioctl->async = NULL;
551 if (async)
553 ioctl->async = (struct async *)grab_object( async );
554 queue_async( queue, async );
556 list_add_tail( &server->queue, &ioctl->entry );
557 wake_up( &server->obj, 0 );
558 if (async) set_error( STATUS_PENDING );
559 return 1;
562 static void disconnect_console_server( struct console_server *server )
564 while (!list_empty( &server->queue ))
566 struct console_host_ioctl *call = LIST_ENTRY( list_head( &server->queue ), struct console_host_ioctl, entry );
567 list_remove( &call->entry );
568 console_host_ioctl_terminate( call, STATUS_CANCELLED );
570 while (!list_empty( &server->read_queue ))
572 struct console_host_ioctl *call = LIST_ENTRY( list_head( &server->read_queue ), struct console_host_ioctl, entry );
573 list_remove( &call->entry );
574 console_host_ioctl_terminate( call, STATUS_CANCELLED );
577 if (server->term_fd != -1)
579 tcsetattr( server->term_fd, TCSANOW, &server->termios );
580 close( server->term_fd );
581 server->term_fd = -1;
584 if (server->console)
586 assert( server->console->server == server );
587 server->console->server = NULL;
588 server->console = NULL;
589 wake_up( &server->obj, 0 );
593 static void set_active_screen_buffer( struct console *console, struct screen_buffer *screen_buffer )
595 if (console->active == screen_buffer) return;
596 if (console->active) release_object( console->active );
597 console->active = (struct screen_buffer *)grab_object( screen_buffer );
599 if (console->server) queue_host_ioctl( console->server, IOCTL_CONDRV_ACTIVATE,
600 screen_buffer->id, NULL, NULL );
603 static struct object *create_screen_buffer( struct console *console )
605 struct screen_buffer *screen_buffer;
607 if (console->last_id == ~0)
609 set_error( STATUS_NO_MEMORY );
610 return NULL;
613 if (!(screen_buffer = alloc_object( &screen_buffer_ops )))
614 return NULL;
616 screen_buffer->id = ++console->last_id;
617 screen_buffer->input = console;
618 init_async_queue( &screen_buffer->ioctl_q );
619 list_add_head( &screen_buffer_list, &screen_buffer->entry );
621 screen_buffer->fd = alloc_pseudo_fd( &screen_buffer_fd_ops, &screen_buffer->obj,
622 FILE_SYNCHRONOUS_IO_NONALERT );
623 if (!screen_buffer->fd)
625 release_object( screen_buffer );
626 return NULL;
628 allow_fd_caching(screen_buffer->fd);
630 if (console->server) queue_host_ioctl( console->server, IOCTL_CONDRV_INIT_OUTPUT,
631 screen_buffer->id, NULL, NULL );
632 if (!console->active) set_active_screen_buffer( console, screen_buffer );
633 return &screen_buffer->obj;
636 struct thread *console_get_renderer( struct console *console )
638 return console->renderer;
641 struct console_signal_info
643 struct console *console;
644 process_id_t group;
645 int signal;
648 static int propagate_console_signal_cb(struct process *process, void *user)
650 struct console_signal_info* csi = (struct console_signal_info*)user;
652 if (process->console == csi->console && process->running_threads &&
653 (!csi->group || process->group_id == csi->group))
655 /* find a suitable thread to signal */
656 struct thread *thread;
657 LIST_FOR_EACH_ENTRY( thread, &process->thread_list, struct thread, proc_entry )
659 if (send_thread_signal( thread, csi->signal )) break;
662 return FALSE;
665 static void propagate_console_signal( struct console *console,
666 int sig, process_id_t group_id )
668 struct console_signal_info csi;
670 if (!console)
672 set_error( STATUS_INVALID_PARAMETER );
673 return;
675 /* FIXME: should support the other events (like CTRL_BREAK) */
676 if (sig != CTRL_C_EVENT)
678 set_error( STATUS_NOT_IMPLEMENTED );
679 return;
681 csi.console = console;
682 csi.signal = SIGINT;
683 csi.group = group_id;
685 enum_processes(propagate_console_signal_cb, &csi);
688 /* dumb dump */
689 static void console_dump( struct object *obj, int verbose )
691 struct console *console = (struct console *)obj;
692 assert( obj->ops == &console_ops );
693 fprintf( stderr, "Console input active=%p server=%p\n",
694 console->active, console->server );
697 static void console_destroy( struct object *obj )
699 struct console *console = (struct console *)obj;
700 struct screen_buffer *curr;
702 assert( obj->ops == &console_ops );
704 if (console->server)
706 assert( console->server->console == console );
707 disconnect_console_server( console->server );
710 if (console->active) release_object( console->active );
711 console->active = NULL;
713 LIST_FOR_EACH_ENTRY( curr, &screen_buffer_list, struct screen_buffer, entry )
715 if (curr->input == console) curr->input = NULL;
718 free_async_queue( &console->ioctl_q );
719 free_async_queue( &console->read_q );
720 if (console->fd)
721 release_object( console->fd );
724 static struct object *create_console_connection( struct console *console )
726 struct console_connection *connection;
728 if (current->process->console)
730 set_error( STATUS_ACCESS_DENIED );
731 return NULL;
734 if (!(connection = alloc_object( &console_connection_ops ))) return NULL;
735 if (!(connection->fd = alloc_pseudo_fd( &console_connection_fd_ops, &connection->obj, 0 )))
737 release_object( connection );
738 return NULL;
741 if (console)
742 current->process->console = (struct console *)grab_object( console );
744 return &connection->obj;
747 static struct object *console_lookup_name( struct object *obj, struct unicode_str *name,
748 unsigned int attr, struct object *root )
750 struct console *console = (struct console *)obj;
751 static const WCHAR connectionW[] = {'C','o','n','n','e','c','t','i','o','n'};
752 assert( obj->ops == &console_ops );
754 if (name->len == sizeof(connectionW) && !memcmp( name->str, connectionW, name->len ))
756 name->len = 0;
757 return create_console_connection( console );
760 return NULL;
763 static struct object *console_open_file( struct object *obj, unsigned int access,
764 unsigned int sharing, unsigned int options )
766 return grab_object( obj );
769 static void screen_buffer_dump( struct object *obj, int verbose )
771 struct screen_buffer *screen_buffer = (struct screen_buffer *)obj;
772 assert( obj->ops == &screen_buffer_ops );
774 fprintf(stderr, "Console screen buffer input=%p\n", screen_buffer->input );
777 static void screen_buffer_destroy( struct object *obj )
779 struct screen_buffer *screen_buffer = (struct screen_buffer *)obj;
781 assert( obj->ops == &screen_buffer_ops );
783 list_remove( &screen_buffer->entry );
784 if (screen_buffer->input && screen_buffer->input->server)
785 queue_host_ioctl( screen_buffer->input->server, IOCTL_CONDRV_CLOSE_OUTPUT,
786 screen_buffer->id, NULL, NULL );
787 if (screen_buffer->fd) release_object( screen_buffer->fd );
788 free_async_queue( &screen_buffer->ioctl_q );
791 static struct object *screen_buffer_open_file( struct object *obj, unsigned int access,
792 unsigned int sharing, unsigned int options )
794 return grab_object( obj );
797 static int screen_buffer_add_queue( struct object *obj, struct wait_queue_entry *entry )
799 struct screen_buffer *screen_buffer = (struct screen_buffer*)obj;
800 if (!screen_buffer->input)
802 set_error( STATUS_ACCESS_DENIED );
803 return 0;
805 return add_queue( &screen_buffer->input->obj, entry );
808 static struct fd *screen_buffer_get_fd( struct object *obj )
810 struct screen_buffer *screen_buffer = (struct screen_buffer*)obj;
811 assert( obj->ops == &screen_buffer_ops );
812 if (screen_buffer->fd)
813 return (struct fd*)grab_object( screen_buffer->fd );
814 set_error( STATUS_OBJECT_TYPE_MISMATCH );
815 return NULL;
818 static void console_server_dump( struct object *obj, int verbose )
820 assert( obj->ops == &console_server_ops );
821 fprintf( stderr, "Console server\n" );
824 static void console_server_destroy( struct object *obj )
826 struct console_server *server = (struct console_server *)obj;
827 assert( obj->ops == &console_server_ops );
828 disconnect_console_server( server );
829 if (server->fd) release_object( server->fd );
832 static struct object *console_server_lookup_name( struct object *obj, struct unicode_str *name,
833 unsigned int attr, struct object *root )
835 struct console_server *server = (struct console_server*)obj;
836 static const WCHAR referenceW[] = {'R','e','f','e','r','e','n','c','e'};
837 assert( obj->ops == &console_server_ops );
839 if (name->len == sizeof(referenceW) && !memcmp( name->str, referenceW, name->len ))
841 struct screen_buffer *screen_buffer;
842 name->len = 0;
843 if (server->console)
845 set_error( STATUS_INVALID_HANDLE );
846 return 0;
848 if (!(server->console = (struct console *)create_console())) return NULL;
849 if (!(screen_buffer = (struct screen_buffer *)create_screen_buffer( server->console )))
851 release_object( server->console );
852 server->console = NULL;
853 return NULL;
855 release_object( screen_buffer );
856 server->console->server = server;
858 return &server->console->obj;
861 return NULL;
864 static int console_server_signaled( struct object *obj, struct wait_queue_entry *entry )
866 struct console_server *server = (struct console_server*)obj;
867 assert( obj->ops == &console_server_ops );
868 return !server->console || !list_empty( &server->queue );
871 static struct fd *console_server_get_fd( struct object* obj )
873 struct console_server *server = (struct console_server*)obj;
874 assert( obj->ops == &console_server_ops );
875 return (struct fd *)grab_object( server->fd );
878 static struct object *console_server_open_file( struct object *obj, unsigned int access,
879 unsigned int sharing, unsigned int options )
881 return grab_object( obj );
884 static struct object *create_console_server( void )
886 struct console_server *server;
888 if (!(server = alloc_object( &console_server_ops ))) return NULL;
889 server->console = NULL;
890 server->busy = 0;
891 server->term_fd = -1;
892 list_init( &server->queue );
893 list_init( &server->read_queue );
894 server->fd = alloc_pseudo_fd( &console_server_fd_ops, &server->obj, FILE_SYNCHRONOUS_IO_NONALERT );
895 if (!server->fd)
897 release_object( server );
898 return NULL;
900 allow_fd_caching(server->fd);
902 return &server->obj;
905 static int is_blocking_read_ioctl( unsigned int code )
907 switch (code)
909 case IOCTL_CONDRV_READ_INPUT:
910 case IOCTL_CONDRV_READ_CONSOLE:
911 case IOCTL_CONDRV_READ_FILE:
912 return 1;
913 default:
914 return 0;
918 static int console_ioctl( struct fd *fd, ioctl_code_t code, struct async *async )
920 struct console *console = get_fd_user( fd );
922 switch (code)
924 case IOCTL_CONDRV_CTRL_EVENT:
926 const struct condrv_ctrl_event *event = get_req_data();
927 process_id_t group;
928 if (get_req_data_size() != sizeof(*event))
930 set_error( STATUS_INVALID_PARAMETER );
931 return 0;
933 group = event->group_id ? event->group_id : current->process->group_id;
934 if (!group)
936 set_error( STATUS_INVALID_PARAMETER );
937 return 0;
939 propagate_console_signal( console, event->event, group );
940 return !get_error();
943 default:
944 if (!console->server || code >> 16 != FILE_DEVICE_CONSOLE)
946 set_error( STATUS_INVALID_HANDLE );
947 return 0;
949 return queue_host_ioctl( console->server, code, 0, async, &console->ioctl_q );
953 static int console_read( struct fd *fd, struct async *async, file_pos_t pos )
955 struct console *console = get_fd_user( fd );
957 if (!console->server)
959 set_error( STATUS_INVALID_HANDLE );
960 return 0;
962 return queue_host_ioctl( console->server, IOCTL_CONDRV_READ_FILE, 0, async, &console->ioctl_q );
965 static int console_flush( struct fd *fd, struct async *async )
967 struct console *console = get_fd_user( fd );
969 if (!console->server)
971 set_error( STATUS_INVALID_HANDLE );
972 return 0;
974 return queue_host_ioctl( console->server, IOCTL_CONDRV_FLUSH, 0, NULL, NULL );
977 static int screen_buffer_write( struct fd *fd, struct async *async, file_pos_t pos )
979 struct screen_buffer *screen_buffer = get_fd_user( fd );
980 struct iosb *iosb;
982 if (!screen_buffer->input || !screen_buffer->input->server)
984 set_error( STATUS_INVALID_HANDLE );
985 return 0;
988 if (!queue_host_ioctl( screen_buffer->input->server, IOCTL_CONDRV_WRITE_FILE,
989 screen_buffer->id, async, &screen_buffer->ioctl_q ))
990 return 0;
992 /* we can't use default async handling, because write result is not
993 * compatible with ioctl result */
994 iosb = async_get_iosb( async );
995 iosb->result = iosb->in_size;
996 release_object( iosb );
997 return 1;
1000 static int screen_buffer_ioctl( struct fd *fd, ioctl_code_t code, struct async *async )
1002 struct screen_buffer *screen_buffer = get_fd_user( fd );
1004 switch (code)
1006 case IOCTL_CONDRV_ACTIVATE:
1007 if (!screen_buffer->input)
1009 set_error( STATUS_INVALID_HANDLE );
1010 return 0;
1013 set_active_screen_buffer( screen_buffer->input, screen_buffer );
1014 return 1;
1016 default:
1017 if (!screen_buffer->input || !screen_buffer->input->server || code >> 16 != FILE_DEVICE_CONSOLE ||
1018 is_blocking_read_ioctl( code ))
1020 set_error( STATUS_INVALID_HANDLE );
1021 return 0;
1023 return queue_host_ioctl( screen_buffer->input->server, code, screen_buffer->id,
1024 async, &screen_buffer->ioctl_q );
1028 static int console_connection_ioctl( struct fd *fd, ioctl_code_t code, struct async *async )
1030 struct console_connection *console_connection = get_fd_user( fd );
1032 switch (code)
1034 case IOCTL_CONDRV_BIND_PID:
1036 struct process *process;
1037 unsigned int pid;
1038 if (get_req_data_size() != sizeof(unsigned int))
1040 set_error( STATUS_INVALID_PARAMETER );
1041 return 0;
1043 if (current->process->console)
1045 set_error( STATUS_INVALID_HANDLE );
1046 return 0;
1049 pid = *(unsigned int *)get_req_data();
1050 if (pid == ATTACH_PARENT_PROCESS) pid = current->process->parent_id;
1051 if (!(process = get_process_from_id( pid ))) return 0;
1053 if (process->console)
1054 current->process->console = (struct console *)grab_object( process->console );
1055 else set_error( STATUS_ACCESS_DENIED );
1056 release_object( process );
1057 return !get_error();
1060 default:
1061 return default_fd_ioctl( console_connection->fd, code, async );
1065 static int console_server_ioctl( struct fd *fd, ioctl_code_t code, struct async *async )
1067 struct console_server *server = get_fd_user( fd );
1069 switch (code)
1071 case IOCTL_CONDRV_CTRL_EVENT:
1073 const struct condrv_ctrl_event *event = get_req_data();
1074 if (get_req_data_size() != sizeof(*event))
1076 set_error( STATUS_INVALID_PARAMETER );
1077 return 0;
1079 if (!server->console)
1081 set_error( STATUS_INVALID_HANDLE );
1082 return 0;
1084 propagate_console_signal( server->console, event->event, event->group_id );
1085 return !get_error();
1088 case IOCTL_CONDRV_SETUP_INPUT:
1090 struct termios term;
1091 obj_handle_t handle;
1092 struct file *file;
1093 int unix_fd;
1095 if (get_req_data_size() != sizeof(unsigned int) || get_reply_max_size())
1097 set_error( STATUS_INVALID_PARAMETER );
1098 return 0;
1100 if (server->term_fd != -1)
1102 tcsetattr( server->term_fd, TCSANOW, &server->termios );
1103 close( server->term_fd );
1104 server->term_fd = -1;
1106 handle = *(unsigned int *)get_req_data();
1107 if (!handle) return 1;
1108 if (!(file = get_file_obj( current->process, handle, FILE_READ_DATA )))
1110 return 0;
1112 unix_fd = get_file_unix_fd( file );
1113 release_object( file );
1115 if (tcgetattr( unix_fd, &server->termios ))
1117 file_set_error();
1118 return 0;
1120 term = server->termios;
1121 term.c_lflag &= ~(ECHO | ECHONL | ICANON | IEXTEN);
1122 term.c_iflag &= ~(BRKINT | ICRNL | INPCK | ISTRIP | IXON);
1123 term.c_cflag &= ~(CSIZE | PARENB);
1124 term.c_cflag |= CS8;
1125 term.c_cc[VMIN] = 1;
1126 term.c_cc[VTIME] = 0;
1127 if (tcsetattr( unix_fd, TCSANOW, &term ) || (server->term_fd = dup( unix_fd )) == -1)
1129 file_set_error();
1130 return 0;
1132 return 1;
1135 default:
1136 set_error( STATUS_INVALID_HANDLE );
1137 return 0;
1141 static void console_connection_dump( struct object *obj, int verbose )
1143 fputs( "console connection\n", stderr );
1146 static struct fd *console_connection_get_fd( struct object *obj )
1148 struct console_connection *connection = (struct console_connection *)obj;
1149 return (struct fd *)grab_object( connection->fd );
1152 static struct object *console_connection_lookup_name( struct object *obj, struct unicode_str *name,
1153 unsigned int attr, struct object *root )
1155 static const WCHAR referenceW[] = {'R','e','f','e','r','e','n','c','e'};
1157 if (name->len == sizeof(referenceW) && !memcmp( name->str, referenceW, name->len ))
1159 if (!current->process->console)
1161 set_error( STATUS_INVALID_HANDLE );
1162 return NULL;
1164 name->len = 0;
1165 return grab_object( current->process->console );
1168 return NULL;
1171 static struct object *console_connection_open_file( struct object *obj, unsigned int access,
1172 unsigned int sharing, unsigned int options )
1174 return grab_object( obj );
1177 static int console_connection_close_handle( struct object *obj, struct process *process, obj_handle_t handle )
1179 struct console *console = process->console;
1181 if (console)
1183 process->console = NULL;
1184 release_object( console );
1186 return 1;
1189 static void console_connection_destroy( struct object *obj )
1191 struct console_connection *connection = (struct console_connection *)obj;
1192 if (connection->fd) release_object( connection->fd );
1195 static void console_device_dump( struct object *obj, int verbose )
1197 fputs( "Console device\n", stderr );
1200 static struct object *console_device_lookup_name( struct object *obj, struct unicode_str *name,
1201 unsigned int attr, struct object *root )
1203 static const WCHAR connectionW[] = {'C','o','n','n','e','c','t','i','o','n'};
1204 static const WCHAR consoleW[] = {'C','o','n','s','o','l','e'};
1205 static const WCHAR current_inW[] = {'C','u','r','r','e','n','t','I','n'};
1206 static const WCHAR current_outW[] = {'C','u','r','r','e','n','t','O','u','t'};
1207 static const WCHAR inputW[] = {'I','n','p','u','t'};
1208 static const WCHAR outputW[] = {'O','u','t','p','u','t'};
1209 static const WCHAR screen_bufferW[] = {'S','c','r','e','e','n','B','u','f','f','e','r'};
1210 static const WCHAR serverW[] = {'S','e','r','v','e','r'};
1212 if (name->len == sizeof(current_inW) && !memcmp( name->str, current_inW, name->len ))
1214 if (!current->process->console)
1216 set_error( STATUS_INVALID_HANDLE );
1217 return NULL;
1219 name->len = 0;
1220 return grab_object( current->process->console );
1223 if (name->len == sizeof(current_outW) && !memcmp( name->str, current_outW, name->len ))
1225 if (!current->process->console || !current->process->console->active)
1227 set_error( STATUS_INVALID_HANDLE );
1228 return NULL;
1230 name->len = 0;
1231 return grab_object( current->process->console->active );
1234 if (name->len == sizeof(consoleW) && !memcmp( name->str, consoleW, name->len ))
1236 name->len = 0;
1237 return grab_object( obj );
1240 if (name->len == sizeof(inputW) && !memcmp( name->str, inputW, name->len ))
1242 struct console_input *console_input;
1243 name->len = 0;
1244 if (!(console_input = alloc_object( &console_input_ops ))) return NULL;
1245 console_input->fd = alloc_pseudo_fd( &console_input_fd_ops, &console_input->obj,
1246 FILE_SYNCHRONOUS_IO_NONALERT );
1247 if (!console_input->fd)
1249 release_object( console_input );
1250 return NULL;
1252 return &console_input->obj;
1255 if (name->len == sizeof(outputW) && !memcmp( name->str, outputW, name->len ))
1257 struct console_output *console_output;
1258 name->len = 0;
1259 if (!(console_output = alloc_object( &console_output_ops ))) return NULL;
1260 console_output->fd = alloc_pseudo_fd( &console_output_fd_ops, &console_output->obj,
1261 FILE_SYNCHRONOUS_IO_NONALERT );
1262 if (!console_output->fd)
1264 release_object( console_output );
1265 return NULL;
1267 return &console_output->obj;
1270 if (name->len == sizeof(screen_bufferW) && !memcmp( name->str, screen_bufferW, name->len ))
1272 if (!current->process->console)
1274 set_error( STATUS_INVALID_HANDLE );
1275 return NULL;
1277 name->len = 0;
1278 return create_screen_buffer( current->process->console );
1281 if (name->len == sizeof(serverW) && !memcmp( name->str, serverW, name->len ))
1283 name->len = 0;
1284 return create_console_server();
1287 if (name->len == sizeof(connectionW) && !memcmp( name->str, connectionW, name->len ))
1289 name->len = 0;
1290 return create_console_connection( NULL );
1293 return NULL;
1296 static struct object *console_device_open_file( struct object *obj, unsigned int access,
1297 unsigned int sharing, unsigned int options )
1299 int is_output;
1300 access = default_map_access( obj, access );
1301 is_output = access & FILE_WRITE_DATA;
1302 if (!current->process->console || (is_output && !current->process->console))
1304 set_error( STATUS_INVALID_HANDLE );
1305 return NULL;
1307 if (is_output && (access & FILE_READ_DATA))
1309 set_error( STATUS_INVALID_PARAMETER );
1310 return NULL;
1312 return is_output ? grab_object( current->process->console->active ) : grab_object( current->process->console );
1315 static void console_input_dump( struct object *obj, int verbose )
1317 fputs( "console Input device\n", stderr );
1320 static int console_input_add_queue( struct object *obj, struct wait_queue_entry *entry )
1322 if (!current->process->console)
1324 set_error( STATUS_ACCESS_DENIED );
1325 return 0;
1327 return add_queue( &current->process->console->obj, entry );
1330 static struct fd *console_input_get_fd( struct object *obj )
1332 struct console_input *console_input = (struct console_input *)obj;
1333 assert( obj->ops == &console_input_ops );
1334 return (struct fd *)grab_object( console_input->fd );
1337 static struct object *console_input_open_file( struct object *obj, unsigned int access,
1338 unsigned int sharing, unsigned int options )
1340 return grab_object( obj );
1343 static void console_input_destroy( struct object *obj )
1345 struct console_input *console_input = (struct console_input *)obj;
1347 assert( obj->ops == &console_input_ops );
1348 if (console_input->fd) release_object( console_input->fd );
1351 static int console_input_ioctl( struct fd *fd, ioctl_code_t code, struct async *async )
1353 struct console *console = current->process->console;
1355 if (!console)
1357 set_error( STATUS_INVALID_HANDLE );
1358 return 0;
1360 return console_ioctl( console->fd, code, async );
1363 static int console_input_read( struct fd *fd, struct async *async, file_pos_t pos )
1365 struct console *console = current->process->console;
1367 if (!console)
1369 set_error( STATUS_INVALID_HANDLE );
1370 return 0;
1372 return console_read( console->fd, async, pos );
1375 static int console_input_flush( struct fd *fd, struct async *async )
1377 struct console *console = current->process->console;
1379 if (!console)
1381 set_error( STATUS_INVALID_HANDLE );
1382 return 0;
1384 return console_flush( console->fd, async );
1387 static void console_output_dump( struct object *obj, int verbose )
1389 fputs( "console Output device\n", stderr );
1392 static int console_output_add_queue( struct object *obj, struct wait_queue_entry *entry )
1394 if (!current->process->console || !current->process->console->active)
1396 set_error( STATUS_ACCESS_DENIED );
1397 return 0;
1399 return add_queue( &current->process->console->obj, entry );
1402 static struct fd *console_output_get_fd( struct object *obj )
1404 struct console_output *console_output = (struct console_output *)obj;
1405 assert( obj->ops == &console_output_ops );
1406 return (struct fd *)grab_object( console_output->fd );
1409 static struct object *console_output_open_file( struct object *obj, unsigned int access,
1410 unsigned int sharing, unsigned int options )
1412 return grab_object( obj );
1415 static void console_output_destroy( struct object *obj )
1417 struct console_output *console_output = (struct console_output *)obj;
1419 assert( obj->ops == &console_output_ops );
1420 if (console_output->fd) release_object( console_output->fd );
1423 static int console_output_ioctl( struct fd *fd, ioctl_code_t code, struct async *async )
1425 struct console *console = current->process->console;
1427 if (!console || !console->active)
1429 set_error( STATUS_INVALID_HANDLE );
1430 return 0;
1432 return screen_buffer_ioctl( console->active->fd, code, async );
1435 static int console_output_write( struct fd *fd, struct async *async, file_pos_t pos )
1437 struct console *console = current->process->console;
1439 if (!console || !console->active)
1441 set_error( STATUS_INVALID_HANDLE );
1442 return 0;
1444 return screen_buffer_write( console->active->fd, async, pos );
1447 struct object *create_console_device( struct object *root, const struct unicode_str *name,
1448 unsigned int attr, const struct security_descriptor *sd )
1450 return create_named_object( root, &console_device_ops, name, attr, sd );
1453 /* retrieve the next pending console ioctl request */
1454 DECL_HANDLER(get_next_console_request)
1456 struct console_host_ioctl *ioctl = NULL, *next;
1457 struct console_server *server;
1458 struct iosb *iosb = NULL;
1460 server = (struct console_server *)get_handle_obj( current->process, req->handle, 0, &console_server_ops );
1461 if (!server) return;
1463 if (!server->console)
1465 set_error( STATUS_INVALID_HANDLE );
1466 release_object( server );
1467 return;
1470 if (!server->console->renderer) server->console->renderer = current;
1472 if (!req->signal) server->console->signaled = 0;
1473 else if (!server->console->signaled)
1475 server->console->signaled = 1;
1476 wake_up( &server->console->obj, 0 );
1479 if (req->read)
1481 /* set result of current pending ioctl */
1482 if (list_empty( &server->read_queue ))
1484 set_error( STATUS_INVALID_HANDLE );
1485 release_object( server );
1486 return;
1489 ioctl = LIST_ENTRY( list_head( &server->read_queue ), struct console_host_ioctl, entry );
1490 list_remove( &ioctl->entry );
1491 list_move_tail( &server->queue, &server->read_queue );
1493 else if (server->busy)
1495 /* set result of previous ioctl */
1496 ioctl = LIST_ENTRY( list_head( &server->queue ), struct console_host_ioctl, entry );
1497 list_remove( &ioctl->entry );
1500 if (ioctl)
1502 unsigned int status = req->status;
1503 if (status == STATUS_PENDING) status = STATUS_INVALID_PARAMETER;
1504 if (ioctl->async)
1506 iosb = async_get_iosb( ioctl->async );
1507 if (iosb->status == STATUS_PENDING)
1509 iosb->status = status;
1510 iosb->out_size = min( iosb->out_size, get_req_data_size() );
1511 if (iosb->out_size)
1513 if ((iosb->out_data = memdup( get_req_data(), iosb->out_size )))
1515 iosb->result = iosb->out_size;
1517 else if (!status)
1519 iosb->status = STATUS_NO_MEMORY;
1520 iosb->out_size = 0;
1523 if (iosb->result) status = STATUS_ALERTED;
1525 else
1527 release_object( ioctl->async );
1528 ioctl->async = NULL;
1531 console_host_ioctl_terminate( ioctl, status );
1532 if (iosb) release_object( iosb );
1534 if (req->read)
1536 release_object( server );
1537 return;
1539 server->busy = 0;
1542 /* if we have a blocking read ioctl in queue head and previous blocking read is still waiting,
1543 * move it to read queue for execution after current read is complete. move all blocking
1544 * ioctl at the same time to preserve their order. */
1545 if (!list_empty( &server->queue ) && !list_empty( &server->read_queue ))
1547 ioctl = LIST_ENTRY( list_head( &server->queue ), struct console_host_ioctl, entry );
1548 if (is_blocking_read_ioctl( ioctl->code ))
1550 LIST_FOR_EACH_ENTRY_SAFE( ioctl, next, &server->queue, struct console_host_ioctl, entry )
1552 if (!is_blocking_read_ioctl( ioctl->code )) continue;
1553 list_remove( &ioctl->entry );
1554 list_add_tail( &server->read_queue, &ioctl->entry );
1559 /* return the next ioctl */
1560 if (!list_empty( &server->queue ))
1562 ioctl = LIST_ENTRY( list_head( &server->queue ), struct console_host_ioctl, entry );
1563 iosb = ioctl->async ? async_get_iosb( ioctl->async ) : NULL;
1565 if (!iosb || get_reply_max_size() >= iosb->in_size)
1567 reply->code = ioctl->code;
1568 reply->output = ioctl->output;
1570 if (iosb)
1572 reply->out_size = iosb->out_size;
1573 set_reply_data_ptr( iosb->in_data, iosb->in_size );
1574 iosb->in_data = NULL;
1577 if (is_blocking_read_ioctl( ioctl->code ))
1579 list_remove( &ioctl->entry );
1580 assert( list_empty( &server->read_queue ));
1581 list_add_tail( &server->read_queue, &ioctl->entry );
1583 else server->busy = 1;
1585 else
1587 reply->out_size = iosb->in_size;
1588 set_error( STATUS_BUFFER_OVERFLOW );
1590 if (iosb) release_object( iosb );
1592 else
1594 set_error( STATUS_PENDING );
1597 release_object( server );