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