canon_copy_from_read_buf(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

✨ 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 with
  • kbp β€” data ✨ (it's a u8 **, so it's a pointer to a pointer, main character energy fr)
  • nr β€” size of data 🌸 a size_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_lock mutex 🫢
  • n_tty_read / consumer path: the caller holds non-exclusive termios_rwsem; read_tail published ⭐

🌈 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