tty.h 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef _LINUX_TTY_H
  3. #define _LINUX_TTY_H
  4. #include <linux/fs.h>
  5. #include <linux/major.h>
  6. #include <linux/termios.h>
  7. #include <linux/workqueue.h>
  8. #include <linux/tty_buffer.h>
  9. #include <linux/tty_driver.h>
  10. #include <linux/tty_ldisc.h>
  11. #include <linux/tty_port.h>
  12. #include <linux/mutex.h>
  13. #include <linux/tty_flags.h>
  14. #include <uapi/linux/tty.h>
  15. #include <linux/rwsem.h>
  16. #include <linux/llist.h>
  17. #include <linux/android_kabi.h>
  18. /*
  19. * (Note: the *_driver.minor_start values 1, 64, 128, 192 are
  20. * hardcoded at present.)
  21. */
  22. #define NR_UNIX98_PTY_DEFAULT 4096 /* Default maximum for Unix98 ptys */
  23. #define NR_UNIX98_PTY_RESERVE 1024 /* Default reserve for main devpts */
  24. #define NR_UNIX98_PTY_MAX (1 << MINORBITS) /* Absolute limit */
  25. /*
  26. * This character is the same as _POSIX_VDISABLE: it cannot be used as
  27. * a c_cc[] character, but indicates that a particular special character
  28. * isn't in use (eg VINTR has no character etc)
  29. */
  30. #define __DISABLED_CHAR '\0'
  31. #define INTR_CHAR(tty) ((tty)->termios.c_cc[VINTR])
  32. #define QUIT_CHAR(tty) ((tty)->termios.c_cc[VQUIT])
  33. #define ERASE_CHAR(tty) ((tty)->termios.c_cc[VERASE])
  34. #define KILL_CHAR(tty) ((tty)->termios.c_cc[VKILL])
  35. #define EOF_CHAR(tty) ((tty)->termios.c_cc[VEOF])
  36. #define TIME_CHAR(tty) ((tty)->termios.c_cc[VTIME])
  37. #define MIN_CHAR(tty) ((tty)->termios.c_cc[VMIN])
  38. #define SWTC_CHAR(tty) ((tty)->termios.c_cc[VSWTC])
  39. #define START_CHAR(tty) ((tty)->termios.c_cc[VSTART])
  40. #define STOP_CHAR(tty) ((tty)->termios.c_cc[VSTOP])
  41. #define SUSP_CHAR(tty) ((tty)->termios.c_cc[VSUSP])
  42. #define EOL_CHAR(tty) ((tty)->termios.c_cc[VEOL])
  43. #define REPRINT_CHAR(tty) ((tty)->termios.c_cc[VREPRINT])
  44. #define DISCARD_CHAR(tty) ((tty)->termios.c_cc[VDISCARD])
  45. #define WERASE_CHAR(tty) ((tty)->termios.c_cc[VWERASE])
  46. #define LNEXT_CHAR(tty) ((tty)->termios.c_cc[VLNEXT])
  47. #define EOL2_CHAR(tty) ((tty)->termios.c_cc[VEOL2])
  48. #define _I_FLAG(tty, f) ((tty)->termios.c_iflag & (f))
  49. #define _O_FLAG(tty, f) ((tty)->termios.c_oflag & (f))
  50. #define _C_FLAG(tty, f) ((tty)->termios.c_cflag & (f))
  51. #define _L_FLAG(tty, f) ((tty)->termios.c_lflag & (f))
  52. #define I_IGNBRK(tty) _I_FLAG((tty), IGNBRK)
  53. #define I_BRKINT(tty) _I_FLAG((tty), BRKINT)
  54. #define I_IGNPAR(tty) _I_FLAG((tty), IGNPAR)
  55. #define I_PARMRK(tty) _I_FLAG((tty), PARMRK)
  56. #define I_INPCK(tty) _I_FLAG((tty), INPCK)
  57. #define I_ISTRIP(tty) _I_FLAG((tty), ISTRIP)
  58. #define I_INLCR(tty) _I_FLAG((tty), INLCR)
  59. #define I_IGNCR(tty) _I_FLAG((tty), IGNCR)
  60. #define I_ICRNL(tty) _I_FLAG((tty), ICRNL)
  61. #define I_IUCLC(tty) _I_FLAG((tty), IUCLC)
  62. #define I_IXON(tty) _I_FLAG((tty), IXON)
  63. #define I_IXANY(tty) _I_FLAG((tty), IXANY)
  64. #define I_IXOFF(tty) _I_FLAG((tty), IXOFF)
  65. #define I_IMAXBEL(tty) _I_FLAG((tty), IMAXBEL)
  66. #define I_IUTF8(tty) _I_FLAG((tty), IUTF8)
  67. #define O_OPOST(tty) _O_FLAG((tty), OPOST)
  68. #define O_OLCUC(tty) _O_FLAG((tty), OLCUC)
  69. #define O_ONLCR(tty) _O_FLAG((tty), ONLCR)
  70. #define O_OCRNL(tty) _O_FLAG((tty), OCRNL)
  71. #define O_ONOCR(tty) _O_FLAG((tty), ONOCR)
  72. #define O_ONLRET(tty) _O_FLAG((tty), ONLRET)
  73. #define O_OFILL(tty) _O_FLAG((tty), OFILL)
  74. #define O_OFDEL(tty) _O_FLAG((tty), OFDEL)
  75. #define O_NLDLY(tty) _O_FLAG((tty), NLDLY)
  76. #define O_CRDLY(tty) _O_FLAG((tty), CRDLY)
  77. #define O_TABDLY(tty) _O_FLAG((tty), TABDLY)
  78. #define O_BSDLY(tty) _O_FLAG((tty), BSDLY)
  79. #define O_VTDLY(tty) _O_FLAG((tty), VTDLY)
  80. #define O_FFDLY(tty) _O_FLAG((tty), FFDLY)
  81. #define C_BAUD(tty) _C_FLAG((tty), CBAUD)
  82. #define C_CSIZE(tty) _C_FLAG((tty), CSIZE)
  83. #define C_CSTOPB(tty) _C_FLAG((tty), CSTOPB)
  84. #define C_CREAD(tty) _C_FLAG((tty), CREAD)
  85. #define C_PARENB(tty) _C_FLAG((tty), PARENB)
  86. #define C_PARODD(tty) _C_FLAG((tty), PARODD)
  87. #define C_HUPCL(tty) _C_FLAG((tty), HUPCL)
  88. #define C_CLOCAL(tty) _C_FLAG((tty), CLOCAL)
  89. #define C_CIBAUD(tty) _C_FLAG((tty), CIBAUD)
  90. #define C_CRTSCTS(tty) _C_FLAG((tty), CRTSCTS)
  91. #define C_CMSPAR(tty) _C_FLAG((tty), CMSPAR)
  92. #define L_ISIG(tty) _L_FLAG((tty), ISIG)
  93. #define L_ICANON(tty) _L_FLAG((tty), ICANON)
  94. #define L_XCASE(tty) _L_FLAG((tty), XCASE)
  95. #define L_ECHO(tty) _L_FLAG((tty), ECHO)
  96. #define L_ECHOE(tty) _L_FLAG((tty), ECHOE)
  97. #define L_ECHOK(tty) _L_FLAG((tty), ECHOK)
  98. #define L_ECHONL(tty) _L_FLAG((tty), ECHONL)
  99. #define L_NOFLSH(tty) _L_FLAG((tty), NOFLSH)
  100. #define L_TOSTOP(tty) _L_FLAG((tty), TOSTOP)
  101. #define L_ECHOCTL(tty) _L_FLAG((tty), ECHOCTL)
  102. #define L_ECHOPRT(tty) _L_FLAG((tty), ECHOPRT)
  103. #define L_ECHOKE(tty) _L_FLAG((tty), ECHOKE)
  104. #define L_FLUSHO(tty) _L_FLAG((tty), FLUSHO)
  105. #define L_PENDIN(tty) _L_FLAG((tty), PENDIN)
  106. #define L_IEXTEN(tty) _L_FLAG((tty), IEXTEN)
  107. #define L_EXTPROC(tty) _L_FLAG((tty), EXTPROC)
  108. struct device;
  109. struct signal_struct;
  110. struct tty_operations;
  111. /**
  112. * struct tty_struct - state associated with a tty while open
  113. *
  114. * @kref: reference counting by tty_kref_get() and tty_kref_put(), reaching zero
  115. * frees the structure
  116. * @dev: class device or %NULL (e.g. ptys, serdev)
  117. * @driver: &struct tty_driver operating this tty
  118. * @ops: &struct tty_operations of @driver for this tty (open, close, etc.)
  119. * @index: index of this tty (e.g. to construct @name like tty12)
  120. * @ldisc_sem: protects line discipline changes (@ldisc) -- lock tty not pty
  121. * @ldisc: the current line discipline for this tty (n_tty by default)
  122. * @atomic_write_lock: protects against concurrent writers, i.e. locks
  123. * @write_cnt, @write_buf and similar
  124. * @legacy_mutex: leftover from history (BKL -> BTM -> @legacy_mutex),
  125. * protecting several operations on this tty
  126. * @throttle_mutex: protects against concurrent tty_throttle_safe() and
  127. * tty_unthrottle_safe() (but not tty_unthrottle())
  128. * @termios_rwsem: protects @termios and @termios_locked
  129. * @winsize_mutex: protects @winsize
  130. * @termios: termios for the current tty, copied from/to @driver.termios
  131. * @termios_locked: locked termios (by %TIOCGLCKTRMIOS and %TIOCSLCKTRMIOS
  132. * ioctls)
  133. * @name: name of the tty constructed by tty_line_name() (e.g. ttyS3)
  134. * @flags: bitwise OR of %TTY_THROTTLED, %TTY_IO_ERROR, ...
  135. * @count: count of open processes, reaching zero cancels all the work for
  136. * this tty and drops a @kref too (but does not free this tty)
  137. * @winsize: size of the terminal "window" (cf. @winsize_mutex)
  138. * @flow: flow settings grouped together, see also @flow.unused
  139. * @flow.lock: lock for @flow members
  140. * @flow.stopped: tty stopped/started by stop_tty()/start_tty()
  141. * @flow.tco_stopped: tty stopped/started by %TCOOFF/%TCOON ioctls (it has
  142. * precedence over @flow.stopped)
  143. * @flow.unused: alignment for Alpha, so that no members other than @flow.* are
  144. * modified by the same 64b word store. The @flow's __aligned is
  145. * there for the very same reason.
  146. * @ctrl: control settings grouped together, see also @ctrl.unused
  147. * @ctrl.lock: lock for @ctrl members
  148. * @ctrl.pgrp: process group of this tty (setpgrp(2))
  149. * @ctrl.session: session of this tty (setsid(2)). Writes are protected by both
  150. * @ctrl.lock and @legacy_mutex, readers must use at least one of
  151. * them.
  152. * @ctrl.pktstatus: packet mode status (bitwise OR of %TIOCPKT_ constants)
  153. * @ctrl.packet: packet mode enabled
  154. * @ctrl.unused: alignment for Alpha, see @flow.unused for explanation
  155. * @hw_stopped: not controlled by the tty layer, under @driver's control for CTS
  156. * handling
  157. * @receive_room: bytes permitted to feed to @ldisc without any being lost
  158. * @flow_change: controls behavior of throttling, see tty_throttle_safe() and
  159. * tty_unthrottle_safe()
  160. * @link: link to another pty (master -> slave and vice versa)
  161. * @fasync: state for %O_ASYNC (for %SIGIO); managed by fasync_helper()
  162. * @write_wait: concurrent writers are waiting in this queue until they are
  163. * allowed to write
  164. * @read_wait: readers wait for data in this queue
  165. * @hangup_work: normally a work to perform a hangup (do_tty_hangup()); while
  166. * freeing the tty, (re)used to release_one_tty()
  167. * @disc_data: pointer to @ldisc's private data (e.g. to &struct n_tty_data)
  168. * @driver_data: pointer to @driver's private data (e.g. &struct uart_state)
  169. * @files_lock: protects @tty_files list
  170. * @tty_files: list of (re)openers of this tty (i.e. linked &struct
  171. * tty_file_private)
  172. * @closing: when set during close, n_tty processes only START & STOP chars
  173. * @write_buf: temporary buffer used during tty_write() to copy user data to
  174. * @write_cnt: count of bytes written in tty_write() to @write_buf
  175. * @SAK_work: if the tty has a pending do_SAK, it is queued here
  176. * @port: persistent storage for this device (i.e. &struct tty_port)
  177. *
  178. * All of the state associated with a tty while the tty is open. Persistent
  179. * storage for tty devices is referenced here as @port and is documented in
  180. * &struct tty_port.
  181. */
  182. struct tty_struct {
  183. struct kref kref;
  184. struct device *dev;
  185. struct tty_driver *driver;
  186. const struct tty_operations *ops;
  187. int index;
  188. struct ld_semaphore ldisc_sem;
  189. struct tty_ldisc *ldisc;
  190. struct mutex atomic_write_lock;
  191. struct mutex legacy_mutex;
  192. struct mutex throttle_mutex;
  193. struct rw_semaphore termios_rwsem;
  194. struct mutex winsize_mutex;
  195. struct ktermios termios, termios_locked;
  196. char name[64];
  197. unsigned long flags;
  198. int count;
  199. struct winsize winsize;
  200. struct {
  201. spinlock_t lock;
  202. bool stopped;
  203. bool tco_stopped;
  204. unsigned long unused[0];
  205. } __aligned(sizeof(unsigned long)) flow;
  206. struct {
  207. spinlock_t lock;
  208. struct pid *pgrp;
  209. struct pid *session;
  210. unsigned char pktstatus;
  211. bool packet;
  212. unsigned long unused[0];
  213. } __aligned(sizeof(unsigned long)) ctrl;
  214. int hw_stopped;
  215. unsigned int receive_room;
  216. int flow_change;
  217. struct tty_struct *link;
  218. struct fasync_struct *fasync;
  219. wait_queue_head_t write_wait;
  220. wait_queue_head_t read_wait;
  221. struct work_struct hangup_work;
  222. void *disc_data;
  223. void *driver_data;
  224. spinlock_t files_lock;
  225. struct list_head tty_files;
  226. #define N_TTY_BUF_SIZE 4096
  227. int closing;
  228. unsigned char *write_buf;
  229. int write_cnt;
  230. struct work_struct SAK_work;
  231. struct tty_port *port;
  232. ANDROID_KABI_RESERVE(1);
  233. ANDROID_KABI_RESERVE(2);
  234. } __randomize_layout;
  235. /* Each of a tty's open files has private_data pointing to tty_file_private */
  236. struct tty_file_private {
  237. struct tty_struct *tty;
  238. struct file *file;
  239. struct list_head list;
  240. };
  241. /**
  242. * DOC: TTY Struct Flags
  243. *
  244. * These bits are used in the :c:member:`tty_struct.flags` field.
  245. *
  246. * So that interrupts won't be able to mess up the queues,
  247. * copy_to_cooked must be atomic with respect to itself, as must
  248. * tty->write. Thus, you must use the inline functions set_bit() and
  249. * clear_bit() to make things atomic.
  250. *
  251. * TTY_THROTTLED
  252. * Driver input is throttled. The ldisc should call
  253. * :c:member:`tty_driver.unthrottle()` in order to resume reception when
  254. * it is ready to process more data (at threshold min).
  255. *
  256. * TTY_IO_ERROR
  257. * If set, causes all subsequent userspace read/write calls on the tty to
  258. * fail, returning -%EIO. (May be no ldisc too.)
  259. *
  260. * TTY_OTHER_CLOSED
  261. * Device is a pty and the other side has closed.
  262. *
  263. * TTY_EXCLUSIVE
  264. * Exclusive open mode (a single opener).
  265. *
  266. * TTY_DO_WRITE_WAKEUP
  267. * If set, causes the driver to call the
  268. * :c:member:`tty_ldisc_ops.write_wakeup()` method in order to resume
  269. * transmission when it can accept more data to transmit.
  270. *
  271. * TTY_LDISC_OPEN
  272. * Indicates that a line discipline is open. For debugging purposes only.
  273. *
  274. * TTY_PTY_LOCK
  275. * A flag private to pty code to implement %TIOCSPTLCK/%TIOCGPTLCK logic.
  276. *
  277. * TTY_NO_WRITE_SPLIT
  278. * Prevent driver from splitting up writes into smaller chunks (preserve
  279. * write boundaries to driver).
  280. *
  281. * TTY_HUPPED
  282. * The TTY was hung up. This is set post :c:member:`tty_driver.hangup()`.
  283. *
  284. * TTY_HUPPING
  285. * The TTY is in the process of hanging up to abort potential readers.
  286. *
  287. * TTY_LDISC_CHANGING
  288. * Line discipline for this TTY is being changed. I/O should not block
  289. * when this is set. Use tty_io_nonblock() to check.
  290. *
  291. * TTY_LDISC_HALTED
  292. * Line discipline for this TTY was stopped. No work should be queued to
  293. * this ldisc.
  294. */
  295. #define TTY_THROTTLED 0
  296. #define TTY_IO_ERROR 1
  297. #define TTY_OTHER_CLOSED 2
  298. #define TTY_EXCLUSIVE 3
  299. #define TTY_DO_WRITE_WAKEUP 5
  300. #define TTY_LDISC_OPEN 11
  301. #define TTY_PTY_LOCK 16
  302. #define TTY_NO_WRITE_SPLIT 17
  303. #define TTY_HUPPED 18
  304. #define TTY_HUPPING 19
  305. #define TTY_LDISC_CHANGING 20
  306. #define TTY_LDISC_HALTED 22
  307. static inline bool tty_io_nonblock(struct tty_struct *tty, struct file *file)
  308. {
  309. return file->f_flags & O_NONBLOCK ||
  310. test_bit(TTY_LDISC_CHANGING, &tty->flags);
  311. }
  312. static inline bool tty_io_error(struct tty_struct *tty)
  313. {
  314. return test_bit(TTY_IO_ERROR, &tty->flags);
  315. }
  316. static inline bool tty_throttled(struct tty_struct *tty)
  317. {
  318. return test_bit(TTY_THROTTLED, &tty->flags);
  319. }
  320. #ifdef CONFIG_TTY
  321. void tty_kref_put(struct tty_struct *tty);
  322. struct pid *tty_get_pgrp(struct tty_struct *tty);
  323. void tty_vhangup_self(void);
  324. void disassociate_ctty(int priv);
  325. dev_t tty_devnum(struct tty_struct *tty);
  326. void proc_clear_tty(struct task_struct *p);
  327. struct tty_struct *get_current_tty(void);
  328. /* tty_io.c */
  329. int __init tty_init(void);
  330. const char *tty_name(const struct tty_struct *tty);
  331. struct tty_struct *tty_kopen_exclusive(dev_t device);
  332. struct tty_struct *tty_kopen_shared(dev_t device);
  333. void tty_kclose(struct tty_struct *tty);
  334. int tty_dev_name_to_number(const char *name, dev_t *number);
  335. #else
  336. static inline void tty_kref_put(struct tty_struct *tty)
  337. { }
  338. static inline struct pid *tty_get_pgrp(struct tty_struct *tty)
  339. { return NULL; }
  340. static inline void tty_vhangup_self(void)
  341. { }
  342. static inline void disassociate_ctty(int priv)
  343. { }
  344. static inline dev_t tty_devnum(struct tty_struct *tty)
  345. { return 0; }
  346. static inline void proc_clear_tty(struct task_struct *p)
  347. { }
  348. static inline struct tty_struct *get_current_tty(void)
  349. { return NULL; }
  350. /* tty_io.c */
  351. static inline int __init tty_init(void)
  352. { return 0; }
  353. static inline const char *tty_name(const struct tty_struct *tty)
  354. { return "(none)"; }
  355. static inline struct tty_struct *tty_kopen_exclusive(dev_t device)
  356. { return ERR_PTR(-ENODEV); }
  357. static inline void tty_kclose(struct tty_struct *tty)
  358. { }
  359. static inline int tty_dev_name_to_number(const char *name, dev_t *number)
  360. { return -ENOTSUPP; }
  361. #endif
  362. extern struct ktermios tty_std_termios;
  363. int vcs_init(void);
  364. extern struct class *tty_class;
  365. /**
  366. * tty_kref_get - get a tty reference
  367. * @tty: tty device
  368. *
  369. * Return a new reference to a tty object. The caller must hold
  370. * sufficient locks/counts to ensure that their existing reference cannot
  371. * go away
  372. */
  373. static inline struct tty_struct *tty_kref_get(struct tty_struct *tty)
  374. {
  375. if (tty)
  376. kref_get(&tty->kref);
  377. return tty;
  378. }
  379. const char *tty_driver_name(const struct tty_struct *tty);
  380. void tty_wait_until_sent(struct tty_struct *tty, long timeout);
  381. void stop_tty(struct tty_struct *tty);
  382. void start_tty(struct tty_struct *tty);
  383. void tty_write_message(struct tty_struct *tty, char *msg);
  384. int tty_send_xchar(struct tty_struct *tty, char ch);
  385. int tty_put_char(struct tty_struct *tty, unsigned char c);
  386. unsigned int tty_chars_in_buffer(struct tty_struct *tty);
  387. unsigned int tty_write_room(struct tty_struct *tty);
  388. void tty_driver_flush_buffer(struct tty_struct *tty);
  389. void tty_unthrottle(struct tty_struct *tty);
  390. int tty_throttle_safe(struct tty_struct *tty);
  391. int tty_unthrottle_safe(struct tty_struct *tty);
  392. int tty_do_resize(struct tty_struct *tty, struct winsize *ws);
  393. int tty_get_icount(struct tty_struct *tty,
  394. struct serial_icounter_struct *icount);
  395. int is_current_pgrp_orphaned(void);
  396. void tty_hangup(struct tty_struct *tty);
  397. void tty_vhangup(struct tty_struct *tty);
  398. int tty_hung_up_p(struct file *filp);
  399. void do_SAK(struct tty_struct *tty);
  400. void __do_SAK(struct tty_struct *tty);
  401. void no_tty(void);
  402. speed_t tty_termios_baud_rate(const struct ktermios *termios);
  403. void tty_termios_encode_baud_rate(struct ktermios *termios, speed_t ibaud,
  404. speed_t obaud);
  405. void tty_encode_baud_rate(struct tty_struct *tty, speed_t ibaud,
  406. speed_t obaud);
  407. /**
  408. * tty_get_baud_rate - get tty bit rates
  409. * @tty: tty to query
  410. *
  411. * Returns the baud rate as an integer for this terminal. The
  412. * termios lock must be held by the caller and the terminal bit
  413. * flags may be updated.
  414. *
  415. * Locking: none
  416. */
  417. static inline speed_t tty_get_baud_rate(struct tty_struct *tty)
  418. {
  419. return tty_termios_baud_rate(&tty->termios);
  420. }
  421. unsigned char tty_get_char_size(unsigned int cflag);
  422. unsigned char tty_get_frame_size(unsigned int cflag);
  423. void tty_termios_copy_hw(struct ktermios *new, const struct ktermios *old);
  424. int tty_termios_hw_change(const struct ktermios *a, const struct ktermios *b);
  425. int tty_set_termios(struct tty_struct *tty, struct ktermios *kt);
  426. void tty_wakeup(struct tty_struct *tty);
  427. int tty_mode_ioctl(struct tty_struct *tty, unsigned int cmd, unsigned long arg);
  428. int tty_perform_flush(struct tty_struct *tty, unsigned long arg);
  429. struct tty_struct *tty_init_dev(struct tty_driver *driver, int idx);
  430. void tty_release_struct(struct tty_struct *tty, int idx);
  431. void tty_init_termios(struct tty_struct *tty);
  432. void tty_save_termios(struct tty_struct *tty);
  433. int tty_standard_install(struct tty_driver *driver,
  434. struct tty_struct *tty);
  435. extern struct mutex tty_mutex;
  436. /* n_tty.c */
  437. void n_tty_inherit_ops(struct tty_ldisc_ops *ops);
  438. #ifdef CONFIG_TTY
  439. void __init n_tty_init(void);
  440. #else
  441. static inline void n_tty_init(void) { }
  442. #endif
  443. /* tty_audit.c */
  444. #ifdef CONFIG_AUDIT
  445. void tty_audit_exit(void);
  446. void tty_audit_fork(struct signal_struct *sig);
  447. int tty_audit_push(void);
  448. #else
  449. static inline void tty_audit_exit(void)
  450. {
  451. }
  452. static inline void tty_audit_fork(struct signal_struct *sig)
  453. {
  454. }
  455. static inline int tty_audit_push(void)
  456. {
  457. return 0;
  458. }
  459. #endif
  460. /* tty_ioctl.c */
  461. int n_tty_ioctl_helper(struct tty_struct *tty, unsigned int cmd,
  462. unsigned long arg);
  463. /* vt.c */
  464. int vt_ioctl(struct tty_struct *tty, unsigned int cmd, unsigned long arg);
  465. long vt_compat_ioctl(struct tty_struct *tty, unsigned int cmd,
  466. unsigned long arg);
  467. /* tty_mutex.c */
  468. /* functions for preparation of BKL removal */
  469. void tty_lock(struct tty_struct *tty);
  470. int tty_lock_interruptible(struct tty_struct *tty);
  471. void tty_unlock(struct tty_struct *tty);
  472. void tty_lock_slave(struct tty_struct *tty);
  473. void tty_unlock_slave(struct tty_struct *tty);
  474. void tty_set_lock_subclass(struct tty_struct *tty);
  475. #endif