diff options
Diffstat (limited to 'arch/um/os-Linux/start_up.c')
-rw-r--r-- | arch/um/os-Linux/start_up.c | 145 |
1 files changed, 0 insertions, 145 deletions
diff --git a/arch/um/os-Linux/start_up.c b/arch/um/os-Linux/start_up.c index 1244179e6c83..1540f21d6997 100644 --- a/arch/um/os-Linux/start_up.c +++ b/arch/um/os-Linux/start_up.c | |||
@@ -553,148 +553,3 @@ int __init parse_iomem(char *str, int *add) | |||
553 | out: | 553 | out: |
554 | return 1; | 554 | return 1; |
555 | } | 555 | } |
556 | |||
557 | |||
558 | /* Changed during early boot */ | ||
559 | int pty_output_sigio = 0; | ||
560 | int pty_close_sigio = 0; | ||
561 | |||
562 | /* Used as a flag during SIGIO testing early in boot */ | ||
563 | static volatile int got_sigio = 0; | ||
564 | |||
565 | static void __init handler(int sig) | ||
566 | { | ||
567 | got_sigio = 1; | ||
568 | } | ||
569 | |||
570 | struct openpty_arg { | ||
571 | int master; | ||
572 | int slave; | ||
573 | int err; | ||
574 | }; | ||
575 | |||
576 | static void openpty_cb(void *arg) | ||
577 | { | ||
578 | struct openpty_arg *info = arg; | ||
579 | |||
580 | info->err = 0; | ||
581 | if(openpty(&info->master, &info->slave, NULL, NULL, NULL)) | ||
582 | info->err = -errno; | ||
583 | } | ||
584 | |||
585 | static int async_pty(int master, int slave) | ||
586 | { | ||
587 | int flags; | ||
588 | |||
589 | flags = fcntl(master, F_GETFL); | ||
590 | if(flags < 0) | ||
591 | return -errno; | ||
592 | |||
593 | if((fcntl(master, F_SETFL, flags | O_NONBLOCK | O_ASYNC) < 0) || | ||
594 | (fcntl(master, F_SETOWN, os_getpid()) < 0)) | ||
595 | return -errno; | ||
596 | |||
597 | if((fcntl(slave, F_SETFL, flags | O_NONBLOCK) < 0)) | ||
598 | return -errno; | ||
599 | |||
600 | return(0); | ||
601 | } | ||
602 | |||
603 | static void __init check_one_sigio(void (*proc)(int, int)) | ||
604 | { | ||
605 | struct sigaction old, new; | ||
606 | struct openpty_arg pty = { .master = -1, .slave = -1 }; | ||
607 | int master, slave, err; | ||
608 | |||
609 | initial_thread_cb(openpty_cb, &pty); | ||
610 | if(pty.err){ | ||
611 | printk("openpty failed, errno = %d\n", -pty.err); | ||
612 | return; | ||
613 | } | ||
614 | |||
615 | master = pty.master; | ||
616 | slave = pty.slave; | ||
617 | |||
618 | if((master == -1) || (slave == -1)){ | ||
619 | printk("openpty failed to allocate a pty\n"); | ||
620 | return; | ||
621 | } | ||
622 | |||
623 | /* Not now, but complain so we now where we failed. */ | ||
624 | err = raw(master); | ||
625 | if (err < 0) | ||
626 | panic("check_sigio : __raw failed, errno = %d\n", -err); | ||
627 | |||
628 | err = async_pty(master, slave); | ||
629 | if(err < 0) | ||
630 | panic("tty_fds : sigio_async failed, err = %d\n", -err); | ||
631 | |||
632 | if(sigaction(SIGIO, NULL, &old) < 0) | ||
633 | panic("check_sigio : sigaction 1 failed, errno = %d\n", errno); | ||
634 | new = old; | ||
635 | new.sa_handler = handler; | ||
636 | if(sigaction(SIGIO, &new, NULL) < 0) | ||
637 | panic("check_sigio : sigaction 2 failed, errno = %d\n", errno); | ||
638 | |||
639 | got_sigio = 0; | ||
640 | (*proc)(master, slave); | ||
641 | |||
642 | close(master); | ||
643 | close(slave); | ||
644 | |||
645 | if(sigaction(SIGIO, &old, NULL) < 0) | ||
646 | panic("check_sigio : sigaction 3 failed, errno = %d\n", errno); | ||
647 | } | ||
648 | |||
649 | static void tty_output(int master, int slave) | ||
650 | { | ||
651 | int n; | ||
652 | char buf[512]; | ||
653 | |||
654 | printk("Checking that host ptys support output SIGIO..."); | ||
655 | |||
656 | memset(buf, 0, sizeof(buf)); | ||
657 | |||
658 | while(os_write_file(master, buf, sizeof(buf)) > 0) ; | ||
659 | if(errno != EAGAIN) | ||
660 | panic("check_sigio : write failed, errno = %d\n", errno); | ||
661 | while(((n = os_read_file(slave, buf, sizeof(buf))) > 0) && !got_sigio) ; | ||
662 | |||
663 | if(got_sigio){ | ||
664 | printk("Yes\n"); | ||
665 | pty_output_sigio = 1; | ||
666 | } | ||
667 | else if(n == -EAGAIN) printk("No, enabling workaround\n"); | ||
668 | else panic("check_sigio : read failed, err = %d\n", n); | ||
669 | } | ||
670 | |||
671 | static void tty_close(int master, int slave) | ||
672 | { | ||
673 | printk("Checking that host ptys support SIGIO on close..."); | ||
674 | |||
675 | close(slave); | ||
676 | if(got_sigio){ | ||
677 | printk("Yes\n"); | ||
678 | pty_close_sigio = 1; | ||
679 | } | ||
680 | else printk("No, enabling workaround\n"); | ||
681 | } | ||
682 | |||
683 | void __init check_sigio(void) | ||
684 | { | ||
685 | if((os_access("/dev/ptmx", OS_ACC_R_OK) < 0) && | ||
686 | (os_access("/dev/ptyp0", OS_ACC_R_OK) < 0)){ | ||
687 | printk("No pseudo-terminals available - skipping pty SIGIO " | ||
688 | "check\n"); | ||
689 | return; | ||
690 | } | ||
691 | check_one_sigio(tty_output); | ||
692 | check_one_sigio(tty_close); | ||
693 | } | ||
694 | |||
695 | void os_check_bugs(void) | ||
696 | { | ||
697 | check_ptrace(); | ||
698 | check_sigio(); | ||
699 | } | ||
700 | |||