n_tty_write(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… n_tty_write(9) β€” like, the write function for tty, bestie

okay so real quick, this is from the Kernel API Manual (the kernel API girlies know), and it's literally the write function for a tty. buckle up πŸŽ€


✨ NAME ✨

n_tty_write β€” the write function for tty. that's it, that's the vibe. πŸ’–


🌸 SYNOPSIS 🌸

ssize_t n_tty_write (struct tty_struct *tty , struct file *file , const
       u8 *buf , size_t nr );

πŸ¦‹ ARGUMENTS πŸ¦‹

  • tty β€” the tty device. the main character of this whole situation πŸ‘‘
  • file β€” the file object, standard issue
  • buf β€” a userspace buffer pointer, so like, pointers into userspace, mwah πŸ’…
  • nr β€” the size of I/O, aka how much we're moving

πŸ’œ DESCRIPTION πŸ’œ

okay so this is the write function of the terminal device, periodt. here's the tea: it's serialized with respect to other write callers β€” but not to termios changes, reads, and other such events. so it plays nice with other writers and only other writers, iykyk πŸ™ˆ

and because the receive code will echo characters (which means it goes and calls the driver write methods!!), the output_lock is used in the output processing functions called here and in the echo processing function, to protect the column state and the space left in the buffer. teamwork, no cap 🫢

⚠️ this code must be sure never to sleep through a hangup. like, fr fr, that's a hard requirement, don't do it πŸ’€

πŸ”₯ Locking

output_lock protects the column state and the space left β€” and note that the process_output*() functions take this lock themselves, so don't go double-locking, bestie 😭


🌈 SEE ALSO 🌈

kernel file ./drivers/tty/n_tty.c β€” and honestly the whole friend group:


and that's the page, bestie 🧚✨ this icon came from ./drivers/tty, dated October 2026, and it's giving absolute legend behavior β€” go off, kernel docs πŸ’–πŸŽ€πŸ’…

πŸ“¦ where this page comes from