include/linux/tty.h
Source file repositories/reference/linux-study-clean/include/linux/tty.h
File Facts
- System
- Linux kernel
- Corpus path
include/linux/tty.h- Extension
.h- Size
- 17553 bytes
- Lines
- 512
- Domain
- Core OS
- Bucket
- Core Kernel Interface
- Inferred role
- Core OS: implementation source
- Status
- source implementation candidate
Why This File Exists
Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/fs.hlinux/major.hlinux/termios.hlinux/workqueue.hlinux/tty_driver.hlinux/tty_ldisc.hlinux/tty_port.hlinux/mutex.hlinux/tty_flags.huapi/linux/tty.hlinux/rwsem.hlinux/llist.h
Detected Declarations
struct devicestruct signal_structstruct tty_operationsstruct tty_structstruct tty_file_privateenum tty_struct_flagsfunction tty_io_nonblockfunction tty_io_errorfunction tty_throttledfunction tty_kref_putfunction tty_vhangup_selffunction proc_clear_ttyfunction tty_initfunction tty_kclosefunction tty_get_baud_ratefunction n_tty_initfunction tty_audit_exit
Annotated Snippet
struct tty_struct {
struct kref kref;
int index;
struct device *dev;
struct tty_driver *driver;
struct tty_port *port;
const struct tty_operations *ops;
struct tty_ldisc *ldisc;
struct ld_semaphore ldisc_sem;
struct mutex atomic_write_lock;
struct mutex legacy_mutex;
struct mutex throttle_mutex;
struct rw_semaphore termios_rwsem;
struct mutex winsize_mutex;
struct ktermios termios, termios_locked;
char name[64];
unsigned long flags;
int count;
unsigned int receive_room;
struct winsize winsize;
struct {
spinlock_t lock;
bool stopped;
bool tco_stopped;
} flow;
struct {
struct pid *pgrp;
struct pid *session;
spinlock_t lock;
unsigned char pktstatus;
bool packet;
} ctrl;
bool hw_stopped;
bool closing;
int flow_change;
struct tty_struct *link;
struct fasync_struct *fasync;
wait_queue_head_t write_wait;
wait_queue_head_t read_wait;
struct work_struct hangup_work;
void *disc_data;
void *driver_data;
spinlock_t files_lock;
int write_cnt;
u8 *write_buf;
struct list_head tty_files;
struct work_struct SAK_work;
} __randomize_layout;
/* Each of a tty's open files has private_data pointing to tty_file_private */
struct tty_file_private {
struct tty_struct *tty;
struct file *file;
struct list_head list;
};
/**
* enum tty_struct_flags - TTY Struct Flags
*
* These bits are used in the :c:member:`tty_struct.flags` field.
*
* So that interrupts won't be able to mess up the queues,
* copy_to_cooked must be atomic with respect to itself, as must
* tty->write. Thus, you must use the inline functions set_bit() and
* clear_bit() to make things atomic.
*
* @TTY_THROTTLED:
* Driver input is throttled. The ldisc should call
* :c:member:`tty_driver.unthrottle()` in order to resume reception when
* it is ready to process more data (at threshold min).
*
* @TTY_IO_ERROR:
* If set, causes all subsequent userspace read/write calls on the tty to
* fail, returning -%EIO. (May be no ldisc too.)
*
* @TTY_OTHER_CLOSED:
* Device is a pty and the other side has closed.
*
* @TTY_EXCLUSIVE:
* Exclusive open mode (a single opener).
*
* @TTY_DO_WRITE_WAKEUP:
Annotation
- Immediate include surface: `linux/fs.h`, `linux/major.h`, `linux/termios.h`, `linux/workqueue.h`, `linux/tty_driver.h`, `linux/tty_ldisc.h`, `linux/tty_port.h`, `linux/mutex.h`.
- Detected declarations: `struct device`, `struct signal_struct`, `struct tty_operations`, `struct tty_struct`, `struct tty_file_private`, `enum tty_struct_flags`, `function tty_io_nonblock`, `function tty_io_error`, `function tty_throttled`, `function tty_kref_put`.
- Atlas domain: Core OS / Core Kernel Interface.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.