n_tty_receive_buf_common(9)
hiii bestie π welcome to the n_tty_receive_buf_common(9) page from the Kernel API Manual. this is the process input function, and we are keeping every single deet because the kernel does not do βclose enoughβ and neither do we. no cap. β¨
π NAME π
n_tty_receive_buf_common β process input. that's the whole name, and it's iconic.
β¨ SYNOPSIS β¨
size_t n_tty_receive_buf_common (struct tty_struct *tty , const u8 *cp ,
const u8 *fp , size_t count , bool flow );
π ARGUMENTS π
ttyβ device to receive input π«Άcpβ input chars πfpβ flags for each char (ifNULL, all chars areTTY_NORMAL) β¨countβ number of input chars incpπ’flowβ enable flow control π
π¦ DESCRIPTION π¦
okay so the terminal driver calls this when a block of characters has been received. This function must be called from soft contexts, not from interrupt context β bestie, I cannot stress this enough π. The driver is responsible for making calls one at a time and in order (or using flush_to_ldisc).
β οΈ soft contexts only. not interrupt context. fr fr.
In canonical mode, the maximum line length is 4096 chars (including the line termination char); lines longer than 4096 chars are truncated. After 4095 chars, input data is still processed but not stored. Overflow processing ensures the tty can always receive more input until at least one line can be read. lowkey a whole little overflow safety net π«
In non-canonical mode, the read buffer will only accept 4095 chars; this provides the necessary space for a newline char if the input mode is switched to canonical. cute and practical π
Note it is possible for the read buffer to contain 4096 chars in non-canonical mode: the read buffer could already contain the maximum canon line of 4096 chars when the mode is switched to non-canonical. edge case spotted, details preserved π
Locking: n_tty_receive_buf/producer path: claims non-exclusive termios_rwsem; publishes commit_head or canon_head π
π RETURN π
the # of input chars from cp which were processed. that's the return value, and it's giving βcount your blessings but make it inputβ π
π SEE ALSO π
Kernel file ./drivers/tty/n_tty.c β plus the whole bestie squad:
n_tty_kick_worker(9)n_tty_write_wakeup(9)put_tty_queue(9)reset_buffer_flags(9)n_tty_flush_buffer(9)is_utf8_continuation(9)is_continuation(9)do_output_char(9)process_output(9)process_output_block(9)__process_echoes(9)add_echo_byte(9)echo_move_back_col(9)echo_set_canon_col(9)echo_erase_tab(9)echo_char_raw(9)echo_char(9)finish_erasing(9)eraser(9)isig(9)n_tty_receive_break(9)n_tty_receive_overrun(9)n_tty_receive_parity_error(9)n_tty_receive_char_flow_ctrl(9)n_tty_receive_char(9)n_tty_set_termios(9)n_tty_close(9)n_tty_open(9)copy_from_read_buf(9)canon_copy_from_read_buf(9)job_control(9)n_tty_read(9)n_tty_write(9)n_tty_poll(9)n_tty_inherit_ops(9)
byeee π β source/version: ./drivers/tty Β· n_tty_receive_buf_common(9) Β· date: October 2026. mwah π
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms