d2d1: Remove unused D3D10 interfaces.
[wine.git] / server / console.c
blob1e6f6c0f8a356bef15900478ad81e2bcb8474760
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 no_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 && (!csi->group || process->group_id == csi->group))
654 /* find a suitable thread to signal */
655 struct thread *thread;
656 LIST_FOR_EACH_ENTRY( thread, &process->thread_list, struct thread, proc_entry )
658 if (send_thread_signal( thread, csi->signal )) break;
661 return FALSE;
664 static void propagate_console_signal( struct console *console,
665 int sig, process_id_t group_id )
667 struct console_signal_info csi;
669 if (!console)
671 set_error( STATUS_INVALID_PARAMETER );
672 return;
674 /* FIXME: should support the other events (like CTRL_BREAK) */
675 if (sig != CTRL_C_EVENT)
677 set_error( STATUS_NOT_IMPLEMENTED );
678 return;
680 csi.console = console;
681 csi.signal = SIGINT;
682 csi.group = group_id;
684 enum_processes(propagate_console_signal_cb, &csi);
687 /* dumb dump */
688 static void console_dump( struct object *obj, int verbose )
690 struct console *console = (struct console *)obj;
691 assert( obj->ops == &console_ops );
692 fprintf( stderr, "Console input active=%p server=%p\n",
693 console->active, console->server );
696 static void console_destroy( struct object *obj )
698 struct console *console = (struct console *)obj;
699 struct screen_buffer *curr;
701 assert( obj->ops == &console_ops );
703 if (console->server)
705 assert( console->server->console == console );
706 disconnect_console_server( console->server );
709 if (console->active) release_object( console->active );
710 console->active = NULL;
712 LIST_FOR_EACH_ENTRY( curr, &screen_buffer_list, struct screen_buffer, entry )
714 if (curr->input == console) curr->input = NULL;
717 free_async_queue( &console->ioctl_q );
718 free_async_queue( &console->read_q );
719 if (console->fd)
720 release_object( console->fd );
723 static struct object *create_console_connection( struct console *console )
725 struct console_connection *connection;
727 if (current->process->console)
729 set_error( STATUS_ACCESS_DENIED );
730 return NULL;
733 if (!(connection = alloc_object( &console_connection_ops ))) return NULL;
734 if (!(connection->fd = alloc_pseudo_fd( &console_connection_fd_ops, &connection->obj, 0 )))
736 release_object( connection );
737 return NULL;
740 if (console)
741 current->process->console = (struct console *)grab_object( console );
743 return &connection->obj;
746 static struct object *console_lookup_name( struct object *obj, struct unicode_str *name,
747 unsigned int attr, struct object *root )
749 struct console *console = (struct console *)obj;
750 static const WCHAR connectionW[] = {'C','o','n','n','e','c','t','i','o','n'};
751 assert( obj->ops == &console_ops );
753 if (name->len == sizeof(connectionW) && !memcmp( name->str, connectionW, name->len ))
755 name->len = 0;
756 return create_console_connection( console );
759 return NULL;
762 static struct object *console_open_file( struct object *obj, unsigned int access,
763 unsigned int sharing, unsigned int options )
765 return grab_object( obj );
768 static void screen_buffer_dump( struct object *obj, int verbose )
770 struct screen_buffer *screen_buffer = (struct screen_buffer *)obj;
771 assert( obj->ops == &screen_buffer_ops );
773 fprintf(stderr, "Console screen buffer input=%p\n", screen_buffer->input );
776 static void screen_buffer_destroy( struct object *obj )
778 struct screen_buffer *screen_buffer = (struct screen_buffer *)obj;
780 assert( obj->ops == &screen_buffer_ops );
782 list_remove( &screen_buffer->entry );
783 if (screen_buffer->input && screen_buffer->input->server)
784 queue_host_ioctl( screen_buffer->input->server, IOCTL_CONDRV_CLOSE_OUTPUT,
785 screen_buffer->id, NULL, NULL );
786 if (screen_buffer->fd) release_object( screen_buffer->fd );
787 free_async_queue( &screen_buffer->ioctl_q );
790 static struct object *screen_buffer_open_file( struct object *obj, unsigned int access,
791 unsigned int sharing, unsigned int options )
793 return grab_object( obj );
796 static int screen_buffer_add_queue( struct object *obj, struct wait_queue_entry *entry )
798 struct screen_buffer *screen_buffer = (struct screen_buffer*)obj;
799 if (!screen_buffer->input)
801 set_error( STATUS_ACCESS_DENIED );
802 return 0;
804 return add_queue( &screen_buffer->input->obj, entry );
807 static struct fd *screen_buffer_get_fd( struct object *obj )
809 struct screen_buffer *screen_buffer = (struct screen_buffer*)obj;
810 assert( obj->ops == &screen_buffer_ops );
811 if (screen_buffer->fd)
812 return (struct fd*)grab_object( screen_buffer->fd );
813 set_error( STATUS_OBJECT_TYPE_MISMATCH );
814 return NULL;
817 static void console_server_dump( struct object *obj, int verbose )
819 assert( obj->ops == &console_server_ops );
820 fprintf( stderr, "Console server\n" );
823 static void console_server_destroy( struct object *obj )
825 struct console_server *server = (struct console_server *)obj;
826 assert( obj->ops == &console_server_ops );
827 disconnect_console_server( server );
828 if (server->fd) release_object( server->fd );
831 static struct object *console_server_lookup_name( struct object *obj, struct unicode_str *name,
832 unsigned int attr, struct object *root )
834 struct console_server *server = (struct console_server*)obj;
835 static const WCHAR referenceW[] = {'R','e','f','e','r','e','n','c','e'};
836 assert( obj->ops == &console_server_ops );
838 if (name->len == sizeof(referenceW) && !memcmp( name->str, referenceW, name->len ))
840 struct screen_buffer *screen_buffer;
841 name->len = 0;
842 if (server->console)
844 set_error( STATUS_INVALID_HANDLE );
845 return 0;
847 if (!(server->console = (struct console *)create_console())) return NULL;
848 if (!(screen_buffer = (struct screen_buffer *)create_screen_buffer( server->console )))
850 release_object( server->console );
851 server->console = NULL;
852 return NULL;
854 release_object( screen_buffer );
855 server->console->server = server;
857 return &server->console->obj;
860 return NULL;
863 static int console_server_signaled( struct object *obj, struct wait_queue_entry *entry )
865 struct console_server *server = (struct console_server*)obj;
866 assert( obj->ops == &console_server_ops );
867 return !server->console || !list_empty( &server->queue );
870 static struct fd *console_server_get_fd( struct object* obj )
872 struct console_server *server = (struct console_server*)obj;
873 assert( obj->ops == &console_server_ops );
874 return (struct fd *)grab_object( server->fd );
877 static struct object *console_server_open_file( struct object *obj, unsigned int access,
878 unsigned int sharing, unsigned int options )
880 return grab_object( obj );
883 static struct object *create_console_server( void )
885 struct console_server *server;
887 if (!(server = alloc_object( &console_server_ops ))) return NULL;
888 server->console = NULL;
889 server->busy = 0;
890 server->term_fd = -1;
891 list_init( &server->queue );
892 list_init( &server->read_queue );
893 server->fd = alloc_pseudo_fd( &console_server_fd_ops, &server->obj, FILE_SYNCHRONOUS_IO_NONALERT );
894 if (!server->fd)
896 release_object( server );
897 return NULL;
899 allow_fd_caching(server->fd);
901 return &server->obj;
904 static int is_blocking_read_ioctl( unsigned int code )
906 switch (code)
908 case IOCTL_CONDRV_READ_INPUT:
909 case IOCTL_CONDRV_READ_CONSOLE:
910 case IOCTL_CONDRV_READ_FILE:
911 return 1;
912 default:
913 return 0;
917 static int console_ioctl( struct fd *fd, ioctl_code_t code, struct async *async )
919 struct console *console = get_fd_user( fd );
921 switch (code)
923 case IOCTL_CONDRV_CTRL_EVENT:
925 const struct condrv_ctrl_event *event = get_req_data();
926 process_id_t group;
927 if (get_req_data_size() != sizeof(*event))
929 set_error( STATUS_INVALID_PARAMETER );
930 return 0;
932 group = event->group_id ? event->group_id : current->process->group_id;
933 if (!group)
935 set_error( STATUS_INVALID_PARAMETER );
936 return 0;
938 propagate_console_signal( console, event->event, group );
939 return !get_error();
942 default:
943 if (!console->server || code >> 16 != FILE_DEVICE_CONSOLE)
945 set_error( STATUS_INVALID_HANDLE );
946 return 0;
948 return queue_host_ioctl( console->server, code, 0, async, &console->ioctl_q );
952 static int console_read( struct fd *fd, struct async *async, file_pos_t pos )
954 struct console *console = get_fd_user( fd );
956 if (!console->server)
958 set_error( STATUS_INVALID_HANDLE );
959 return 0;
961 return queue_host_ioctl( console->server, IOCTL_CONDRV_READ_FILE, 0, async, &console->ioctl_q );
964 static int console_flush( struct fd *fd, struct async *async )
966 struct console *console = get_fd_user( fd );
968 if (!console->server)
970 set_error( STATUS_INVALID_HANDLE );
971 return 0;
973 return queue_host_ioctl( console->server, IOCTL_CONDRV_FLUSH, 0, NULL, NULL );
976 static int screen_buffer_write( struct fd *fd, struct async *async, file_pos_t pos )
978 struct screen_buffer *screen_buffer = get_fd_user( fd );
979 struct iosb *iosb;
981 if (!screen_buffer->input || !screen_buffer->input->server)
983 set_error( STATUS_INVALID_HANDLE );
984 return 0;
987 if (!queue_host_ioctl( screen_buffer->input->server, IOCTL_CONDRV_WRITE_FILE,
988 screen_buffer->id, async, &screen_buffer->ioctl_q ))
989 return 0;
991 /* we can't use default async handling, because write result is not
992 * compatible with ioctl result */
993 iosb = async_get_iosb( async );
994 iosb->result = iosb->in_size;
995 release_object( iosb );
996 return 1;
999 static int screen_buffer_ioctl( struct fd *fd, ioctl_code_t code, struct async *async )
1001 struct screen_buffer *screen_buffer = get_fd_user( fd );
1003 switch (code)
1005 case IOCTL_CONDRV_ACTIVATE:
1006 if (!screen_buffer->input)
1008 set_error( STATUS_INVALID_HANDLE );
1009 return 0;
1012 set_active_screen_buffer( screen_buffer->input, screen_buffer );
1013 return 1;
1015 default:
1016 if (!screen_buffer->input || !screen_buffer->input->server || code >> 16 != FILE_DEVICE_CONSOLE ||
1017 is_blocking_read_ioctl( code ))
1019 set_error( STATUS_INVALID_HANDLE );
1020 return 0;
1022 return queue_host_ioctl( screen_buffer->input->server, code, screen_buffer->id,
1023 async, &screen_buffer->ioctl_q );
1027 static int console_connection_ioctl( struct fd *fd, ioctl_code_t code, struct async *async )
1029 struct console_connection *console_connection = get_fd_user( fd );
1031 switch (code)
1033 case IOCTL_CONDRV_BIND_PID:
1035 struct process *process;
1036 unsigned int pid;
1037 if (get_req_data_size() != sizeof(unsigned int))
1039 set_error( STATUS_INVALID_PARAMETER );
1040 return 0;
1042 if (current->process->console)
1044 set_error( STATUS_INVALID_HANDLE );
1045 return 0;
1048 pid = *(unsigned int *)get_req_data();
1049 if (pid == ATTACH_PARENT_PROCESS) pid = current->process->parent_id;
1050 if (!(process = get_process_from_id( pid ))) return 0;
1052 if (process->console)
1053 current->process->console = (struct console *)grab_object( process->console );
1054 else set_error( STATUS_ACCESS_DENIED );
1055 release_object( process );
1056 return !get_error();
1059 default:
1060 return default_fd_ioctl( console_connection->fd, code, async );
1064 static int console_server_ioctl( struct fd *fd, ioctl_code_t code, struct async *async )
1066 struct console_server *server = get_fd_user( fd );
1068 switch (code)
1070 case IOCTL_CONDRV_CTRL_EVENT:
1072 const struct condrv_ctrl_event *event = get_req_data();
1073 if (get_req_data_size() != sizeof(*event))
1075 set_error( STATUS_INVALID_PARAMETER );
1076 return 0;
1078 if (!server->console)
1080 set_error( STATUS_INVALID_HANDLE );
1081 return 0;
1083 propagate_console_signal( server->console, event->event, event->group_id );
1084 return !get_error();
1087 case IOCTL_CONDRV_SETUP_INPUT:
1089 struct termios term;
1090 obj_handle_t handle;
1091 struct file *file;
1092 int unix_fd;
1094 if (get_req_data_size() != sizeof(unsigned int) || get_reply_max_size())
1096 set_error( STATUS_INVALID_PARAMETER );
1097 return 0;
1099 if (server->term_fd != -1)
1101 tcsetattr( server->term_fd, TCSANOW, &server->termios );
1102 close( server->term_fd );
1103 server->term_fd = -1;
1105 handle = *(unsigned int *)get_req_data();
1106 if (!handle) return 1;
1107 if (!(file = get_file_obj( current->process, handle, FILE_READ_DATA )))
1109 return 0;
1111 unix_fd = get_file_unix_fd( file );
1112 release_object( file );
1114 if (tcgetattr( unix_fd, &server->termios ))
1116 file_set_error();
1117 return 0;
1119 term = server->termios;
1120 term.c_lflag &= ~(ECHO | ECHONL | ICANON | IEXTEN);
1121 term.c_iflag &= ~(BRKINT | ICRNL | INPCK | ISTRIP | IXON);
1122 term.c_cflag &= ~(CSIZE | PARENB);
1123 term.c_cflag |= CS8;
1124 term.c_cc[VMIN] = 1;
1125 term.c_cc[VTIME] = 0;
1126 if (tcsetattr( unix_fd, TCSANOW, &term ) || (server->term_fd = dup( unix_fd )) == -1)
1128 file_set_error();
1129 return 0;
1131 return 1;
1134 default:
1135 set_error( STATUS_INVALID_HANDLE );
1136 return 0;
1140 static void console_connection_dump( struct object *obj, int verbose )
1142 fputs( "console connection\n", stderr );
1145 static struct fd *console_connection_get_fd( struct object *obj )
1147 struct console_connection *connection = (struct console_connection *)obj;
1148 return (struct fd *)grab_object( connection->fd );
1151 static struct object *console_connection_lookup_name( struct object *obj, struct unicode_str *name,
1152 unsigned int attr, struct object *root )
1154 static const WCHAR referenceW[] = {'R','e','f','e','r','e','n','c','e'};
1156 if (name->len == sizeof(referenceW) && !memcmp( name->str, referenceW, name->len ))
1158 if (!current->process->console)
1160 set_error( STATUS_INVALID_HANDLE );
1161 return NULL;
1163 name->len = 0;
1164 return grab_object( current->process->console );
1167 return NULL;
1170 static struct object *console_connection_open_file( struct object *obj, unsigned int access,
1171 unsigned int sharing, unsigned int options )
1173 return grab_object( obj );
1176 static int console_connection_close_handle( struct object *obj, struct process *process, obj_handle_t handle )
1178 struct console *console = process->console;
1180 if (console)
1182 process->console = NULL;
1183 release_object( console );
1185 return 1;
1188 static void console_connection_destroy( struct object *obj )
1190 struct console_connection *connection = (struct console_connection *)obj;
1191 if (connection->fd) release_object( connection->fd );
1194 static void console_device_dump( struct object *obj, int verbose )
1196 fputs( "Console device\n", stderr );
1199 static struct object *console_device_lookup_name( struct object *obj, struct unicode_str *name,
1200 unsigned int attr, struct object *root )
1202 static const WCHAR connectionW[] = {'C','o','n','n','e','c','t','i','o','n'};
1203 static const WCHAR consoleW[] = {'C','o','n','s','o','l','e'};
1204 static const WCHAR current_inW[] = {'C','u','r','r','e','n','t','I','n'};
1205 static const WCHAR current_outW[] = {'C','u','r','r','e','n','t','O','u','t'};
1206 static const WCHAR inputW[] = {'I','n','p','u','t'};
1207 static const WCHAR outputW[] = {'O','u','t','p','u','t'};
1208 static const WCHAR screen_bufferW[] = {'S','c','r','e','e','n','B','u','f','f','e','r'};
1209 static const WCHAR serverW[] = {'S','e','r','v','e','r'};
1211 if (name->len == sizeof(current_inW) && !memcmp( name->str, current_inW, name->len ))
1213 if (!current->process->console)
1215 set_error( STATUS_INVALID_HANDLE );
1216 return NULL;
1218 name->len = 0;
1219 return grab_object( current->process->console );
1222 if (name->len == sizeof(current_outW) && !memcmp( name->str, current_outW, name->len ))
1224 if (!current->process->console || !current->process->console->active)
1226 set_error( STATUS_INVALID_HANDLE );
1227 return NULL;
1229 name->len = 0;
1230 return grab_object( current->process->console->active );
1233 if (name->len == sizeof(consoleW) && !memcmp( name->str, consoleW, name->len ))
1235 name->len = 0;
1236 return grab_object( obj );
1239 if (name->len == sizeof(inputW) && !memcmp( name->str, inputW, name->len ))
1241 struct console_input *console_input;
1242 name->len = 0;
1243 if (!(console_input = alloc_object( &console_input_ops ))) return NULL;
1244 console_input->fd = alloc_pseudo_fd( &console_input_fd_ops, &console_input->obj,
1245 FILE_SYNCHRONOUS_IO_NONALERT );
1246 if (!console_input->fd)
1248 release_object( console_input );
1249 return NULL;
1251 return &console_input->obj;
1254 if (name->len == sizeof(outputW) && !memcmp( name->str, outputW, name->len ))
1256 struct console_output *console_output;
1257 name->len = 0;
1258 if (!(console_output = alloc_object( &console_output_ops ))) return NULL;
1259 console_output->fd = alloc_pseudo_fd( &console_output_fd_ops, &console_output->obj,
1260 FILE_SYNCHRONOUS_IO_NONALERT );
1261 if (!console_output->fd)
1263 release_object( console_output );
1264 return NULL;
1266 return &console_output->obj;
1269 if (name->len == sizeof(screen_bufferW) && !memcmp( name->str, screen_bufferW, name->len ))
1271 if (!current->process->console)
1273 set_error( STATUS_INVALID_HANDLE );
1274 return NULL;
1276 name->len = 0;
1277 return create_screen_buffer( current->process->console );
1280 if (name->len == sizeof(serverW) && !memcmp( name->str, serverW, name->len ))
1282 name->len = 0;
1283 return create_console_server();
1286 if (name->len == sizeof(connectionW) && !memcmp( name->str, connectionW, name->len ))
1288 name->len = 0;
1289 return create_console_connection( NULL );
1292 return NULL;
1295 static struct object *console_device_open_file( struct object *obj, unsigned int access,
1296 unsigned int sharing, unsigned int options )
1298 int is_output;
1299 access = default_map_access( obj, access );
1300 is_output = access & FILE_WRITE_DATA;
1301 if (!current->process->console || (is_output && !current->process->console))
1303 set_error( STATUS_INVALID_HANDLE );
1304 return NULL;
1306 if (is_output && (access & FILE_READ_DATA))
1308 set_error( STATUS_INVALID_PARAMETER );
1309 return NULL;
1311 return is_output ? grab_object( current->process->console->active ) : grab_object( current->process->console );
1314 static void console_input_dump( struct object *obj, int verbose )
1316 fputs( "console Input device\n", stderr );
1319 static int console_input_add_queue( struct object *obj, struct wait_queue_entry *entry )
1321 if (!current->process->console)
1323 set_error( STATUS_ACCESS_DENIED );
1324 return 0;
1326 return add_queue( &current->process->console->obj, entry );
1329 static struct fd *console_input_get_fd( struct object *obj )
1331 struct console_input *console_input = (struct console_input *)obj;
1332 assert( obj->ops == &console_input_ops );
1333 return (struct fd *)grab_object( console_input->fd );
1336 static struct object *console_input_open_file( struct object *obj, unsigned int access,
1337 unsigned int sharing, unsigned int options )
1339 return grab_object( obj );
1342 static void console_input_destroy( struct object *obj )
1344 struct console_input *console_input = (struct console_input *)obj;
1346 assert( obj->ops == &console_input_ops );
1347 if (console_input->fd) release_object( console_input->fd );
1350 static int console_input_ioctl( struct fd *fd, ioctl_code_t code, struct async *async )
1352 struct console *console = current->process->console;
1354 if (!console)
1356 set_error( STATUS_INVALID_HANDLE );
1357 return 0;
1359 return console_ioctl( console->fd, code, async );
1362 static int console_input_read( struct fd *fd, struct async *async, file_pos_t pos )
1364 struct console *console = current->process->console;
1366 if (!console)
1368 set_error( STATUS_INVALID_HANDLE );
1369 return 0;
1371 return console_read( console->fd, async, pos );
1374 static int console_input_flush( struct fd *fd, struct async *async )
1376 struct console *console = current->process->console;
1378 if (!console)
1380 set_error( STATUS_INVALID_HANDLE );
1381 return 0;
1383 return console_flush( console->fd, async );
1386 static void console_output_dump( struct object *obj, int verbose )
1388 fputs( "console Output device\n", stderr );
1391 static int console_output_add_queue( struct object *obj, struct wait_queue_entry *entry )
1393 if (!current->process->console || !current->process->console->active)
1395 set_error( STATUS_ACCESS_DENIED );
1396 return 0;
1398 return add_queue( &current->process->console->obj, entry );
1401 static struct fd *console_output_get_fd( struct object *obj )
1403 struct console_output *console_output = (struct console_output *)obj;
1404 assert( obj->ops == &console_output_ops );
1405 return (struct fd *)grab_object( console_output->fd );
1408 static struct object *console_output_open_file( struct object *obj, unsigned int access,
1409 unsigned int sharing, unsigned int options )
1411 return grab_object( obj );
1414 static void console_output_destroy( struct object *obj )
1416 struct console_output *console_output = (struct console_output *)obj;
1418 assert( obj->ops == &console_output_ops );
1419 if (console_output->fd) release_object( console_output->fd );
1422 static int console_output_ioctl( struct fd *fd, ioctl_code_t code, struct async *async )
1424 struct console *console = current->process->console;
1426 if (!console || !console->active)
1428 set_error( STATUS_INVALID_HANDLE );
1429 return 0;
1431 return screen_buffer_ioctl( console->active->fd, code, async );
1434 static int console_output_write( struct fd *fd, struct async *async, file_pos_t pos )
1436 struct console *console = current->process->console;
1438 if (!console || !console->active)
1440 set_error( STATUS_INVALID_HANDLE );
1441 return 0;
1443 return screen_buffer_write( console->active->fd, async, pos );
1446 struct object *create_console_device( struct object *root, const struct unicode_str *name,
1447 unsigned int attr, const struct security_descriptor *sd )
1449 return create_named_object( root, &console_device_ops, name, attr, sd );
1452 /* retrieve the next pending console ioctl request */
1453 DECL_HANDLER(get_next_console_request)
1455 struct console_host_ioctl *ioctl = NULL, *next;
1456 struct console_server *server;
1457 struct iosb *iosb = NULL;
1459 server = (struct console_server *)get_handle_obj( current->process, req->handle, 0, &console_server_ops );
1460 if (!server) return;
1462 if (!server->console)
1464 set_error( STATUS_INVALID_HANDLE );
1465 release_object( server );
1466 return;
1469 if (!server->console->renderer) server->console->renderer = current;
1471 if (!req->signal) server->console->signaled = 0;
1472 else if (!server->console->signaled)
1474 server->console->signaled = 1;
1475 wake_up( &server->console->obj, 0 );
1478 if (req->read)
1480 /* set result of current pending ioctl */
1481 if (list_empty( &server->read_queue ))
1483 set_error( STATUS_INVALID_HANDLE );
1484 release_object( server );
1485 return;
1488 ioctl = LIST_ENTRY( list_head( &server->read_queue ), struct console_host_ioctl, entry );
1489 list_remove( &ioctl->entry );
1490 list_move_tail( &server->queue, &server->read_queue );
1492 else if (server->busy)
1494 /* set result of previous ioctl */
1495 ioctl = LIST_ENTRY( list_head( &server->queue ), struct console_host_ioctl, entry );
1496 list_remove( &ioctl->entry );
1499 if (ioctl)
1501 unsigned int status = req->status;
1502 if (status == STATUS_PENDING) status = STATUS_INVALID_PARAMETER;
1503 if (ioctl->async)
1505 iosb = async_get_iosb( ioctl->async );
1506 if (iosb->status == STATUS_PENDING)
1508 iosb->status = status;
1509 iosb->out_size = min( iosb->out_size, get_req_data_size() );
1510 if (iosb->out_size)
1512 if ((iosb->out_data = memdup( get_req_data(), iosb->out_size )))
1514 iosb->result = iosb->out_size;
1516 else if (!status)
1518 iosb->status = STATUS_NO_MEMORY;
1519 iosb->out_size = 0;
1522 if (iosb->result) status = STATUS_ALERTED;
1524 else
1526 release_object( ioctl->async );
1527 ioctl->async = NULL;
1530 console_host_ioctl_terminate( ioctl, status );
1531 if (iosb) release_object( iosb );
1533 if (req->read)
1535 release_object( server );
1536 return;
1538 server->busy = 0;
1541 /* if we have a blocking read ioctl in queue head and previous blocking read is still waiting,
1542 * move it to read queue for execution after current read is complete. move all blocking
1543 * ioctl at the same time to preserve their order. */
1544 if (!list_empty( &server->queue ) && !list_empty( &server->read_queue ))
1546 ioctl = LIST_ENTRY( list_head( &server->queue ), struct console_host_ioctl, entry );
1547 if (is_blocking_read_ioctl( ioctl->code ))
1549 LIST_FOR_EACH_ENTRY_SAFE( ioctl, next, &server->queue, struct console_host_ioctl, entry )
1551 if (!is_blocking_read_ioctl( ioctl->code )) continue;
1552 list_remove( &ioctl->entry );
1553 list_add_tail( &server->read_queue, &ioctl->entry );
1558 /* return the next ioctl */
1559 if (!list_empty( &server->queue ))
1561 ioctl = LIST_ENTRY( list_head( &server->queue ), struct console_host_ioctl, entry );
1562 iosb = ioctl->async ? async_get_iosb( ioctl->async ) : NULL;
1564 if (!iosb || get_reply_max_size() >= iosb->in_size)
1566 reply->code = ioctl->code;
1567 reply->output = ioctl->output;
1569 if (iosb)
1571 reply->out_size = iosb->out_size;
1572 set_reply_data_ptr( iosb->in_data, iosb->in_size );
1573 iosb->in_data = NULL;
1576 if (is_blocking_read_ioctl( ioctl->code ))
1578 list_remove( &ioctl->entry );
1579 assert( list_empty( &server->read_queue ));
1580 list_add_tail( &server->read_queue, &ioctl->entry );
1582 else server->busy = 1;
1584 else
1586 reply->out_size = iosb->in_size;
1587 set_error( STATUS_BUFFER_OVERFLOW );
1589 if (iosb) release_object( iosb );
1591 else
1593 set_error( STATUS_PENDING );
1596 release_object( server );