blob: 8d4e0c6b8c92e085e697557f68e59b87af7afe23 [file] [log] [blame]
Jeff Dike8e367062006-03-27 01:14:32 -08001/*
Linus Torvalds1da177e2005-04-16 15:20:36 -07002 * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
3 * Licensed under the GPL
4 */
5
6#include <unistd.h>
7#include <stdlib.h>
8#include <termios.h>
9#include <pty.h>
10#include <signal.h>
Jeff Dikec65badb2007-05-06 14:51:06 -070011#include <fcntl.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070012#include <errno.h>
13#include <string.h>
14#include <sched.h>
15#include <sys/socket.h>
16#include <sys/poll.h>
17#include "init.h"
18#include "user.h"
19#include "kern_util.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070020#include "sigio.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070021#include "os.h"
Paolo 'Blaisorblade' Giarrussoc13e5692006-10-19 23:28:20 -070022#include "um_malloc.h"
Jeff Dikec65badb2007-05-06 14:51:06 -070023#include "init.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070024
Jeff Dikef206aab2006-03-27 01:14:33 -080025/* Protected by sigio_lock(), also used by sigio_cleanup, which is an
Linus Torvalds1da177e2005-04-16 15:20:36 -070026 * exitcall.
27 */
28static int write_sigio_pid = -1;
29
30/* These arrays are initialized before the sigio thread is started, and
31 * the descriptors closed after it is killed. So, it can't see them change.
32 * On the UML side, they are changed under the sigio_lock.
33 */
Jeff Dike5f4e8fd2006-03-27 01:14:40 -080034#define SIGIO_FDS_INIT {-1, -1}
35
36static int write_sigio_fds[2] = SIGIO_FDS_INIT;
37static int sigio_private[2] = SIGIO_FDS_INIT;
Linus Torvalds1da177e2005-04-16 15:20:36 -070038
39struct pollfds {
40 struct pollfd *poll;
41 int size;
42 int used;
43};
44
45/* Protected by sigio_lock(). Used by the sigio thread, but the UML thread
46 * synchronizes with it.
47 */
Jeff Dike19bdf042006-09-25 23:33:04 -070048static struct pollfds current_poll;
49static struct pollfds next_poll;
50static struct pollfds all_sigio_fds;
Linus Torvalds1da177e2005-04-16 15:20:36 -070051
52static int write_sigio_thread(void *unused)
53{
54 struct pollfds *fds, tmp;
55 struct pollfd *p;
56 int i, n, respond_fd;
57 char c;
58
Jeff Dikecd2ee4a2005-05-05 16:15:32 -070059 signal(SIGWINCH, SIG_IGN);
Linus Torvalds1da177e2005-04-16 15:20:36 -070060 fds = &current_poll;
61 while(1){
62 n = poll(fds->poll, fds->used, -1);
63 if(n < 0){
64 if(errno == EINTR) continue;
65 printk("write_sigio_thread : poll returned %d, "
66 "errno = %d\n", n, errno);
67 }
68 for(i = 0; i < fds->used; i++){
69 p = &fds->poll[i];
70 if(p->revents == 0) continue;
71 if(p->fd == sigio_private[1]){
Jeff Dikea61f3342007-05-06 14:51:35 -070072 CATCH_EINTR(n = read(sigio_private[1], &c,
73 sizeof(c)));
Linus Torvalds1da177e2005-04-16 15:20:36 -070074 if(n != sizeof(c))
75 printk("write_sigio_thread : "
Jeff Dike19bdf042006-09-25 23:33:04 -070076 "read on socket failed, "
Jeff Dikea61f3342007-05-06 14:51:35 -070077 "err = %d\n", errno);
Linus Torvalds1da177e2005-04-16 15:20:36 -070078 tmp = current_poll;
79 current_poll = next_poll;
80 next_poll = tmp;
81 respond_fd = sigio_private[1];
82 }
83 else {
84 respond_fd = write_sigio_fds[1];
85 fds->used--;
86 memmove(&fds->poll[i], &fds->poll[i + 1],
87 (fds->used - i) * sizeof(*fds->poll));
88 }
89
Jeff Dikea61f3342007-05-06 14:51:35 -070090 CATCH_EINTR(n = write(respond_fd, &c, sizeof(c)));
Linus Torvalds1da177e2005-04-16 15:20:36 -070091 if(n != sizeof(c))
Jeff Dike19bdf042006-09-25 23:33:04 -070092 printk("write_sigio_thread : write on socket "
Jeff Dikea61f3342007-05-06 14:51:35 -070093 "failed, err = %d\n", errno);
Linus Torvalds1da177e2005-04-16 15:20:36 -070094 }
95 }
Jeff Dike1b57e9c2006-01-06 00:18:49 -080096
97 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -070098}
99
Jeff Dike19bdf042006-09-25 23:33:04 -0700100static int need_poll(struct pollfds *polls, int n)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700101{
Jeff Dike838e56a2007-02-16 01:27:21 -0800102 struct pollfd *new;
103
104 if(n <= polls->size)
Jeff Dike19bdf042006-09-25 23:33:04 -0700105 return 0;
Jeff Dike838e56a2007-02-16 01:27:21 -0800106
107 new = um_kmalloc_atomic(n * sizeof(struct pollfd));
108 if(new == NULL){
Linus Torvalds1da177e2005-04-16 15:20:36 -0700109 printk("need_poll : failed to allocate new pollfds\n");
Jeff Dike19bdf042006-09-25 23:33:04 -0700110 return -ENOMEM;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700111 }
Jeff Dike838e56a2007-02-16 01:27:21 -0800112
113 memcpy(new, polls->poll, polls->used * sizeof(struct pollfd));
114 kfree(polls->poll);
115
116 polls->poll = new;
Jeff Dike19bdf042006-09-25 23:33:04 -0700117 polls->size = n;
Jeff Dike19bdf042006-09-25 23:33:04 -0700118 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700119}
120
121/* Must be called with sigio_lock held, because it's needed by the marked
Jeff Dike19bdf042006-09-25 23:33:04 -0700122 * critical section.
123 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700124static void update_thread(void)
125{
126 unsigned long flags;
127 int n;
128 char c;
129
130 flags = set_signals(0);
Jeff Dikea61f3342007-05-06 14:51:35 -0700131 n = write(sigio_private[0], &c, sizeof(c));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700132 if(n != sizeof(c)){
Jeff Dikea61f3342007-05-06 14:51:35 -0700133 printk("update_thread : write failed, err = %d\n", errno);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700134 goto fail;
135 }
136
Jeff Dikea61f3342007-05-06 14:51:35 -0700137 CATCH_EINTR(n = read(sigio_private[0], &c, sizeof(c)));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700138 if(n != sizeof(c)){
Jeff Dikea61f3342007-05-06 14:51:35 -0700139 printk("update_thread : read failed, err = %d\n", errno);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700140 goto fail;
141 }
142
143 set_signals(flags);
144 return;
145 fail:
146 /* Critical section start */
Jeff Dikef206aab2006-03-27 01:14:33 -0800147 if(write_sigio_pid != -1)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700148 os_kill_process(write_sigio_pid, 1);
149 write_sigio_pid = -1;
Jeff Dike8e367062006-03-27 01:14:32 -0800150 close(sigio_private[0]);
151 close(sigio_private[1]);
152 close(write_sigio_fds[0]);
153 close(write_sigio_fds[1]);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700154 /* Critical section end */
155 set_signals(flags);
156}
157
Jeff Dike19bdf042006-09-25 23:33:04 -0700158int add_sigio_fd(int fd)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700159{
Jeff Dike19bdf042006-09-25 23:33:04 -0700160 struct pollfd *p;
161 int err = 0, i, n;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700162
163 sigio_lock();
Jeff Dike19bdf042006-09-25 23:33:04 -0700164 for(i = 0; i < all_sigio_fds.used; i++){
165 if(all_sigio_fds.poll[i].fd == fd)
166 break;
167 }
168 if(i == all_sigio_fds.used)
169 goto out;
170
171 p = &all_sigio_fds.poll[i];
172
Linus Torvalds1da177e2005-04-16 15:20:36 -0700173 for(i = 0; i < current_poll.used; i++){
Jeff Dikef206aab2006-03-27 01:14:33 -0800174 if(current_poll.poll[i].fd == fd)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700175 goto out;
176 }
177
Jeff Dike838e56a2007-02-16 01:27:21 -0800178 n = current_poll.used;
179 err = need_poll(&next_poll, n + 1);
Jeff Dikef206aab2006-03-27 01:14:33 -0800180 if(err)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700181 goto out;
182
Jeff Dike838e56a2007-02-16 01:27:21 -0800183 memcpy(next_poll.poll, current_poll.poll,
184 current_poll.used * sizeof(struct pollfd));
185 next_poll.poll[n] = *p;
186 next_poll.used = n + 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700187 update_thread();
188 out:
189 sigio_unlock();
Jeff Dike19bdf042006-09-25 23:33:04 -0700190 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700191}
192
193int ignore_sigio_fd(int fd)
194{
195 struct pollfd *p;
196 int err = 0, i, n = 0;
197
Jeff Dike61232f22006-07-10 04:45:11 -0700198 /* This is called from exitcalls elsewhere in UML - if
199 * sigio_cleanup has already run, then update_thread will hang
200 * or fail because the thread is no longer running.
201 */
202 if(write_sigio_pid == -1)
203 return -EIO;
204
Linus Torvalds1da177e2005-04-16 15:20:36 -0700205 sigio_lock();
206 for(i = 0; i < current_poll.used; i++){
207 if(current_poll.poll[i].fd == fd) break;
208 }
209 if(i == current_poll.used)
210 goto out;
Jeff Dikef206aab2006-03-27 01:14:33 -0800211
Jeff Dike19bdf042006-09-25 23:33:04 -0700212 err = need_poll(&next_poll, current_poll.used - 1);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700213 if(err)
214 goto out;
215
216 for(i = 0; i < current_poll.used; i++){
217 p = &current_poll.poll[i];
Jeff Dike19bdf042006-09-25 23:33:04 -0700218 if(p->fd != fd)
219 next_poll.poll[n++] = *p;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700220 }
Jeff Dike838e56a2007-02-16 01:27:21 -0800221 next_poll.used = current_poll.used - 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700222
223 update_thread();
224 out:
225 sigio_unlock();
Jeff Dike61232f22006-07-10 04:45:11 -0700226 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700227}
228
Jeff Dikef206aab2006-03-27 01:14:33 -0800229static struct pollfd *setup_initial_poll(int fd)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700230{
231 struct pollfd *p;
232
Paolo 'Blaisorblade' Giarrussob6a2b132006-01-18 17:42:57 -0800233 p = um_kmalloc(sizeof(struct pollfd));
234 if (p == NULL) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700235 printk("setup_initial_poll : failed to allocate poll\n");
Paolo 'Blaisorblade' Giarrussob6a2b132006-01-18 17:42:57 -0800236 return NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700237 }
Jeff Dike19bdf042006-09-25 23:33:04 -0700238 *p = ((struct pollfd) { .fd = fd,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700239 .events = POLLIN,
240 .revents = 0 });
Paolo 'Blaisorblade' Giarrussob6a2b132006-01-18 17:42:57 -0800241 return p;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700242}
243
Jeff Dike8e64d96a2006-07-10 04:45:11 -0700244static void write_sigio_workaround(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700245{
246 unsigned long stack;
Paolo 'Blaisorblade' Giarrussob6a2b132006-01-18 17:42:57 -0800247 struct pollfd *p;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700248 int err;
Paolo 'Blaisorblade' Giarrussob6a2b132006-01-18 17:42:57 -0800249 int l_write_sigio_fds[2];
250 int l_sigio_private[2];
251 int l_write_sigio_pid;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700252
Paolo 'Blaisorblade' Giarrussob6a2b132006-01-18 17:42:57 -0800253 /* We call this *tons* of times - and most ones we must just fail. */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700254 sigio_lock();
Paolo 'Blaisorblade' Giarrussob6a2b132006-01-18 17:42:57 -0800255 l_write_sigio_pid = write_sigio_pid;
256 sigio_unlock();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700257
Paolo 'Blaisorblade' Giarrussob6a2b132006-01-18 17:42:57 -0800258 if (l_write_sigio_pid != -1)
259 return;
260
261 err = os_pipe(l_write_sigio_fds, 1, 1);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700262 if(err < 0){
263 printk("write_sigio_workaround - os_pipe 1 failed, "
264 "err = %d\n", -err);
Paolo 'Blaisorblade' Giarrussob6a2b132006-01-18 17:42:57 -0800265 return;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700266 }
Paolo 'Blaisorblade' Giarrussob6a2b132006-01-18 17:42:57 -0800267 err = os_pipe(l_sigio_private, 1, 1);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700268 if(err < 0){
Jeff Dikef206aab2006-03-27 01:14:33 -0800269 printk("write_sigio_workaround - os_pipe 2 failed, "
Linus Torvalds1da177e2005-04-16 15:20:36 -0700270 "err = %d\n", -err);
271 goto out_close1;
272 }
Paolo 'Blaisorblade' Giarrussob6a2b132006-01-18 17:42:57 -0800273
274 p = setup_initial_poll(l_sigio_private[1]);
275 if(!p)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700276 goto out_close2;
277
Paolo 'Blaisorblade' Giarrussob6a2b132006-01-18 17:42:57 -0800278 sigio_lock();
279
280 /* Did we race? Don't try to optimize this, please, it's not so likely
281 * to happen, and no more than once at the boot. */
282 if(write_sigio_pid != -1)
Jeff Dike5f4e8fd2006-03-27 01:14:40 -0800283 goto out_free;
284
285 current_poll = ((struct pollfds) { .poll = p,
286 .used = 1,
287 .size = 1 });
288
289 if (write_sigio_irq(l_write_sigio_fds[0]))
290 goto out_clear_poll;
291
292 memcpy(write_sigio_fds, l_write_sigio_fds, sizeof(l_write_sigio_fds));
293 memcpy(sigio_private, l_sigio_private, sizeof(l_sigio_private));
Paolo 'Blaisorblade' Giarrussob6a2b132006-01-18 17:42:57 -0800294
295 write_sigio_pid = run_helper_thread(write_sigio_thread, NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700296 CLONE_FILES | CLONE_VM, &stack, 0);
297
Paolo 'Blaisorblade' Giarrussob6a2b132006-01-18 17:42:57 -0800298 if (write_sigio_pid < 0)
299 goto out_clear;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700300
Linus Torvalds1da177e2005-04-16 15:20:36 -0700301 sigio_unlock();
302 return;
303
Jeff Dike5f4e8fd2006-03-27 01:14:40 -0800304out_clear:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700305 write_sigio_pid = -1;
Jeff Dike5f4e8fd2006-03-27 01:14:40 -0800306 write_sigio_fds[0] = -1;
307 write_sigio_fds[1] = -1;
308 sigio_private[0] = -1;
309 sigio_private[1] = -1;
310out_clear_poll:
311 current_poll = ((struct pollfds) { .poll = NULL,
312 .size = 0,
313 .used = 0 });
314out_free:
Jeff Dike5f4e8fd2006-03-27 01:14:40 -0800315 sigio_unlock();
Paolo 'Blaisorblade' Giarrussoe6fb54a2006-04-10 22:53:36 -0700316 kfree(p);
Jeff Dike5f4e8fd2006-03-27 01:14:40 -0800317out_close2:
Jeff Dike8e367062006-03-27 01:14:32 -0800318 close(l_sigio_private[0]);
319 close(l_sigio_private[1]);
Jeff Dike5f4e8fd2006-03-27 01:14:40 -0800320out_close1:
Jeff Dike8e367062006-03-27 01:14:32 -0800321 close(l_write_sigio_fds[0]);
322 close(l_write_sigio_fds[1]);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700323}
324
Jeff Dikec65badb2007-05-06 14:51:06 -0700325/* Changed during early boot */
326static int pty_output_sigio = 0;
327static int pty_close_sigio = 0;
328
Jeff Dike8e64d96a2006-07-10 04:45:11 -0700329void maybe_sigio_broken(int fd, int read)
330{
Jeff Dike19bdf042006-09-25 23:33:04 -0700331 int err;
332
Jeff Dike8e64d96a2006-07-10 04:45:11 -0700333 if(!isatty(fd))
334 return;
335
336 if((read || pty_output_sigio) && (!read || pty_close_sigio))
337 return;
338
339 write_sigio_workaround();
Jeff Dike19bdf042006-09-25 23:33:04 -0700340
341 sigio_lock();
342 err = need_poll(&all_sigio_fds, all_sigio_fds.used + 1);
Jeff Dike04a51e62007-02-28 20:13:11 -0800343 if(err){
344 printk("maybe_sigio_broken - failed to add pollfd for "
345 "descriptor %d\n", fd);
Jeff Dike19bdf042006-09-25 23:33:04 -0700346 goto out;
Jeff Dike04a51e62007-02-28 20:13:11 -0800347 }
Jeff Dike838e56a2007-02-16 01:27:21 -0800348
Jeff Dike19bdf042006-09-25 23:33:04 -0700349 all_sigio_fds.poll[all_sigio_fds.used++] =
350 ((struct pollfd) { .fd = fd,
351 .events = read ? POLLIN : POLLOUT,
352 .revents = 0 });
353out:
354 sigio_unlock();
Jeff Dike8e64d96a2006-07-10 04:45:11 -0700355}
356
Jeff Dike29ac1c22006-07-10 04:45:12 -0700357static void sigio_cleanup(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700358{
Jeff Dikef206aab2006-03-27 01:14:33 -0800359 if(write_sigio_pid != -1){
Linus Torvalds1da177e2005-04-16 15:20:36 -0700360 os_kill_process(write_sigio_pid, 1);
361 write_sigio_pid = -1;
362 }
363}
Jeff Dike29ac1c22006-07-10 04:45:12 -0700364
365__uml_exitcall(sigio_cleanup);
Jeff Dikec65badb2007-05-06 14:51:06 -0700366
367/* Used as a flag during SIGIO testing early in boot */
368static volatile int got_sigio = 0;
369
370static void __init handler(int sig)
371{
372 got_sigio = 1;
373}
374
375struct openpty_arg {
376 int master;
377 int slave;
378 int err;
379};
380
381static void openpty_cb(void *arg)
382{
383 struct openpty_arg *info = arg;
384
385 info->err = 0;
386 if(openpty(&info->master, &info->slave, NULL, NULL, NULL))
387 info->err = -errno;
388}
389
390static int async_pty(int master, int slave)
391{
392 int flags;
393
394 flags = fcntl(master, F_GETFL);
395 if(flags < 0)
396 return -errno;
397
398 if((fcntl(master, F_SETFL, flags | O_NONBLOCK | O_ASYNC) < 0) ||
399 (fcntl(master, F_SETOWN, os_getpid()) < 0))
400 return -errno;
401
402 if((fcntl(slave, F_SETFL, flags | O_NONBLOCK) < 0))
403 return -errno;
404
405 return(0);
406}
407
408static void __init check_one_sigio(void (*proc)(int, int))
409{
410 struct sigaction old, new;
411 struct openpty_arg pty = { .master = -1, .slave = -1 };
412 int master, slave, err;
413
414 initial_thread_cb(openpty_cb, &pty);
415 if(pty.err){
416 printk("openpty failed, errno = %d\n", -pty.err);
417 return;
418 }
419
420 master = pty.master;
421 slave = pty.slave;
422
423 if((master == -1) || (slave == -1)){
424 printk("openpty failed to allocate a pty\n");
425 return;
426 }
427
428 /* Not now, but complain so we now where we failed. */
429 err = raw(master);
430 if (err < 0)
431 panic("check_sigio : __raw failed, errno = %d\n", -err);
432
433 err = async_pty(master, slave);
434 if(err < 0)
435 panic("tty_fds : sigio_async failed, err = %d\n", -err);
436
437 if(sigaction(SIGIO, NULL, &old) < 0)
438 panic("check_sigio : sigaction 1 failed, errno = %d\n", errno);
439 new = old;
440 new.sa_handler = handler;
441 if(sigaction(SIGIO, &new, NULL) < 0)
442 panic("check_sigio : sigaction 2 failed, errno = %d\n", errno);
443
444 got_sigio = 0;
445 (*proc)(master, slave);
446
447 close(master);
448 close(slave);
449
450 if(sigaction(SIGIO, &old, NULL) < 0)
451 panic("check_sigio : sigaction 3 failed, errno = %d\n", errno);
452}
453
454static void tty_output(int master, int slave)
455{
456 int n;
457 char buf[512];
458
459 printk("Checking that host ptys support output SIGIO...");
460
461 memset(buf, 0, sizeof(buf));
462
Jeff Dikea61f3342007-05-06 14:51:35 -0700463 while(write(master, buf, sizeof(buf)) > 0) ;
Jeff Dikec65badb2007-05-06 14:51:06 -0700464 if(errno != EAGAIN)
Jeff Dikeef0470c2007-05-06 14:51:33 -0700465 panic("tty_output : write failed, errno = %d\n", errno);
Jeff Dikea61f3342007-05-06 14:51:35 -0700466 while(((n = read(slave, buf, sizeof(buf))) > 0) && !got_sigio) ;
Jeff Dikec65badb2007-05-06 14:51:06 -0700467
468 if(got_sigio){
469 printk("Yes\n");
470 pty_output_sigio = 1;
471 }
Jeff Dikeef0470c2007-05-06 14:51:33 -0700472 else if(n == -EAGAIN)
473 printk("No, enabling workaround\n");
474 else panic("tty_output : read failed, err = %d\n", n);
Jeff Dikec65badb2007-05-06 14:51:06 -0700475}
476
477static void tty_close(int master, int slave)
478{
479 printk("Checking that host ptys support SIGIO on close...");
480
481 close(slave);
482 if(got_sigio){
483 printk("Yes\n");
484 pty_close_sigio = 1;
485 }
486 else printk("No, enabling workaround\n");
487}
488
489void __init check_sigio(void)
490{
491 if((os_access("/dev/ptmx", OS_ACC_R_OK) < 0) &&
492 (os_access("/dev/ptyp0", OS_ACC_R_OK) < 0)){
493 printk("No pseudo-terminals available - skipping pty SIGIO "
494 "check\n");
495 return;
496 }
497 check_one_sigio(tty_output);
498 check_one_sigio(tty_close);
499}
500
501/* Here because it only does the SIGIO testing for now */
502void __init os_check_bugs(void)
503{
504 check_sigio();
505}