Lines Matching refs:tty
156 static inline int tty_put_user(struct tty_struct *tty, unsigned char x, in tty_put_user() argument
159 struct n_tty_data *ldata = tty->disc_data; in tty_put_user()
161 tty_audit_add_data(tty, &x, 1, ldata->icanon); in tty_put_user()
165 static inline int tty_copy_to_user(struct tty_struct *tty, in tty_copy_to_user() argument
170 struct n_tty_data *ldata = tty->disc_data; in tty_copy_to_user()
172 tty_audit_add_data(tty, from, n, ldata->icanon); in tty_copy_to_user()
188 static void n_tty_kick_worker(struct tty_struct *tty) in n_tty_kick_worker() argument
190 struct n_tty_data *ldata = tty->disc_data; in n_tty_kick_worker()
196 WARN_RATELIMIT(tty->port->itty == NULL, in n_tty_kick_worker()
202 WARN_RATELIMIT(test_bit(TTY_LDISC_HALTED, &tty->flags), in n_tty_kick_worker()
204 tty_buffer_restart_work(tty->port); in n_tty_kick_worker()
208 static ssize_t chars_in_buffer(struct tty_struct *tty) in chars_in_buffer() argument
210 struct n_tty_data *ldata = tty->disc_data; in chars_in_buffer()
229 static void n_tty_write_wakeup(struct tty_struct *tty) in n_tty_write_wakeup() argument
231 if (tty->fasync && test_and_clear_bit(TTY_DO_WRITE_WAKEUP, &tty->flags)) in n_tty_write_wakeup()
232 kill_fasync(&tty->fasync, SIGIO, POLL_OUT); in n_tty_write_wakeup()
235 static void n_tty_check_throttle(struct tty_struct *tty) in n_tty_check_throttle() argument
237 struct n_tty_data *ldata = tty->disc_data; in n_tty_check_throttle()
249 tty_set_flow_change(tty, TTY_THROTTLE_SAFE); in n_tty_check_throttle()
252 throttled = tty_throttle_safe(tty); in n_tty_check_throttle()
256 __tty_set_flow_change(tty, 0); in n_tty_check_throttle()
259 static void n_tty_check_unthrottle(struct tty_struct *tty) in n_tty_check_unthrottle() argument
261 if (tty->driver->type == TTY_DRIVER_TYPE_PTY) { in n_tty_check_unthrottle()
262 if (chars_in_buffer(tty) > TTY_THRESHOLD_UNTHROTTLE) in n_tty_check_unthrottle()
264 if (!tty->count) in n_tty_check_unthrottle()
266 n_tty_kick_worker(tty); in n_tty_check_unthrottle()
267 tty_wakeup(tty->link); in n_tty_check_unthrottle()
281 tty_set_flow_change(tty, TTY_UNTHROTTLE_SAFE); in n_tty_check_unthrottle()
282 if (chars_in_buffer(tty) > TTY_THRESHOLD_UNTHROTTLE) in n_tty_check_unthrottle()
284 if (!tty->count) in n_tty_check_unthrottle()
286 n_tty_kick_worker(tty); in n_tty_check_unthrottle()
287 unthrottled = tty_unthrottle_safe(tty); in n_tty_check_unthrottle()
291 __tty_set_flow_change(tty, 0); in n_tty_check_unthrottle()
335 static void n_tty_packet_mode_flush(struct tty_struct *tty) in n_tty_packet_mode_flush() argument
339 if (tty->link->packet) { in n_tty_packet_mode_flush()
340 spin_lock_irqsave(&tty->ctrl_lock, flags); in n_tty_packet_mode_flush()
341 tty->ctrl_status |= TIOCPKT_FLUSHREAD; in n_tty_packet_mode_flush()
342 spin_unlock_irqrestore(&tty->ctrl_lock, flags); in n_tty_packet_mode_flush()
343 wake_up_interruptible(&tty->link->read_wait); in n_tty_packet_mode_flush()
361 static void n_tty_flush_buffer(struct tty_struct *tty) in n_tty_flush_buffer() argument
363 down_write(&tty->termios_rwsem); in n_tty_flush_buffer()
364 reset_buffer_flags(tty->disc_data); in n_tty_flush_buffer()
365 n_tty_kick_worker(tty); in n_tty_flush_buffer()
367 if (tty->link) in n_tty_flush_buffer()
368 n_tty_packet_mode_flush(tty); in n_tty_flush_buffer()
369 up_write(&tty->termios_rwsem); in n_tty_flush_buffer()
382 static ssize_t n_tty_chars_in_buffer(struct tty_struct *tty) in n_tty_chars_in_buffer() argument
388 down_write(&tty->termios_rwsem); in n_tty_chars_in_buffer()
389 n = chars_in_buffer(tty); in n_tty_chars_in_buffer()
390 up_write(&tty->termios_rwsem); in n_tty_chars_in_buffer()
416 static inline int is_continuation(unsigned char c, struct tty_struct *tty) in is_continuation() argument
418 return I_IUTF8(tty) && is_utf8_continuation(c); in is_continuation()
443 static int do_output_char(unsigned char c, struct tty_struct *tty, int space) in do_output_char() argument
445 struct n_tty_data *ldata = tty->disc_data; in do_output_char()
453 if (O_ONLRET(tty)) in do_output_char()
455 if (O_ONLCR(tty)) { in do_output_char()
459 tty->ops->write(tty, "\r\n", 2); in do_output_char()
465 if (O_ONOCR(tty) && ldata->column == 0) in do_output_char()
467 if (O_OCRNL(tty)) { in do_output_char()
469 if (O_ONLRET(tty)) in do_output_char()
477 if (O_TABDLY(tty) == XTABS) { in do_output_char()
481 tty->ops->write(tty, " ", spaces); in do_output_char()
492 if (O_OLCUC(tty)) in do_output_char()
494 if (!is_continuation(c, tty)) in do_output_char()
500 tty_put_char(tty, c); in do_output_char()
518 static int process_output(unsigned char c, struct tty_struct *tty) in process_output() argument
520 struct n_tty_data *ldata = tty->disc_data; in process_output()
525 space = tty_write_room(tty); in process_output()
526 retval = do_output_char(c, tty, space); in process_output()
554 static ssize_t process_output_block(struct tty_struct *tty, in process_output_block() argument
557 struct n_tty_data *ldata = tty->disc_data; in process_output_block()
564 space = tty_write_room(tty); in process_output_block()
577 if (O_ONLRET(tty)) in process_output_block()
579 if (O_ONLCR(tty)) in process_output_block()
584 if (O_ONOCR(tty) && ldata->column == 0) in process_output_block()
586 if (O_OCRNL(tty)) in process_output_block()
598 if (O_OLCUC(tty)) in process_output_block()
600 if (!is_continuation(c, tty)) in process_output_block()
607 i = tty->ops->write(tty, buf, i); in process_output_block()
638 static size_t __process_echoes(struct tty_struct *tty) in __process_echoes() argument
640 struct n_tty_data *ldata = tty->disc_data; in __process_echoes()
645 old_space = space = tty_write_room(tty); in __process_echoes()
687 tty_put_char(tty, '\b'); in __process_echoes()
711 tty_put_char(tty, ECHO_OP_START); in __process_echoes()
731 tty_put_char(tty, '^'); in __process_echoes()
732 tty_put_char(tty, op ^ 0100); in __process_echoes()
741 if (O_OPOST(tty)) { in __process_echoes()
742 int retval = do_output_char(c, tty, space); in __process_echoes()
749 tty_put_char(tty, c); in __process_echoes()
773 static void commit_echoes(struct tty_struct *tty) in commit_echoes() argument
775 struct n_tty_data *ldata = tty->disc_data; in commit_echoes()
792 echoed = __process_echoes(tty); in commit_echoes()
795 if (echoed && tty->ops->flush_chars) in commit_echoes()
796 tty->ops->flush_chars(tty); in commit_echoes()
799 static void process_echoes(struct tty_struct *tty) in process_echoes() argument
801 struct n_tty_data *ldata = tty->disc_data; in process_echoes()
809 echoed = __process_echoes(tty); in process_echoes()
812 if (echoed && tty->ops->flush_chars) in process_echoes()
813 tty->ops->flush_chars(tty); in process_echoes()
817 static void flush_echoes(struct tty_struct *tty) in flush_echoes() argument
819 struct n_tty_data *ldata = tty->disc_data; in flush_echoes()
821 if ((!L_ECHO(tty) && !L_ECHONL(tty)) || in flush_echoes()
827 __process_echoes(tty); in flush_echoes()
935 static void echo_char(unsigned char c, struct tty_struct *tty) in echo_char() argument
937 struct n_tty_data *ldata = tty->disc_data; in echo_char()
943 if (L_ECHOCTL(tty) && iscntrl(c) && c != '\t') in echo_char()
975 static void eraser(unsigned char c, struct tty_struct *tty) in eraser() argument
977 struct n_tty_data *ldata = tty->disc_data; in eraser()
987 if (c == ERASE_CHAR(tty)) in eraser()
989 else if (c == WERASE_CHAR(tty)) in eraser()
992 if (!L_ECHO(tty)) { in eraser()
996 if (!L_ECHOK(tty) || !L_ECHOKE(tty) || !L_ECHOE(tty)) { in eraser()
999 echo_char(KILL_CHAR(tty), tty); in eraser()
1001 if (L_ECHOK(tty)) in eraser()
1016 } while (is_continuation(c, tty) && head != ldata->canon_head); in eraser()
1019 if (is_continuation(c, tty)) in eraser()
1031 if (L_ECHO(tty)) { in eraser()
1032 if (L_ECHOPRT(tty)) { in eraser()
1038 echo_char(c, tty); in eraser()
1044 } else if (kill_type == ERASE && !L_ECHOE(tty)) { in eraser()
1045 echo_char(ERASE_CHAR(tty), tty); in eraser()
1065 if (L_ECHOCTL(tty)) in eraser()
1067 } else if (!is_continuation(c, tty)) { in eraser()
1073 if (iscntrl(c) && L_ECHOCTL(tty)) { in eraser()
1078 if (!iscntrl(c) || L_ECHOCTL(tty)) { in eraser()
1088 if (ldata->read_head == ldata->canon_head && L_ECHO(tty)) in eraser()
1107 static void __isig(int sig, struct tty_struct *tty) in __isig() argument
1109 struct pid *tty_pgrp = tty_get_pgrp(tty); in __isig()
1116 static void isig(int sig, struct tty_struct *tty) in isig() argument
1118 struct n_tty_data *ldata = tty->disc_data; in isig()
1120 if (L_NOFLSH(tty)) { in isig()
1122 __isig(sig, tty); in isig()
1125 up_read(&tty->termios_rwsem); in isig()
1126 down_write(&tty->termios_rwsem); in isig()
1128 __isig(sig, tty); in isig()
1137 tty_driver_flush_buffer(tty); in isig()
1140 reset_buffer_flags(tty->disc_data); in isig()
1143 if (tty->link) in isig()
1144 n_tty_packet_mode_flush(tty); in isig()
1146 up_write(&tty->termios_rwsem); in isig()
1147 down_read(&tty->termios_rwsem); in isig()
1164 static void n_tty_receive_break(struct tty_struct *tty) in n_tty_receive_break() argument
1166 struct n_tty_data *ldata = tty->disc_data; in n_tty_receive_break()
1168 if (I_IGNBRK(tty)) in n_tty_receive_break()
1170 if (I_BRKINT(tty)) { in n_tty_receive_break()
1171 isig(SIGINT, tty); in n_tty_receive_break()
1174 if (I_PARMRK(tty)) { in n_tty_receive_break()
1194 static void n_tty_receive_overrun(struct tty_struct *tty) in n_tty_receive_overrun() argument
1196 struct n_tty_data *ldata = tty->disc_data; in n_tty_receive_overrun()
1202 tty_name(tty), in n_tty_receive_overrun()
1220 static void n_tty_receive_parity_error(struct tty_struct *tty, unsigned char c) in n_tty_receive_parity_error() argument
1222 struct n_tty_data *ldata = tty->disc_data; in n_tty_receive_parity_error()
1224 if (I_INPCK(tty)) { in n_tty_receive_parity_error()
1225 if (I_IGNPAR(tty)) in n_tty_receive_parity_error()
1227 if (I_PARMRK(tty)) { in n_tty_receive_parity_error()
1238 n_tty_receive_signal_char(struct tty_struct *tty, int signal, unsigned char c) in n_tty_receive_signal_char() argument
1240 isig(signal, tty); in n_tty_receive_signal_char()
1241 if (I_IXON(tty)) in n_tty_receive_signal_char()
1242 start_tty(tty); in n_tty_receive_signal_char()
1243 if (L_ECHO(tty)) { in n_tty_receive_signal_char()
1244 echo_char(c, tty); in n_tty_receive_signal_char()
1245 commit_echoes(tty); in n_tty_receive_signal_char()
1247 process_echoes(tty); in n_tty_receive_signal_char()
1268 n_tty_receive_char_special(struct tty_struct *tty, unsigned char c) in n_tty_receive_char_special() argument
1270 struct n_tty_data *ldata = tty->disc_data; in n_tty_receive_char_special()
1272 if (I_IXON(tty)) { in n_tty_receive_char_special()
1273 if (c == START_CHAR(tty)) { in n_tty_receive_char_special()
1274 start_tty(tty); in n_tty_receive_char_special()
1275 process_echoes(tty); in n_tty_receive_char_special()
1278 if (c == STOP_CHAR(tty)) { in n_tty_receive_char_special()
1279 stop_tty(tty); in n_tty_receive_char_special()
1284 if (L_ISIG(tty)) { in n_tty_receive_char_special()
1285 if (c == INTR_CHAR(tty)) { in n_tty_receive_char_special()
1286 n_tty_receive_signal_char(tty, SIGINT, c); in n_tty_receive_char_special()
1288 } else if (c == QUIT_CHAR(tty)) { in n_tty_receive_char_special()
1289 n_tty_receive_signal_char(tty, SIGQUIT, c); in n_tty_receive_char_special()
1291 } else if (c == SUSP_CHAR(tty)) { in n_tty_receive_char_special()
1292 n_tty_receive_signal_char(tty, SIGTSTP, c); in n_tty_receive_char_special()
1297 if (tty->stopped && !tty->flow_stopped && I_IXON(tty) && I_IXANY(tty)) { in n_tty_receive_char_special()
1298 start_tty(tty); in n_tty_receive_char_special()
1299 process_echoes(tty); in n_tty_receive_char_special()
1303 if (I_IGNCR(tty)) in n_tty_receive_char_special()
1305 if (I_ICRNL(tty)) in n_tty_receive_char_special()
1307 } else if (c == '\n' && I_INLCR(tty)) in n_tty_receive_char_special()
1311 if (c == ERASE_CHAR(tty) || c == KILL_CHAR(tty) || in n_tty_receive_char_special()
1312 (c == WERASE_CHAR(tty) && L_IEXTEN(tty))) { in n_tty_receive_char_special()
1313 eraser(c, tty); in n_tty_receive_char_special()
1314 commit_echoes(tty); in n_tty_receive_char_special()
1317 if (c == LNEXT_CHAR(tty) && L_IEXTEN(tty)) { in n_tty_receive_char_special()
1319 if (L_ECHO(tty)) { in n_tty_receive_char_special()
1321 if (L_ECHOCTL(tty)) { in n_tty_receive_char_special()
1324 commit_echoes(tty); in n_tty_receive_char_special()
1329 if (c == REPRINT_CHAR(tty) && L_ECHO(tty) && L_IEXTEN(tty)) { in n_tty_receive_char_special()
1333 echo_char(c, tty); in n_tty_receive_char_special()
1336 echo_char(read_buf(ldata, tail), tty); in n_tty_receive_char_special()
1339 commit_echoes(tty); in n_tty_receive_char_special()
1343 if (L_ECHO(tty) || L_ECHONL(tty)) { in n_tty_receive_char_special()
1345 commit_echoes(tty); in n_tty_receive_char_special()
1349 if (c == EOF_CHAR(tty)) { in n_tty_receive_char_special()
1353 if ((c == EOL_CHAR(tty)) || in n_tty_receive_char_special()
1354 (c == EOL2_CHAR(tty) && L_IEXTEN(tty))) { in n_tty_receive_char_special()
1358 if (L_ECHO(tty)) { in n_tty_receive_char_special()
1362 echo_char(c, tty); in n_tty_receive_char_special()
1363 commit_echoes(tty); in n_tty_receive_char_special()
1369 if (c == (unsigned char) '\377' && I_PARMRK(tty)) in n_tty_receive_char_special()
1376 kill_fasync(&tty->fasync, SIGIO, POLL_IN); in n_tty_receive_char_special()
1377 wake_up_interruptible_poll(&tty->read_wait, POLLIN); in n_tty_receive_char_special()
1382 if (L_ECHO(tty)) { in n_tty_receive_char_special()
1390 echo_char(c, tty); in n_tty_receive_char_special()
1392 commit_echoes(tty); in n_tty_receive_char_special()
1396 if (c == (unsigned char) '\377' && I_PARMRK(tty)) in n_tty_receive_char_special()
1404 n_tty_receive_char_inline(struct tty_struct *tty, unsigned char c) in n_tty_receive_char_inline() argument
1406 struct n_tty_data *ldata = tty->disc_data; in n_tty_receive_char_inline()
1408 if (tty->stopped && !tty->flow_stopped && I_IXON(tty) && I_IXANY(tty)) { in n_tty_receive_char_inline()
1409 start_tty(tty); in n_tty_receive_char_inline()
1410 process_echoes(tty); in n_tty_receive_char_inline()
1412 if (L_ECHO(tty)) { in n_tty_receive_char_inline()
1417 echo_char(c, tty); in n_tty_receive_char_inline()
1418 commit_echoes(tty); in n_tty_receive_char_inline()
1421 if (c == (unsigned char) '\377' && I_PARMRK(tty)) in n_tty_receive_char_inline()
1426 static void n_tty_receive_char(struct tty_struct *tty, unsigned char c) in n_tty_receive_char() argument
1428 n_tty_receive_char_inline(tty, c); in n_tty_receive_char()
1432 n_tty_receive_char_fast(struct tty_struct *tty, unsigned char c) in n_tty_receive_char_fast() argument
1434 struct n_tty_data *ldata = tty->disc_data; in n_tty_receive_char_fast()
1436 if (tty->stopped && !tty->flow_stopped && I_IXON(tty) && I_IXANY(tty)) { in n_tty_receive_char_fast()
1437 start_tty(tty); in n_tty_receive_char_fast()
1438 process_echoes(tty); in n_tty_receive_char_fast()
1440 if (L_ECHO(tty)) { in n_tty_receive_char_fast()
1445 echo_char(c, tty); in n_tty_receive_char_fast()
1446 commit_echoes(tty); in n_tty_receive_char_fast()
1451 static void n_tty_receive_char_closing(struct tty_struct *tty, unsigned char c) in n_tty_receive_char_closing() argument
1453 if (I_ISTRIP(tty)) in n_tty_receive_char_closing()
1455 if (I_IUCLC(tty) && L_IEXTEN(tty)) in n_tty_receive_char_closing()
1458 if (I_IXON(tty)) { in n_tty_receive_char_closing()
1459 if (c == STOP_CHAR(tty)) in n_tty_receive_char_closing()
1460 stop_tty(tty); in n_tty_receive_char_closing()
1461 else if (c == START_CHAR(tty) || in n_tty_receive_char_closing()
1462 (tty->stopped && !tty->flow_stopped && I_IXANY(tty) && in n_tty_receive_char_closing()
1463 c != INTR_CHAR(tty) && c != QUIT_CHAR(tty) && in n_tty_receive_char_closing()
1464 c != SUSP_CHAR(tty))) { in n_tty_receive_char_closing()
1465 start_tty(tty); in n_tty_receive_char_closing()
1466 process_echoes(tty); in n_tty_receive_char_closing()
1472 n_tty_receive_char_flagged(struct tty_struct *tty, unsigned char c, char flag) in n_tty_receive_char_flagged() argument
1476 n_tty_receive_break(tty); in n_tty_receive_char_flagged()
1480 n_tty_receive_parity_error(tty, c); in n_tty_receive_char_flagged()
1483 n_tty_receive_overrun(tty); in n_tty_receive_char_flagged()
1487 tty_name(tty), flag); in n_tty_receive_char_flagged()
1493 n_tty_receive_char_lnext(struct tty_struct *tty, unsigned char c, char flag) in n_tty_receive_char_lnext() argument
1495 struct n_tty_data *ldata = tty->disc_data; in n_tty_receive_char_lnext()
1499 if (I_ISTRIP(tty)) in n_tty_receive_char_lnext()
1501 if (I_IUCLC(tty) && L_IEXTEN(tty)) in n_tty_receive_char_lnext()
1503 n_tty_receive_char(tty, c); in n_tty_receive_char_lnext()
1505 n_tty_receive_char_flagged(tty, c, flag); in n_tty_receive_char_lnext()
1509 n_tty_receive_buf_real_raw(struct tty_struct *tty, const unsigned char *cp, in n_tty_receive_buf_real_raw() argument
1512 struct n_tty_data *ldata = tty->disc_data; in n_tty_receive_buf_real_raw()
1529 n_tty_receive_buf_raw(struct tty_struct *tty, const unsigned char *cp, in n_tty_receive_buf_raw() argument
1532 struct n_tty_data *ldata = tty->disc_data; in n_tty_receive_buf_raw()
1541 n_tty_receive_char_flagged(tty, *cp++, flag); in n_tty_receive_buf_raw()
1546 n_tty_receive_buf_closing(struct tty_struct *tty, const unsigned char *cp, in n_tty_receive_buf_closing() argument
1555 n_tty_receive_char_closing(tty, *cp++); in n_tty_receive_buf_closing()
1557 n_tty_receive_char_flagged(tty, *cp++, flag); 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()
1659 if ((read_cnt(ldata) >= ldata->minimum_to_wake) || 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, POLLIN); 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()
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()
1800 static void n_tty_set_termios(struct tty_struct *tty, struct ktermios *old) in n_tty_set_termios() argument
1802 struct n_tty_data *ldata = tty->disc_data; in n_tty_set_termios()
1804 if (!old || (old->c_lflag ^ tty->termios.c_lflag) & ICANON) { in n_tty_set_termios()
1807 if (!L_ICANON(tty) || !read_cnt(ldata)) { in n_tty_set_termios()
1821 ldata->icanon = (L_ICANON(tty) != 0); in n_tty_set_termios()
1823 if (I_ISTRIP(tty) || I_IUCLC(tty) || I_IGNCR(tty) || in n_tty_set_termios()
1824 I_ICRNL(tty) || I_INLCR(tty) || L_ICANON(tty) || in n_tty_set_termios()
1825 I_IXON(tty) || L_ISIG(tty) || L_ECHO(tty) || in n_tty_set_termios()
1826 I_PARMRK(tty)) { in n_tty_set_termios()
1829 if (I_IGNCR(tty) || I_ICRNL(tty)) in n_tty_set_termios()
1831 if (I_INLCR(tty)) in n_tty_set_termios()
1834 if (L_ICANON(tty)) { in n_tty_set_termios()
1835 set_bit(ERASE_CHAR(tty), ldata->char_map); in n_tty_set_termios()
1836 set_bit(KILL_CHAR(tty), ldata->char_map); in n_tty_set_termios()
1837 set_bit(EOF_CHAR(tty), ldata->char_map); in n_tty_set_termios()
1839 set_bit(EOL_CHAR(tty), ldata->char_map); in n_tty_set_termios()
1840 if (L_IEXTEN(tty)) { in n_tty_set_termios()
1841 set_bit(WERASE_CHAR(tty), ldata->char_map); in n_tty_set_termios()
1842 set_bit(LNEXT_CHAR(tty), ldata->char_map); in n_tty_set_termios()
1843 set_bit(EOL2_CHAR(tty), ldata->char_map); in n_tty_set_termios()
1844 if (L_ECHO(tty)) in n_tty_set_termios()
1845 set_bit(REPRINT_CHAR(tty), in n_tty_set_termios()
1849 if (I_IXON(tty)) { in n_tty_set_termios()
1850 set_bit(START_CHAR(tty), ldata->char_map); in n_tty_set_termios()
1851 set_bit(STOP_CHAR(tty), ldata->char_map); in n_tty_set_termios()
1853 if (L_ISIG(tty)) { in n_tty_set_termios()
1854 set_bit(INTR_CHAR(tty), ldata->char_map); in n_tty_set_termios()
1855 set_bit(QUIT_CHAR(tty), ldata->char_map); in n_tty_set_termios()
1856 set_bit(SUSP_CHAR(tty), ldata->char_map); in n_tty_set_termios()
1863 if ((I_IGNBRK(tty) || (!I_BRKINT(tty) && !I_PARMRK(tty))) && in n_tty_set_termios()
1864 (I_IGNPAR(tty) || !I_INPCK(tty)) && in n_tty_set_termios()
1865 (tty->driver->flags & TTY_DRIVER_REAL_RAW)) in n_tty_set_termios()
1874 if (!I_IXON(tty) && old && (old->c_iflag & IXON) && !tty->flow_stopped) { in n_tty_set_termios()
1875 start_tty(tty); in n_tty_set_termios()
1876 process_echoes(tty); in n_tty_set_termios()
1880 wake_up_interruptible(&tty->write_wait); in n_tty_set_termios()
1881 wake_up_interruptible(&tty->read_wait); in n_tty_set_termios()
1894 static void n_tty_close(struct tty_struct *tty) in n_tty_close() argument
1896 struct n_tty_data *ldata = tty->disc_data; in n_tty_close()
1898 if (tty->link) in n_tty_close()
1899 n_tty_packet_mode_flush(tty); in n_tty_close()
1902 tty->disc_data = NULL; in n_tty_close()
1915 static int n_tty_open(struct tty_struct *tty) in n_tty_open() argument
1928 tty->disc_data = ldata; in n_tty_open()
1929 reset_buffer_flags(tty->disc_data); in n_tty_open()
1936 tty->closing = 0; in n_tty_open()
1938 clear_bit(TTY_LDISC_HALTED, &tty->flags); in n_tty_open()
1939 n_tty_set_termios(tty, NULL); in n_tty_open()
1940 tty_unthrottle(tty); in n_tty_open()
1947 static inline int input_available_p(struct tty_struct *tty, int poll) in input_available_p() argument
1949 struct n_tty_data *ldata = tty->disc_data; in input_available_p()
1950 int amt = poll && !TIME_CHAR(tty) && MIN_CHAR(tty) ? MIN_CHAR(tty) : 1; in input_available_p()
1952 if (ldata->icanon && !L_EXTPROC(tty)) in input_available_p()
1978 static int copy_from_read_buf(struct tty_struct *tty, in copy_from_read_buf() argument
1983 struct n_tty_data *ldata = tty->disc_data; in copy_from_read_buf()
1996 is_eof = n == 1 && read_buf(ldata, tail) == EOF_CHAR(tty); in copy_from_read_buf()
1997 tty_audit_add_data(tty, read_buf_addr(ldata, tail), n, in copy_from_read_buf()
2001 if (L_EXTPROC(tty) && ldata->icanon && is_eof && in copy_from_read_buf()
2033 static int canon_copy_from_read_buf(struct tty_struct *tty, in canon_copy_from_read_buf() argument
2037 struct n_tty_data *ldata = tty->disc_data; in canon_copy_from_read_buf()
2080 ret = tty_copy_to_user(tty, *b, read_buf_addr(ldata, tail), size); in canon_copy_from_read_buf()
2083 ret = tty_copy_to_user(tty, *b + size, ldata->read_buf, n - size); in canon_copy_from_read_buf()
2085 ret = tty_copy_to_user(tty, *b, read_buf_addr(ldata, tail), n); in canon_copy_from_read_buf()
2101 tty_audit_push(tty); in canon_copy_from_read_buf()
2123 static int job_control(struct tty_struct *tty, struct file *file) in job_control() argument
2133 return __tty_check_change(tty, SIGTTIN); in job_control()
2156 static ssize_t n_tty_read(struct tty_struct *tty, struct file *file, in n_tty_read() argument
2159 struct n_tty_data *ldata = tty->disc_data; in n_tty_read()
2169 c = job_control(tty, file); in n_tty_read()
2184 down_read(&tty->termios_rwsem); in n_tty_read()
2189 minimum = MIN_CHAR(tty); in n_tty_read()
2191 time = (HZ / 10) * TIME_CHAR(tty); in n_tty_read()
2194 else if (!waitqueue_active(&tty->read_wait) || in n_tty_read()
2198 timeout = (HZ / 10) * TIME_CHAR(tty); in n_tty_read()
2203 packet = tty->packet; in n_tty_read()
2206 add_wait_queue(&tty->read_wait, &wait); in n_tty_read()
2209 if (packet && tty->link->ctrl_status) { in n_tty_read()
2213 spin_lock_irq(&tty->link->ctrl_lock); in n_tty_read()
2214 cs = tty->link->ctrl_status; in n_tty_read()
2215 tty->link->ctrl_status = 0; in n_tty_read()
2216 spin_unlock_irq(&tty->link->ctrl_lock); in n_tty_read()
2217 if (tty_put_user(tty, cs, b++)) { in n_tty_read()
2230 if (!input_available_p(tty, 0)) { in n_tty_read()
2231 up_read(&tty->termios_rwsem); in n_tty_read()
2232 tty_buffer_flush_work(tty->port); in n_tty_read()
2233 down_read(&tty->termios_rwsem); in n_tty_read()
2234 if (!input_available_p(tty, 0)) { in n_tty_read()
2235 if (test_bit(TTY_OTHER_CLOSED, &tty->flags)) { in n_tty_read()
2251 up_read(&tty->termios_rwsem); in n_tty_read()
2256 down_read(&tty->termios_rwsem); in n_tty_read()
2261 if (ldata->icanon && !L_EXTPROC(tty)) { in n_tty_read()
2262 retval = canon_copy_from_read_buf(tty, &b, &nr); in n_tty_read()
2270 if (tty_put_user(tty, TIOCPKT_DATA, b++)) { in n_tty_read()
2278 uncopied = copy_from_read_buf(tty, &b, &nr); in n_tty_read()
2279 uncopied += copy_from_read_buf(tty, &b, &nr); in n_tty_read()
2286 n_tty_check_unthrottle(tty); in n_tty_read()
2294 n_tty_kick_worker(tty); in n_tty_read()
2295 up_read(&tty->termios_rwsem); in n_tty_read()
2297 remove_wait_queue(&tty->read_wait, &wait); in n_tty_read()
2298 if (!waitqueue_active(&tty->read_wait)) in n_tty_read()
2331 static ssize_t n_tty_write(struct tty_struct *tty, struct file *file, in n_tty_write() argument
2340 if (L_TOSTOP(tty) && file->f_op->write != redirected_tty_write) { in n_tty_write()
2341 retval = tty_check_change(tty); in n_tty_write()
2346 down_read(&tty->termios_rwsem); in n_tty_write()
2349 process_echoes(tty); in n_tty_write()
2351 add_wait_queue(&tty->write_wait, &wait); in n_tty_write()
2357 if (tty_hung_up_p(file) || (tty->link && !tty->link->count)) { in n_tty_write()
2361 if (O_OPOST(tty)) { in n_tty_write()
2363 ssize_t num = process_output_block(tty, b, nr); in n_tty_write()
2375 if (process_output(c, tty) < 0) in n_tty_write()
2379 if (tty->ops->flush_chars) in n_tty_write()
2380 tty->ops->flush_chars(tty); in n_tty_write()
2382 struct n_tty_data *ldata = tty->disc_data; in n_tty_write()
2386 c = tty->ops->write(tty, b, nr); in n_tty_write()
2404 up_read(&tty->termios_rwsem); in n_tty_write()
2408 down_read(&tty->termios_rwsem); in n_tty_write()
2411 remove_wait_queue(&tty->write_wait, &wait); in n_tty_write()
2412 if (b - buf != nr && tty->fasync) in n_tty_write()
2413 set_bit(TTY_DO_WRITE_WAKEUP, &tty->flags); in n_tty_write()
2414 up_read(&tty->termios_rwsem); in n_tty_write()
2432 static unsigned int n_tty_poll(struct tty_struct *tty, struct file *file, in n_tty_poll() argument
2435 struct n_tty_data *ldata = tty->disc_data; in n_tty_poll()
2438 poll_wait(file, &tty->read_wait, wait); in n_tty_poll()
2439 poll_wait(file, &tty->write_wait, wait); in n_tty_poll()
2440 if (input_available_p(tty, 1)) in n_tty_poll()
2443 tty_buffer_flush_work(tty->port); in n_tty_poll()
2444 if (input_available_p(tty, 1)) in n_tty_poll()
2447 if (tty->packet && tty->link->ctrl_status) in n_tty_poll()
2449 if (test_bit(TTY_OTHER_CLOSED, &tty->flags)) in n_tty_poll()
2454 if (MIN_CHAR(tty) && !TIME_CHAR(tty)) in n_tty_poll()
2455 ldata->minimum_to_wake = MIN_CHAR(tty); in n_tty_poll()
2459 if (tty->ops->write && !tty_is_writelocked(tty) && in n_tty_poll()
2460 tty_chars_in_buffer(tty) < WAKEUP_CHARS && in n_tty_poll()
2461 tty_write_room(tty) > 0) in n_tty_poll()
2485 static int n_tty_ioctl(struct tty_struct *tty, struct file *file, in n_tty_ioctl() argument
2488 struct n_tty_data *ldata = tty->disc_data; in n_tty_ioctl()
2493 return put_user(tty_chars_in_buffer(tty), (int __user *) arg); in n_tty_ioctl()
2495 down_write(&tty->termios_rwsem); in n_tty_ioctl()
2496 if (L_ICANON(tty)) in n_tty_ioctl()
2500 up_write(&tty->termios_rwsem); in n_tty_ioctl()
2503 return n_tty_ioctl_helper(tty, file, cmd, arg); in n_tty_ioctl()
2507 static void n_tty_fasync(struct tty_struct *tty, int on) in n_tty_fasync() argument
2509 struct n_tty_data *ldata = tty->disc_data; in n_tty_fasync()
2511 if (!waitqueue_active(&tty->read_wait)) { in n_tty_fasync()
2514 else if (!tty->fasync) in n_tty_fasync()