static int set_termios(struct tty_struct * tty, unsigned long arg, int opt) { struct termios tmp_termios; int retval = tty_check_change(tty); if (retval) return retval; if (opt & TERMIOS_TERMIO) { memcpy(&tmp_termios, tty->termios, sizeof(struct termios)); if (user_termio_to_kernel_termios(&tmp_termios, (struct termio *) arg)) return -EFAULT; } else { if (user_termios_to_kernel_termios(&tmp_termios, (struct termios *) arg)) return -EFAULT; } if ((opt & TERMIOS_FLUSH) && tty->ldisc.flush_buffer) tty->ldisc.flush_buffer(tty); if (opt & TERMIOS_WAIT) { tty_wait_until_sent(tty, 0); if (signal_pending(current)) return -EINTR; } change_termios(tty, &tmp_termios); return 0; }
static int set_termios(struct tty_struct * tty, void __user *arg, int opt) { struct termios tmp_termios; struct tty_ldisc *ld; int retval = tty_check_change(tty); if (retval) return retval; if (opt & TERMIOS_TERMIO) { memcpy(&tmp_termios, tty->termios, sizeof(struct termios)); if (user_termio_to_kernel_termios(&tmp_termios, (struct termio __user *)arg)) return -EFAULT; } else { if (user_termios_to_kernel_termios(&tmp_termios, (struct termios __user *)arg)) return -EFAULT; } ld = tty_ldisc_ref(tty); if (ld != NULL) { if ((opt & TERMIOS_FLUSH) && ld->flush_buffer) ld->flush_buffer(tty); tty_ldisc_deref(ld); } if (opt & TERMIOS_WAIT) { tty_wait_until_sent(tty, 0); if (signal_pending(current)) return -EINTR; } change_termios(tty, &tmp_termios); return 0; }