canon_copy_from_read_buf(9)
β¨ canon_copy_from_read_buf π
ok so bestie, this is canon_copy_from_read_buf, and it lives in section 9 of the Kernel API Manual π like, it's a kernel function, not a command you type, so don't go trying to run it in your terminal okay π
π¦ NAME π¦
canon_copy_from_read_buf β it copies read data when you're in canonical mode β¨ lowkey the whole personality of this function tbh
πΈ SYNOPSIS πΈ
bool canon_copy_from_read_buf (const struct tty_struct *tty , u8 **kbp ,
size_t *nr );
it returns a bool, bestie. yes, that's the vibe π
π ARGUMENTS π
ttyβ the terminal device π₯οΈ like, the actual tty struct we're working withkbpβ data β¨ (it's au8 **, so it's a pointer to a pointer, main character energy fr)nrβ size of data πΈ asize_t *, and yes it's the size of that data
π DESCRIPTION π
okay so this is a helper function for n_tty_read, periodt. and the way that it only gets called when ICANON is on?? iconic. it copies one line of input β and bestie listen, that's up to and including the line-delimiting character π β straight into the result buffer. slay.
π₯ NOTE π₯
ngl this part is important so pay attention π
when termios gets changed from non-canonical to canonical mode and the read buffer already has data in it, n_tty_set_termios simulates an EOF push β like as if C-d had been input β _without_ the DISABLED_CHAR in the buffer. literally without it in the buffer, iykyk π
and what that does is it makes data that's already been processed as input immediately available as input, even though a newline hasn't been received yet. no newline, no problem π
π Locking π
- called under the
atomic_read_lockmutex π«Ά n_tty_read/ consumer path: the caller holds non-exclusivetermios_rwsem;read_tailpublished β
π SEE ALSO π
okay this list is long bestie, but we do not skip. every single one of these is getting its moment π
Kernel file ./drivers/tty/n_tty.c and honestly the whole n_tty fam:
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_receive_buf_common(9), n_tty_set_termios(9), n_tty_close(9), n_tty_open(9), 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) π
and that's the whole page, bestie π§ this one came from ./drivers/tty, dated October 2026, and it's canon_copy_from_read_buf(9) all the way down π go off, you understood all of it, I'm so proud of you π«Άβ¨
π¦ 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