• Home
  • Raw
  • Download

Lines Matching refs:tty

158 static void zero_buffer(struct tty_struct *tty, u8 *buffer, int size)  in zero_buffer()  argument
160 bool icanon = !!L_ICANON(tty); in zero_buffer()
161 bool no_echo = !L_ECHO(tty); in zero_buffer()
167 static int tty_copy_to_user(struct tty_struct *tty, void __user *to, in tty_copy_to_user() argument
170 struct n_tty_data *ldata = tty->disc_data; in tty_copy_to_user()
176 tty_audit_add_data(tty, from, size); in tty_copy_to_user()
178 zero_buffer(tty, from, size - uncopied); in tty_copy_to_user()
186 tty_audit_add_data(tty, from, n); in tty_copy_to_user()
188 zero_buffer(tty, from, n - uncopied); in tty_copy_to_user()
204 static void n_tty_kick_worker(struct tty_struct *tty) in n_tty_kick_worker() argument
206 struct n_tty_data *ldata = tty->disc_data; in n_tty_kick_worker()
212 WARN_RATELIMIT(tty->port->itty == NULL, in n_tty_kick_worker()
218 WARN_RATELIMIT(test_bit(TTY_LDISC_HALTED, &tty->flags), in n_tty_kick_worker()
220 tty_buffer_restart_work(tty->port); in n_tty_kick_worker()
224 static ssize_t chars_in_buffer(struct tty_struct *tty) in chars_in_buffer() argument
226 struct n_tty_data *ldata = tty->disc_data; in chars_in_buffer()
245 static void n_tty_write_wakeup(struct tty_struct *tty) in n_tty_write_wakeup() argument
247 clear_bit(TTY_DO_WRITE_WAKEUP, &tty->flags); in n_tty_write_wakeup()
248 kill_fasync(&tty->fasync, SIGIO, POLL_OUT); in n_tty_write_wakeup()
251 static void n_tty_check_throttle(struct tty_struct *tty) in n_tty_check_throttle() argument
253 struct n_tty_data *ldata = tty->disc_data; in n_tty_check_throttle()
265 tty_set_flow_change(tty, TTY_THROTTLE_SAFE); in n_tty_check_throttle()
268 throttled = tty_throttle_safe(tty); in n_tty_check_throttle()
272 __tty_set_flow_change(tty, 0); in n_tty_check_throttle()
275 static void n_tty_check_unthrottle(struct tty_struct *tty) in n_tty_check_unthrottle() argument
277 if (tty->driver->type == TTY_DRIVER_TYPE_PTY) { in n_tty_check_unthrottle()
278 if (chars_in_buffer(tty) > TTY_THRESHOLD_UNTHROTTLE) in n_tty_check_unthrottle()
280 n_tty_kick_worker(tty); in n_tty_check_unthrottle()
281 tty_wakeup(tty->link); in n_tty_check_unthrottle()
295 tty_set_flow_change(tty, TTY_UNTHROTTLE_SAFE); in n_tty_check_unthrottle()
296 if (chars_in_buffer(tty) > TTY_THRESHOLD_UNTHROTTLE) in n_tty_check_unthrottle()
298 n_tty_kick_worker(tty); in n_tty_check_unthrottle()
299 unthrottled = tty_unthrottle_safe(tty); in n_tty_check_unthrottle()
303 __tty_set_flow_change(tty, 0); in n_tty_check_unthrottle()
345 static void n_tty_packet_mode_flush(struct tty_struct *tty) in n_tty_packet_mode_flush() argument
349 if (tty->link->packet) { in n_tty_packet_mode_flush()
350 spin_lock_irqsave(&tty->ctrl_lock, flags); in n_tty_packet_mode_flush()
351 tty->ctrl_status |= TIOCPKT_FLUSHREAD; in n_tty_packet_mode_flush()
352 spin_unlock_irqrestore(&tty->ctrl_lock, flags); in n_tty_packet_mode_flush()
353 wake_up_interruptible(&tty->link->read_wait); in n_tty_packet_mode_flush()
371 static void n_tty_flush_buffer(struct tty_struct *tty) in n_tty_flush_buffer() argument
373 down_write(&tty->termios_rwsem); in n_tty_flush_buffer()
374 reset_buffer_flags(tty->disc_data); in n_tty_flush_buffer()
375 n_tty_kick_worker(tty); in n_tty_flush_buffer()
377 if (tty->link) in n_tty_flush_buffer()
378 n_tty_packet_mode_flush(tty); in n_tty_flush_buffer()
379 up_write(&tty->termios_rwsem); in n_tty_flush_buffer()
404 static inline int is_continuation(unsigned char c, struct tty_struct *tty) in is_continuation() argument
406 return I_IUTF8(tty) && is_utf8_continuation(c); in is_continuation()
431 static int do_output_char(unsigned char c, struct tty_struct *tty, int space) in do_output_char() argument
433 struct n_tty_data *ldata = tty->disc_data; in do_output_char()
441 if (O_ONLRET(tty)) in do_output_char()
443 if (O_ONLCR(tty)) { in do_output_char()
447 tty->ops->write(tty, "\r\n", 2); in do_output_char()
453 if (O_ONOCR(tty) && ldata->column == 0) in do_output_char()
455 if (O_OCRNL(tty)) { in do_output_char()
457 if (O_ONLRET(tty)) in do_output_char()
465 if (O_TABDLY(tty) == XTABS) { in do_output_char()
469 tty->ops->write(tty, " ", spaces); in do_output_char()
480 if (O_OLCUC(tty)) in do_output_char()
482 if (!is_continuation(c, tty)) in do_output_char()
488 tty_put_char(tty, c); in do_output_char()
506 static int process_output(unsigned char c, struct tty_struct *tty) in process_output() argument
508 struct n_tty_data *ldata = tty->disc_data; in process_output()
513 space = tty_write_room(tty); in process_output()
514 retval = do_output_char(c, tty, space); in process_output()
542 static ssize_t process_output_block(struct tty_struct *tty, in process_output_block() argument
545 struct n_tty_data *ldata = tty->disc_data; in process_output_block()
552 space = tty_write_room(tty); in process_output_block()
565 if (O_ONLRET(tty)) in process_output_block()
567 if (O_ONLCR(tty)) in process_output_block()
572 if (O_ONOCR(tty) && ldata->column == 0) in process_output_block()
574 if (O_OCRNL(tty)) in process_output_block()
586 if (O_OLCUC(tty)) in process_output_block()
588 if (!is_continuation(c, tty)) in process_output_block()
595 i = tty->ops->write(tty, buf, i); in process_output_block()
626 static size_t __process_echoes(struct tty_struct *tty) in __process_echoes() argument
628 struct n_tty_data *ldata = tty->disc_data; in __process_echoes()
633 old_space = space = tty_write_room(tty); in __process_echoes()
684 tty_put_char(tty, '\b'); in __process_echoes()
708 tty_put_char(tty, ECHO_OP_START); in __process_echoes()
728 tty_put_char(tty, '^'); in __process_echoes()
729 tty_put_char(tty, op ^ 0100); in __process_echoes()
738 if (O_OPOST(tty)) { in __process_echoes()
739 int retval = do_output_char(c, tty, space); in __process_echoes()
746 tty_put_char(tty, c); in __process_echoes()
772 static void commit_echoes(struct tty_struct *tty) in commit_echoes() argument
774 struct n_tty_data *ldata = tty->disc_data; in commit_echoes()
794 echoed = __process_echoes(tty); in commit_echoes()
797 if (echoed && tty->ops->flush_chars) in commit_echoes()
798 tty->ops->flush_chars(tty); in commit_echoes()
801 static void process_echoes(struct tty_struct *tty) in process_echoes() argument
803 struct n_tty_data *ldata = tty->disc_data; in process_echoes()
811 echoed = __process_echoes(tty); in process_echoes()
814 if (echoed && tty->ops->flush_chars) in process_echoes()
815 tty->ops->flush_chars(tty); in process_echoes()
819 static void flush_echoes(struct tty_struct *tty) in flush_echoes() argument
821 struct n_tty_data *ldata = tty->disc_data; in flush_echoes()
823 if ((!L_ECHO(tty) && !L_ECHONL(tty)) || in flush_echoes()
829 __process_echoes(tty); in flush_echoes()
939 static void echo_char(unsigned char c, struct tty_struct *tty) in echo_char() argument
941 struct n_tty_data *ldata = tty->disc_data; in echo_char()
947 if (L_ECHOCTL(tty) && iscntrl(c) && c != '\t') in echo_char()
979 static void eraser(unsigned char c, struct tty_struct *tty) in eraser() argument
981 struct n_tty_data *ldata = tty->disc_data; in eraser()
991 if (c == ERASE_CHAR(tty)) in eraser()
993 else if (c == WERASE_CHAR(tty)) in eraser()
996 if (!L_ECHO(tty)) { in eraser()
1000 if (!L_ECHOK(tty) || !L_ECHOKE(tty) || !L_ECHOE(tty)) { in eraser()
1003 echo_char(KILL_CHAR(tty), tty); in eraser()
1005 if (L_ECHOK(tty)) in eraser()
1020 } while (is_continuation(c, tty) && in eraser()
1024 if (is_continuation(c, tty)) in eraser()
1036 if (L_ECHO(tty)) { in eraser()
1037 if (L_ECHOPRT(tty)) { in eraser()
1043 echo_char(c, tty); in eraser()
1049 } else if (kill_type == ERASE && !L_ECHOE(tty)) { in eraser()
1050 echo_char(ERASE_CHAR(tty), tty); in eraser()
1070 if (L_ECHOCTL(tty)) in eraser()
1072 } else if (!is_continuation(c, tty)) { in eraser()
1078 if (iscntrl(c) && L_ECHOCTL(tty)) { in eraser()
1083 if (!iscntrl(c) || L_ECHOCTL(tty)) { in eraser()
1093 if (ldata->read_head == ldata->canon_head && L_ECHO(tty)) in eraser()
1112 static void __isig(int sig, struct tty_struct *tty) in __isig() argument
1114 struct pid *tty_pgrp = tty_get_pgrp(tty); in __isig()
1121 static void isig(int sig, struct tty_struct *tty) in isig() argument
1123 struct n_tty_data *ldata = tty->disc_data; in isig()
1125 if (L_NOFLSH(tty)) { in isig()
1127 __isig(sig, tty); in isig()
1130 up_read(&tty->termios_rwsem); in isig()
1131 down_write(&tty->termios_rwsem); in isig()
1133 __isig(sig, tty); in isig()
1142 tty_driver_flush_buffer(tty); in isig()
1145 reset_buffer_flags(tty->disc_data); in isig()
1148 if (tty->link) in isig()
1149 n_tty_packet_mode_flush(tty); in isig()
1151 up_write(&tty->termios_rwsem); in isig()
1152 down_read(&tty->termios_rwsem); in isig()
1169 static void n_tty_receive_break(struct tty_struct *tty) in n_tty_receive_break() argument
1171 struct n_tty_data *ldata = tty->disc_data; in n_tty_receive_break()
1173 if (I_IGNBRK(tty)) in n_tty_receive_break()
1175 if (I_BRKINT(tty)) { in n_tty_receive_break()
1176 isig(SIGINT, tty); in n_tty_receive_break()
1179 if (I_PARMRK(tty)) { in n_tty_receive_break()
1199 static void n_tty_receive_overrun(struct tty_struct *tty) in n_tty_receive_overrun() argument
1201 struct n_tty_data *ldata = tty->disc_data; in n_tty_receive_overrun()
1206 tty_warn(tty, "%d input overrun(s)\n", ldata->num_overrun); in n_tty_receive_overrun()
1223 static void n_tty_receive_parity_error(struct tty_struct *tty, unsigned char c) in n_tty_receive_parity_error() argument
1225 struct n_tty_data *ldata = tty->disc_data; in n_tty_receive_parity_error()
1227 if (I_INPCK(tty)) { in n_tty_receive_parity_error()
1228 if (I_IGNPAR(tty)) in n_tty_receive_parity_error()
1230 if (I_PARMRK(tty)) { in n_tty_receive_parity_error()
1241 n_tty_receive_signal_char(struct tty_struct *tty, int signal, unsigned char c) in n_tty_receive_signal_char() argument
1243 isig(signal, tty); in n_tty_receive_signal_char()
1244 if (I_IXON(tty)) in n_tty_receive_signal_char()
1245 start_tty(tty); in n_tty_receive_signal_char()
1246 if (L_ECHO(tty)) { in n_tty_receive_signal_char()
1247 echo_char(c, tty); in n_tty_receive_signal_char()
1248 commit_echoes(tty); in n_tty_receive_signal_char()
1250 process_echoes(tty); in n_tty_receive_signal_char()
1271 n_tty_receive_char_special(struct tty_struct *tty, unsigned char c) in n_tty_receive_char_special() argument
1273 struct n_tty_data *ldata = tty->disc_data; in n_tty_receive_char_special()
1275 if (I_IXON(tty)) { in n_tty_receive_char_special()
1276 if (c == START_CHAR(tty)) { in n_tty_receive_char_special()
1277 start_tty(tty); in n_tty_receive_char_special()
1278 process_echoes(tty); in n_tty_receive_char_special()
1281 if (c == STOP_CHAR(tty)) { in n_tty_receive_char_special()
1282 stop_tty(tty); in n_tty_receive_char_special()
1287 if (L_ISIG(tty)) { in n_tty_receive_char_special()
1288 if (c == INTR_CHAR(tty)) { in n_tty_receive_char_special()
1289 n_tty_receive_signal_char(tty, SIGINT, c); in n_tty_receive_char_special()
1291 } else if (c == QUIT_CHAR(tty)) { in n_tty_receive_char_special()
1292 n_tty_receive_signal_char(tty, SIGQUIT, c); in n_tty_receive_char_special()
1294 } else if (c == SUSP_CHAR(tty)) { in n_tty_receive_char_special()
1295 n_tty_receive_signal_char(tty, SIGTSTP, c); in n_tty_receive_char_special()
1300 if (tty->stopped && !tty->flow_stopped && I_IXON(tty) && I_IXANY(tty)) { in n_tty_receive_char_special()
1301 start_tty(tty); in n_tty_receive_char_special()
1302 process_echoes(tty); in n_tty_receive_char_special()
1306 if (I_IGNCR(tty)) in n_tty_receive_char_special()
1308 if (I_ICRNL(tty)) in n_tty_receive_char_special()
1310 } else if (c == '\n' && I_INLCR(tty)) in n_tty_receive_char_special()
1314 if (c == ERASE_CHAR(tty) || c == KILL_CHAR(tty) || in n_tty_receive_char_special()
1315 (c == WERASE_CHAR(tty) && L_IEXTEN(tty))) { in n_tty_receive_char_special()
1316 eraser(c, tty); in n_tty_receive_char_special()
1317 commit_echoes(tty); in n_tty_receive_char_special()
1320 if (c == LNEXT_CHAR(tty) && L_IEXTEN(tty)) { in n_tty_receive_char_special()
1322 if (L_ECHO(tty)) { in n_tty_receive_char_special()
1324 if (L_ECHOCTL(tty)) { in n_tty_receive_char_special()
1327 commit_echoes(tty); in n_tty_receive_char_special()
1332 if (c == REPRINT_CHAR(tty) && L_ECHO(tty) && L_IEXTEN(tty)) { in n_tty_receive_char_special()
1336 echo_char(c, tty); in n_tty_receive_char_special()
1339 echo_char(read_buf(ldata, tail), tty); in n_tty_receive_char_special()
1342 commit_echoes(tty); in n_tty_receive_char_special()
1346 if (L_ECHO(tty) || L_ECHONL(tty)) { in n_tty_receive_char_special()
1348 commit_echoes(tty); in n_tty_receive_char_special()
1352 if (c == EOF_CHAR(tty)) { in n_tty_receive_char_special()
1356 if ((c == EOL_CHAR(tty)) || in n_tty_receive_char_special()
1357 (c == EOL2_CHAR(tty) && L_IEXTEN(tty))) { in n_tty_receive_char_special()
1361 if (L_ECHO(tty)) { in n_tty_receive_char_special()
1365 echo_char(c, tty); in n_tty_receive_char_special()
1366 commit_echoes(tty); in n_tty_receive_char_special()
1372 if (c == (unsigned char) '\377' && I_PARMRK(tty)) in n_tty_receive_char_special()
1379 kill_fasync(&tty->fasync, SIGIO, POLL_IN); in n_tty_receive_char_special()
1380 wake_up_interruptible_poll(&tty->read_wait, EPOLLIN); in n_tty_receive_char_special()
1385 if (L_ECHO(tty)) { in n_tty_receive_char_special()
1393 echo_char(c, tty); in n_tty_receive_char_special()
1395 commit_echoes(tty); in n_tty_receive_char_special()
1399 if (c == (unsigned char) '\377' && I_PARMRK(tty)) in n_tty_receive_char_special()
1407 n_tty_receive_char_inline(struct tty_struct *tty, unsigned char c) in n_tty_receive_char_inline() argument
1409 struct n_tty_data *ldata = tty->disc_data; in n_tty_receive_char_inline()
1411 if (tty->stopped && !tty->flow_stopped && I_IXON(tty) && I_IXANY(tty)) { in n_tty_receive_char_inline()
1412 start_tty(tty); in n_tty_receive_char_inline()
1413 process_echoes(tty); in n_tty_receive_char_inline()
1415 if (L_ECHO(tty)) { in n_tty_receive_char_inline()
1420 echo_char(c, tty); in n_tty_receive_char_inline()
1421 commit_echoes(tty); in n_tty_receive_char_inline()
1424 if (c == (unsigned char) '\377' && I_PARMRK(tty)) in n_tty_receive_char_inline()
1429 static void n_tty_receive_char(struct tty_struct *tty, unsigned char c) in n_tty_receive_char() argument
1431 n_tty_receive_char_inline(tty, c); in n_tty_receive_char()
1435 n_tty_receive_char_fast(struct tty_struct *tty, unsigned char c) in n_tty_receive_char_fast() argument
1437 struct n_tty_data *ldata = tty->disc_data; in n_tty_receive_char_fast()
1439 if (tty->stopped && !tty->flow_stopped && I_IXON(tty) && I_IXANY(tty)) { in n_tty_receive_char_fast()
1440 start_tty(tty); in n_tty_receive_char_fast()
1441 process_echoes(tty); in n_tty_receive_char_fast()
1443 if (L_ECHO(tty)) { in n_tty_receive_char_fast()
1448 echo_char(c, tty); in n_tty_receive_char_fast()
1449 commit_echoes(tty); in n_tty_receive_char_fast()
1454 static void n_tty_receive_char_closing(struct tty_struct *tty, unsigned char c) in n_tty_receive_char_closing() argument
1456 if (I_ISTRIP(tty)) in n_tty_receive_char_closing()
1458 if (I_IUCLC(tty) && L_IEXTEN(tty)) in n_tty_receive_char_closing()
1461 if (I_IXON(tty)) { in n_tty_receive_char_closing()
1462 if (c == STOP_CHAR(tty)) in n_tty_receive_char_closing()
1463 stop_tty(tty); in n_tty_receive_char_closing()
1464 else if (c == START_CHAR(tty) || in n_tty_receive_char_closing()
1465 (tty->stopped && !tty->flow_stopped && I_IXANY(tty) && in n_tty_receive_char_closing()
1466 c != INTR_CHAR(tty) && c != QUIT_CHAR(tty) && in n_tty_receive_char_closing()
1467 c != SUSP_CHAR(tty))) { in n_tty_receive_char_closing()
1468 start_tty(tty); in n_tty_receive_char_closing()
1469 process_echoes(tty); in n_tty_receive_char_closing()
1475 n_tty_receive_char_flagged(struct tty_struct *tty, unsigned char c, char flag) in n_tty_receive_char_flagged() argument
1479 n_tty_receive_break(tty); in n_tty_receive_char_flagged()
1483 n_tty_receive_parity_error(tty, c); in n_tty_receive_char_flagged()
1486 n_tty_receive_overrun(tty); in n_tty_receive_char_flagged()
1489 tty_err(tty, "unknown flag %d\n", flag); in n_tty_receive_char_flagged()
1495 n_tty_receive_char_lnext(struct tty_struct *tty, unsigned char c, char flag) in n_tty_receive_char_lnext() argument
1497 struct n_tty_data *ldata = tty->disc_data; in n_tty_receive_char_lnext()
1501 if (I_ISTRIP(tty)) in n_tty_receive_char_lnext()
1503 if (I_IUCLC(tty) && L_IEXTEN(tty)) in n_tty_receive_char_lnext()
1505 n_tty_receive_char(tty, c); in n_tty_receive_char_lnext()
1507 n_tty_receive_char_flagged(tty, c, flag); in n_tty_receive_char_lnext()
1511 n_tty_receive_buf_real_raw(struct tty_struct *tty, const unsigned char *cp, in n_tty_receive_buf_real_raw() argument
1514 struct n_tty_data *ldata = tty->disc_data; in n_tty_receive_buf_real_raw()
1531 n_tty_receive_buf_raw(struct tty_struct *tty, const unsigned char *cp, in n_tty_receive_buf_raw() argument
1534 struct n_tty_data *ldata = tty->disc_data; in n_tty_receive_buf_raw()
1543 n_tty_receive_char_flagged(tty, *cp++, flag); in n_tty_receive_buf_raw()
1548 n_tty_receive_buf_closing(struct tty_struct *tty, const unsigned char *cp, in n_tty_receive_buf_closing() argument
1557 n_tty_receive_char_closing(tty, *cp++); in n_tty_receive_buf_closing()
1562 n_tty_receive_buf_standard(struct tty_struct *tty, const unsigned char *cp, in n_tty_receive_buf_standard() argument
1565 struct n_tty_data *ldata = tty->disc_data; in n_tty_receive_buf_standard()
1574 if (I_ISTRIP(tty)) in n_tty_receive_buf_standard()
1576 if (I_IUCLC(tty) && L_IEXTEN(tty)) in n_tty_receive_buf_standard()
1578 if (L_EXTPROC(tty)) { in n_tty_receive_buf_standard()
1583 n_tty_receive_char_inline(tty, c); in n_tty_receive_buf_standard()
1584 else if (n_tty_receive_char_special(tty, c) && count) { in n_tty_receive_buf_standard()
1587 n_tty_receive_char_lnext(tty, *cp++, flag); in n_tty_receive_buf_standard()
1591 n_tty_receive_char_flagged(tty, *cp++, flag); in n_tty_receive_buf_standard()
1596 n_tty_receive_buf_fast(struct tty_struct *tty, const unsigned char *cp, in n_tty_receive_buf_fast() argument
1599 struct n_tty_data *ldata = tty->disc_data; in n_tty_receive_buf_fast()
1609 n_tty_receive_char_fast(tty, c); in n_tty_receive_buf_fast()
1610 else if (n_tty_receive_char_special(tty, c) && count) { in n_tty_receive_buf_fast()
1613 n_tty_receive_char_lnext(tty, *cp++, flag); in n_tty_receive_buf_fast()
1617 n_tty_receive_char_flagged(tty, *cp++, flag); in n_tty_receive_buf_fast()
1621 static void __receive_buf(struct tty_struct *tty, const unsigned char *cp, in __receive_buf() argument
1624 struct n_tty_data *ldata = tty->disc_data; in __receive_buf()
1625 bool preops = I_ISTRIP(tty) || (I_IUCLC(tty) && L_IEXTEN(tty)); in __receive_buf()
1628 n_tty_receive_buf_real_raw(tty, cp, fp, count); in __receive_buf()
1629 else if (ldata->raw || (L_EXTPROC(tty) && !preops)) in __receive_buf()
1630 n_tty_receive_buf_raw(tty, cp, fp, count); in __receive_buf()
1631 else if (tty->closing && !L_EXTPROC(tty)) in __receive_buf()
1632 n_tty_receive_buf_closing(tty, cp, fp, count); in __receive_buf()
1639 n_tty_receive_char_lnext(tty, *cp++, flag); in __receive_buf()
1643 if (!preops && !I_PARMRK(tty)) in __receive_buf()
1644 n_tty_receive_buf_fast(tty, cp, fp, count); in __receive_buf()
1646 n_tty_receive_buf_standard(tty, cp, fp, count); in __receive_buf()
1648 flush_echoes(tty); in __receive_buf()
1649 if (tty->ops->flush_chars) in __receive_buf()
1650 tty->ops->flush_chars(tty); in __receive_buf()
1653 if (ldata->icanon && !L_EXTPROC(tty)) in __receive_buf()
1660 kill_fasync(&tty->fasync, SIGIO, POLL_IN); in __receive_buf()
1661 wake_up_interruptible_poll(&tty->read_wait, EPOLLIN); in __receive_buf()
1699 n_tty_receive_buf_common(struct tty_struct *tty, const unsigned char *cp, in n_tty_receive_buf_common() argument
1702 struct n_tty_data *ldata = tty->disc_data; in n_tty_receive_buf_common()
1705 down_read(&tty->termios_rwsem); in n_tty_receive_buf_common()
1724 if (I_PARMRK(tty)) in n_tty_receive_buf_common()
1742 __receive_buf(tty, cp, fp, n); in n_tty_receive_buf_common()
1749 } while (!test_bit(TTY_LDISC_CHANGING, &tty->flags)); in n_tty_receive_buf_common()
1751 tty->receive_room = room; in n_tty_receive_buf_common()
1754 if (tty->driver->type == TTY_DRIVER_TYPE_PTY) { in n_tty_receive_buf_common()
1756 tty_set_flow_change(tty, TTY_UNTHROTTLE_SAFE); in n_tty_receive_buf_common()
1757 tty_unthrottle_safe(tty); in n_tty_receive_buf_common()
1758 __tty_set_flow_change(tty, 0); in n_tty_receive_buf_common()
1761 n_tty_check_throttle(tty); in n_tty_receive_buf_common()
1763 up_read(&tty->termios_rwsem); in n_tty_receive_buf_common()
1768 static void n_tty_receive_buf(struct tty_struct *tty, const unsigned char *cp, in n_tty_receive_buf() argument
1771 n_tty_receive_buf_common(tty, cp, fp, count, 0); in n_tty_receive_buf()
1774 static int n_tty_receive_buf2(struct tty_struct *tty, const unsigned char *cp, in n_tty_receive_buf2() argument
1777 return n_tty_receive_buf_common(tty, cp, fp, count, 1); in n_tty_receive_buf2()
1794 static void n_tty_set_termios(struct tty_struct *tty, struct ktermios *old) in n_tty_set_termios() argument
1796 struct n_tty_data *ldata = tty->disc_data; in n_tty_set_termios()
1798 if (!old || (old->c_lflag ^ tty->termios.c_lflag) & (ICANON | EXTPROC)) { in n_tty_set_termios()
1801 if (!L_ICANON(tty) || !read_cnt(ldata)) { in n_tty_set_termios()
1815 ldata->icanon = (L_ICANON(tty) != 0); in n_tty_set_termios()
1817 if (I_ISTRIP(tty) || I_IUCLC(tty) || I_IGNCR(tty) || in n_tty_set_termios()
1818 I_ICRNL(tty) || I_INLCR(tty) || L_ICANON(tty) || in n_tty_set_termios()
1819 I_IXON(tty) || L_ISIG(tty) || L_ECHO(tty) || in n_tty_set_termios()
1820 I_PARMRK(tty)) { in n_tty_set_termios()
1823 if (I_IGNCR(tty) || I_ICRNL(tty)) in n_tty_set_termios()
1825 if (I_INLCR(tty)) in n_tty_set_termios()
1828 if (L_ICANON(tty)) { in n_tty_set_termios()
1829 set_bit(ERASE_CHAR(tty), ldata->char_map); in n_tty_set_termios()
1830 set_bit(KILL_CHAR(tty), ldata->char_map); in n_tty_set_termios()
1831 set_bit(EOF_CHAR(tty), ldata->char_map); in n_tty_set_termios()
1833 set_bit(EOL_CHAR(tty), ldata->char_map); in n_tty_set_termios()
1834 if (L_IEXTEN(tty)) { in n_tty_set_termios()
1835 set_bit(WERASE_CHAR(tty), ldata->char_map); in n_tty_set_termios()
1836 set_bit(LNEXT_CHAR(tty), ldata->char_map); in n_tty_set_termios()
1837 set_bit(EOL2_CHAR(tty), ldata->char_map); in n_tty_set_termios()
1838 if (L_ECHO(tty)) in n_tty_set_termios()
1839 set_bit(REPRINT_CHAR(tty), in n_tty_set_termios()
1843 if (I_IXON(tty)) { in n_tty_set_termios()
1844 set_bit(START_CHAR(tty), ldata->char_map); in n_tty_set_termios()
1845 set_bit(STOP_CHAR(tty), ldata->char_map); in n_tty_set_termios()
1847 if (L_ISIG(tty)) { in n_tty_set_termios()
1848 set_bit(INTR_CHAR(tty), ldata->char_map); in n_tty_set_termios()
1849 set_bit(QUIT_CHAR(tty), ldata->char_map); in n_tty_set_termios()
1850 set_bit(SUSP_CHAR(tty), ldata->char_map); in n_tty_set_termios()
1857 if ((I_IGNBRK(tty) || (!I_BRKINT(tty) && !I_PARMRK(tty))) && in n_tty_set_termios()
1858 (I_IGNPAR(tty) || !I_INPCK(tty)) && in n_tty_set_termios()
1859 (tty->driver->flags & TTY_DRIVER_REAL_RAW)) in n_tty_set_termios()
1868 if (!I_IXON(tty) && old && (old->c_iflag & IXON) && !tty->flow_stopped) { in n_tty_set_termios()
1869 start_tty(tty); in n_tty_set_termios()
1870 process_echoes(tty); in n_tty_set_termios()
1874 wake_up_interruptible(&tty->write_wait); in n_tty_set_termios()
1875 wake_up_interruptible(&tty->read_wait); in n_tty_set_termios()
1888 static void n_tty_close(struct tty_struct *tty) in n_tty_close() argument
1890 struct n_tty_data *ldata = tty->disc_data; in n_tty_close()
1892 if (tty->link) in n_tty_close()
1893 n_tty_packet_mode_flush(tty); in n_tty_close()
1896 tty->disc_data = NULL; in n_tty_close()
1909 static int n_tty_open(struct tty_struct *tty) in n_tty_open() argument
1922 tty->disc_data = ldata; in n_tty_open()
1923 tty->closing = 0; in n_tty_open()
1925 clear_bit(TTY_LDISC_HALTED, &tty->flags); in n_tty_open()
1926 n_tty_set_termios(tty, NULL); in n_tty_open()
1927 tty_unthrottle(tty); in n_tty_open()
1931 static inline int input_available_p(struct tty_struct *tty, int poll) in input_available_p() argument
1933 struct n_tty_data *ldata = tty->disc_data; in input_available_p()
1934 int amt = poll && !TIME_CHAR(tty) && MIN_CHAR(tty) ? MIN_CHAR(tty) : 1; in input_available_p()
1936 if (ldata->icanon && !L_EXTPROC(tty)) in input_available_p()
1962 static int copy_from_read_buf(struct tty_struct *tty, in copy_from_read_buf() argument
1967 struct n_tty_data *ldata = tty->disc_data; in copy_from_read_buf()
1981 is_eof = n == 1 && *from == EOF_CHAR(tty); in copy_from_read_buf()
1982 tty_audit_add_data(tty, from, n); in copy_from_read_buf()
1983 zero_buffer(tty, from, n); in copy_from_read_buf()
1986 if (L_EXTPROC(tty) && ldata->icanon && is_eof && in copy_from_read_buf()
2018 static int canon_copy_from_read_buf(struct tty_struct *tty, in canon_copy_from_read_buf() argument
2022 struct n_tty_data *ldata = tty->disc_data; in canon_copy_from_read_buf()
2062 ret = tty_copy_to_user(tty, *b, tail, n); in canon_copy_from_read_buf()
2099 static int job_control(struct tty_struct *tty, struct file *file) in job_control() argument
2109 return __tty_check_change(tty, SIGTTIN); in job_control()
2132 static ssize_t n_tty_read(struct tty_struct *tty, struct file *file, in n_tty_read() argument
2135 struct n_tty_data *ldata = tty->disc_data; in n_tty_read()
2145 c = job_control(tty, file); in n_tty_read()
2160 down_read(&tty->termios_rwsem); in n_tty_read()
2165 minimum = MIN_CHAR(tty); in n_tty_read()
2167 time = (HZ / 10) * TIME_CHAR(tty); in n_tty_read()
2169 timeout = (HZ / 10) * TIME_CHAR(tty); in n_tty_read()
2174 packet = tty->packet; in n_tty_read()
2177 add_wait_queue(&tty->read_wait, &wait); in n_tty_read()
2180 if (packet && tty->link->ctrl_status) { in n_tty_read()
2184 spin_lock_irq(&tty->link->ctrl_lock); in n_tty_read()
2185 cs = tty->link->ctrl_status; in n_tty_read()
2186 tty->link->ctrl_status = 0; in n_tty_read()
2187 spin_unlock_irq(&tty->link->ctrl_lock); in n_tty_read()
2197 if (!input_available_p(tty, 0)) { in n_tty_read()
2198 up_read(&tty->termios_rwsem); in n_tty_read()
2199 tty_buffer_flush_work(tty->port); in n_tty_read()
2200 down_read(&tty->termios_rwsem); in n_tty_read()
2201 if (!input_available_p(tty, 0)) { in n_tty_read()
2202 if (test_bit(TTY_OTHER_CLOSED, &tty->flags)) { in n_tty_read()
2212 if (test_bit(TTY_HUPPING, &tty->flags)) in n_tty_read()
2216 if (tty_io_nonblock(tty, file)) { in n_tty_read()
2224 up_read(&tty->termios_rwsem); in n_tty_read()
2229 down_read(&tty->termios_rwsem); in n_tty_read()
2234 if (ldata->icanon && !L_EXTPROC(tty)) { in n_tty_read()
2235 retval = canon_copy_from_read_buf(tty, &b, &nr); in n_tty_read()
2251 uncopied = copy_from_read_buf(tty, &b, &nr); in n_tty_read()
2252 uncopied += copy_from_read_buf(tty, &b, &nr); in n_tty_read()
2259 n_tty_check_unthrottle(tty); in n_tty_read()
2267 n_tty_kick_worker(tty); in n_tty_read()
2268 up_read(&tty->termios_rwsem); in n_tty_read()
2270 remove_wait_queue(&tty->read_wait, &wait); in n_tty_read()
2301 static ssize_t n_tty_write(struct tty_struct *tty, struct file *file, in n_tty_write() argument
2310 if (L_TOSTOP(tty) && file->f_op->write != redirected_tty_write) { in n_tty_write()
2311 retval = tty_check_change(tty); in n_tty_write()
2316 down_read(&tty->termios_rwsem); in n_tty_write()
2319 process_echoes(tty); in n_tty_write()
2321 add_wait_queue(&tty->write_wait, &wait); in n_tty_write()
2327 if (tty_hung_up_p(file) || (tty->link && !tty->link->count)) { in n_tty_write()
2331 if (O_OPOST(tty)) { in n_tty_write()
2333 ssize_t num = process_output_block(tty, b, nr); in n_tty_write()
2345 if (process_output(c, tty) < 0) in n_tty_write()
2349 if (tty->ops->flush_chars) in n_tty_write()
2350 tty->ops->flush_chars(tty); in n_tty_write()
2352 struct n_tty_data *ldata = tty->disc_data; in n_tty_write()
2356 c = tty->ops->write(tty, b, nr); in n_tty_write()
2370 if (tty_io_nonblock(tty, file)) { in n_tty_write()
2374 up_read(&tty->termios_rwsem); in n_tty_write()
2378 down_read(&tty->termios_rwsem); in n_tty_write()
2381 remove_wait_queue(&tty->write_wait, &wait); in n_tty_write()
2382 if (nr && tty->fasync) in n_tty_write()
2383 set_bit(TTY_DO_WRITE_WAKEUP, &tty->flags); in n_tty_write()
2384 up_read(&tty->termios_rwsem); in n_tty_write()
2402 static __poll_t n_tty_poll(struct tty_struct *tty, struct file *file, in n_tty_poll() argument
2407 poll_wait(file, &tty->read_wait, wait); in n_tty_poll()
2408 poll_wait(file, &tty->write_wait, wait); in n_tty_poll()
2409 if (input_available_p(tty, 1)) in n_tty_poll()
2412 tty_buffer_flush_work(tty->port); in n_tty_poll()
2413 if (input_available_p(tty, 1)) in n_tty_poll()
2416 if (tty->packet && tty->link->ctrl_status) in n_tty_poll()
2418 if (test_bit(TTY_OTHER_CLOSED, &tty->flags)) in n_tty_poll()
2422 if (tty->ops->write && !tty_is_writelocked(tty) && in n_tty_poll()
2423 tty_chars_in_buffer(tty) < WAKEUP_CHARS && in n_tty_poll()
2424 tty_write_room(tty) > 0) in n_tty_poll()
2448 static int n_tty_ioctl(struct tty_struct *tty, struct file *file, in n_tty_ioctl() argument
2451 struct n_tty_data *ldata = tty->disc_data; in n_tty_ioctl()
2456 return put_user(tty_chars_in_buffer(tty), (int __user *) arg); in n_tty_ioctl()
2458 down_write(&tty->termios_rwsem); in n_tty_ioctl()
2459 if (L_ICANON(tty) && !L_EXTPROC(tty)) in n_tty_ioctl()
2463 up_write(&tty->termios_rwsem); in n_tty_ioctl()
2466 return n_tty_ioctl_helper(tty, file, cmd, arg); in n_tty_ioctl()