n_tty_receive_buf_common(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

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 (if NULL, all chars are TTY_NORMAL) ✨
  • count β€” number of input chars in cp πŸ”’
  • 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:

byeee πŸŽ€ β€” source/version: ./drivers/tty Β· n_tty_receive_buf_common(9) Β· date: October 2026. mwah πŸ’‹

πŸ“¦ where this page comes from