• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _LINUX_TTY_H
3 #define _LINUX_TTY_H
4 
5 #include <linux/fs.h>
6 #include <linux/major.h>
7 #include <linux/termios.h>
8 #include <linux/workqueue.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 
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 */
25 #define NR_UNIX98_PTY_RESERVE	1024	  /* Default reserve for main devpts */
26 #define NR_UNIX98_PTY_MAX	(1 << MINORBITS) /* Absolute limit */
27 
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 
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])
52 
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))
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)
99 #define C_CMSPAR(tty)	_C_FLAG((tty), CMSPAR)
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)
116 #define L_EXTPROC(tty)	_L_FLAG((tty), EXTPROC)
117 
118 struct device;
119 struct signal_struct;
120 struct tty_operations;
121 
122 /**
123  * struct tty_struct - state associated with a tty while open
124  *
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
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)
154  * @ctrl: control settings grouped together
155  * @ctrl.lock: lock for @ctrl members
156  * @ctrl.pgrp: process group of this tty (setpgrp(2))
157  * @ctrl.session: session of this tty (setsid(2)). Writes are protected by both
158  *		  @ctrl.lock and @legacy_mutex, readers must use at least one of
159  *		  them.
160  * @ctrl.pktstatus: packet mode status (bitwise OR of %TIOCPKT_ constants)
161  * @ctrl.packet: packet mode enabled
162  * @hw_stopped: not controlled by the tty layer, under @driver's control for CTS
163  *		handling
164  * @receive_room: bytes permitted to feed to @ldisc without any being lost
165  * @flow_change: controls behavior of throttling, see tty_throttle_safe() and
166  *		 tty_unthrottle_safe()
167  * @link: link to another pty (master -> slave and vice versa)
168  * @fasync: state for %O_ASYNC (for %SIGIO); managed by fasync_helper()
169  * @write_wait: concurrent writers are waiting in this queue until they are
170  *		allowed to write
171  * @read_wait: readers wait for data in this queue
172  * @hangup_work: normally a work to perform a hangup (do_tty_hangup()); while
173  *		 freeing the tty, (re)used to release_one_tty()
174  * @disc_data: pointer to @ldisc's private data (e.g. to &struct n_tty_data)
175  * @driver_data: pointer to @driver's private data (e.g. &struct uart_state)
176  * @files_lock:	protects @tty_files list
177  * @tty_files: list of (re)openers of this tty (i.e. linked &struct
178  *	       tty_file_private)
179  * @closing: when set during close, n_tty processes only START & STOP chars
180  * @write_buf: temporary buffer used during tty_write() to copy user data to
181  * @write_cnt: count of bytes written in tty_write() to @write_buf
182  * @SAK_work: if the tty has a pending do_SAK, it is queued here
183  * @port: persistent storage for this device (i.e. &struct tty_port)
184  *
185  * All of the state associated with a tty while the tty is open. Persistent
186  * storage for tty devices is referenced here as @port and is documented in
187  * &struct tty_port.
188  */
189 struct tty_struct {
190 	struct kref kref;
191 	int index;
192 	struct device *dev;
193 	struct tty_driver *driver;
194 	struct tty_port *port;
195 	const struct tty_operations *ops;
196 
197 	struct tty_ldisc *ldisc;
198 	struct ld_semaphore ldisc_sem;
199 
200 	struct mutex atomic_write_lock;
201 	struct mutex legacy_mutex;
202 	struct mutex throttle_mutex;
203 	struct rw_semaphore termios_rwsem;
204 	struct mutex winsize_mutex;
205 	struct ktermios termios, termios_locked;
206 	char name[64];
207 	unsigned long flags;
208 	int count;
209 	unsigned int receive_room;
210 	struct winsize winsize;
211 
212 	struct {
213 		spinlock_t lock;
214 		bool stopped;
215 		bool tco_stopped;
216 	} flow;
217 
218 	struct {
219 		struct pid *pgrp;
220 		struct pid *session;
221 		spinlock_t lock;
222 		unsigned char pktstatus;
223 		bool packet;
224 	} ctrl;
225 
226 	bool hw_stopped;
227 	bool closing;
228 	int flow_change;
229 
230 	struct tty_struct *link;
231 	struct fasync_struct *fasync;
232 	wait_queue_head_t write_wait;
233 	wait_queue_head_t read_wait;
234 	struct work_struct hangup_work;
235 	void *disc_data;
236 	void *driver_data;
237 	spinlock_t files_lock;
238 	int write_cnt;
239 	u8 *write_buf;
240 
241 	struct list_head tty_files;
242 
243 #define N_TTY_BUF_SIZE 4096
244 	struct work_struct SAK_work;
245 
246 	ANDROID_KABI_RESERVE(1);
247 	ANDROID_KABI_RESERVE(2);
248 } __randomize_layout;
249 
250 /* Each of a tty's open files has private_data pointing to tty_file_private */
251 struct tty_file_private {
252 	struct tty_struct *tty;
253 	struct file *file;
254 	struct list_head list;
255 };
256 
257 /**
258  * DOC: TTY Struct Flags
259  *
260  * These bits are used in the :c:member:`tty_struct.flags` field.
261  *
262  * So that interrupts won't be able to mess up the queues,
263  * copy_to_cooked must be atomic with respect to itself, as must
264  * tty->write.  Thus, you must use the inline functions set_bit() and
265  * clear_bit() to make things atomic.
266  *
267  * TTY_THROTTLED
268  *	Driver input is throttled. The ldisc should call
269  *	:c:member:`tty_driver.unthrottle()` in order to resume reception when
270  *	it is ready to process more data (at threshold min).
271  *
272  * TTY_IO_ERROR
273  *	If set, causes all subsequent userspace read/write calls on the tty to
274  *	fail, returning -%EIO. (May be no ldisc too.)
275  *
276  * TTY_OTHER_CLOSED
277  *	Device is a pty and the other side has closed.
278  *
279  * TTY_EXCLUSIVE
280  *	Exclusive open mode (a single opener).
281  *
282  * TTY_DO_WRITE_WAKEUP
283  *	If set, causes the driver to call the
284  *	:c:member:`tty_ldisc_ops.write_wakeup()` method in order to resume
285  *	transmission when it can accept more data to transmit.
286  *
287  * TTY_LDISC_OPEN
288  *	Indicates that a line discipline is open. For debugging purposes only.
289  *
290  * TTY_PTY_LOCK
291  *	A flag private to pty code to implement %TIOCSPTLCK/%TIOCGPTLCK logic.
292  *
293  * TTY_NO_WRITE_SPLIT
294  *	Prevent driver from splitting up writes into smaller chunks (preserve
295  *	write boundaries to driver).
296  *
297  * TTY_HUPPED
298  *	The TTY was hung up. This is set post :c:member:`tty_driver.hangup()`.
299  *
300  * TTY_HUPPING
301  *	The TTY is in the process of hanging up to abort potential readers.
302  *
303  * TTY_LDISC_CHANGING
304  *	Line discipline for this TTY is being changed. I/O should not block
305  *	when this is set. Use tty_io_nonblock() to check.
306  *
307  * TTY_LDISC_HALTED
308  *	Line discipline for this TTY was stopped. No work should be queued to
309  *	this ldisc.
310  */
311 #define TTY_THROTTLED		0
312 #define TTY_IO_ERROR		1
313 #define TTY_OTHER_CLOSED	2
314 #define TTY_EXCLUSIVE		3
315 #define TTY_DO_WRITE_WAKEUP	5
316 #define TTY_LDISC_OPEN		11
317 #define TTY_PTY_LOCK		16
318 #define TTY_NO_WRITE_SPLIT	17
319 #define TTY_HUPPED		18
320 #define TTY_HUPPING		19
321 #define TTY_LDISC_CHANGING	20
322 #define TTY_LDISC_HALTED	22
323 
tty_io_nonblock(struct tty_struct * tty,struct file * file)324 static inline bool tty_io_nonblock(struct tty_struct *tty, struct file *file)
325 {
326 	return file->f_flags & O_NONBLOCK ||
327 		test_bit(TTY_LDISC_CHANGING, &tty->flags);
328 }
329 
tty_io_error(struct tty_struct * tty)330 static inline bool tty_io_error(struct tty_struct *tty)
331 {
332 	return test_bit(TTY_IO_ERROR, &tty->flags);
333 }
334 
tty_throttled(struct tty_struct * tty)335 static inline bool tty_throttled(struct tty_struct *tty)
336 {
337 	return test_bit(TTY_THROTTLED, &tty->flags);
338 }
339 
340 #ifdef CONFIG_TTY
341 void tty_kref_put(struct tty_struct *tty);
342 struct pid *tty_get_pgrp(struct tty_struct *tty);
343 void tty_vhangup_self(void);
344 void disassociate_ctty(int priv);
345 dev_t tty_devnum(struct tty_struct *tty);
346 void proc_clear_tty(struct task_struct *p);
347 struct tty_struct *get_current_tty(void);
348 /* tty_io.c */
349 int __init tty_init(void);
350 const char *tty_name(const struct tty_struct *tty);
351 struct tty_struct *tty_kopen_exclusive(dev_t device);
352 struct tty_struct *tty_kopen_shared(dev_t device);
353 void tty_kclose(struct tty_struct *tty);
354 int tty_dev_name_to_number(const char *name, dev_t *number);
355 #else
tty_kref_put(struct tty_struct * tty)356 static inline void tty_kref_put(struct tty_struct *tty)
357 { }
tty_get_pgrp(struct tty_struct * tty)358 static inline struct pid *tty_get_pgrp(struct tty_struct *tty)
359 { return NULL; }
tty_vhangup_self(void)360 static inline void tty_vhangup_self(void)
361 { }
disassociate_ctty(int priv)362 static inline void disassociate_ctty(int priv)
363 { }
tty_devnum(struct tty_struct * tty)364 static inline dev_t tty_devnum(struct tty_struct *tty)
365 { return 0; }
proc_clear_tty(struct task_struct * p)366 static inline void proc_clear_tty(struct task_struct *p)
367 { }
get_current_tty(void)368 static inline struct tty_struct *get_current_tty(void)
369 { return NULL; }
370 /* tty_io.c */
tty_init(void)371 static inline int __init tty_init(void)
372 { return 0; }
tty_name(const struct tty_struct * tty)373 static inline const char *tty_name(const struct tty_struct *tty)
374 { return "(none)"; }
tty_kopen_exclusive(dev_t device)375 static inline struct tty_struct *tty_kopen_exclusive(dev_t device)
376 { return ERR_PTR(-ENODEV); }
tty_kclose(struct tty_struct * tty)377 static inline void tty_kclose(struct tty_struct *tty)
378 { }
tty_dev_name_to_number(const char * name,dev_t * number)379 static inline int tty_dev_name_to_number(const char *name, dev_t *number)
380 { return -ENOTSUPP; }
381 #endif
382 
383 extern struct ktermios tty_std_termios;
384 
385 int vcs_init(void);
386 
387 extern const struct class tty_class;
388 
389 /**
390  * tty_kref_get - get a tty reference
391  * @tty: tty device
392  *
393  * Returns: a new reference to a tty object
394  *
395  * Locking: The caller must hold sufficient locks/counts to ensure that their
396  * existing reference cannot go away.
397  */
tty_kref_get(struct tty_struct * tty)398 static inline struct tty_struct *tty_kref_get(struct tty_struct *tty)
399 {
400 	if (tty)
401 		kref_get(&tty->kref);
402 	return tty;
403 }
404 
405 const char *tty_driver_name(const struct tty_struct *tty);
406 void tty_wait_until_sent(struct tty_struct *tty, long timeout);
407 void stop_tty(struct tty_struct *tty);
408 void start_tty(struct tty_struct *tty);
409 void tty_write_message(struct tty_struct *tty, char *msg);
410 int tty_send_xchar(struct tty_struct *tty, u8 ch);
411 int tty_put_char(struct tty_struct *tty, u8 c);
412 unsigned int tty_chars_in_buffer(struct tty_struct *tty);
413 unsigned int tty_write_room(struct tty_struct *tty);
414 void tty_driver_flush_buffer(struct tty_struct *tty);
415 void tty_unthrottle(struct tty_struct *tty);
416 bool tty_throttle_safe(struct tty_struct *tty);
417 bool tty_unthrottle_safe(struct tty_struct *tty);
418 int tty_do_resize(struct tty_struct *tty, struct winsize *ws);
419 int tty_get_icount(struct tty_struct *tty,
420 		struct serial_icounter_struct *icount);
421 int tty_get_tiocm(struct tty_struct *tty);
422 int is_current_pgrp_orphaned(void);
423 void tty_hangup(struct tty_struct *tty);
424 void tty_vhangup(struct tty_struct *tty);
425 int tty_hung_up_p(struct file *filp);
426 void do_SAK(struct tty_struct *tty);
427 void __do_SAK(struct tty_struct *tty);
428 void no_tty(void);
429 speed_t tty_termios_baud_rate(const struct ktermios *termios);
430 void tty_termios_encode_baud_rate(struct ktermios *termios, speed_t ibaud,
431 		speed_t obaud);
432 void tty_encode_baud_rate(struct tty_struct *tty, speed_t ibaud,
433 		speed_t obaud);
434 
435 /**
436  * tty_get_baud_rate - get tty bit rates
437  * @tty: tty to query
438  *
439  * Returns: the baud rate as an integer for this terminal
440  *
441  * Locking: The termios lock must be held by the caller.
442  */
tty_get_baud_rate(const struct tty_struct * tty)443 static inline speed_t tty_get_baud_rate(const struct tty_struct *tty)
444 {
445 	return tty_termios_baud_rate(&tty->termios);
446 }
447 
448 unsigned char tty_get_char_size(unsigned int cflag);
449 unsigned char tty_get_frame_size(unsigned int cflag);
450 
451 void tty_termios_copy_hw(struct ktermios *new, const struct ktermios *old);
452 bool tty_termios_hw_change(const struct ktermios *a, const struct ktermios *b);
453 int tty_set_termios(struct tty_struct *tty, struct ktermios *kt);
454 
455 void tty_wakeup(struct tty_struct *tty);
456 
457 int tty_mode_ioctl(struct tty_struct *tty, unsigned int cmd, unsigned long arg);
458 int tty_perform_flush(struct tty_struct *tty, unsigned long arg);
459 struct tty_struct *tty_init_dev(struct tty_driver *driver, int idx);
460 void tty_release_struct(struct tty_struct *tty, int idx);
461 void tty_init_termios(struct tty_struct *tty);
462 void tty_save_termios(struct tty_struct *tty);
463 int tty_standard_install(struct tty_driver *driver,
464 		struct tty_struct *tty);
465 
466 extern struct mutex tty_mutex;
467 
468 /* n_tty.c */
469 void n_tty_inherit_ops(struct tty_ldisc_ops *ops);
470 #ifdef CONFIG_TTY
471 void __init n_tty_init(void);
472 #else
n_tty_init(void)473 static inline void n_tty_init(void) { }
474 #endif
475 
476 /* tty_audit.c */
477 #ifdef CONFIG_AUDIT
478 void tty_audit_exit(void);
479 void tty_audit_fork(struct signal_struct *sig);
480 int tty_audit_push(void);
481 #else
tty_audit_exit(void)482 static inline void tty_audit_exit(void)
483 {
484 }
tty_audit_fork(struct signal_struct * sig)485 static inline void tty_audit_fork(struct signal_struct *sig)
486 {
487 }
tty_audit_push(void)488 static inline int tty_audit_push(void)
489 {
490 	return 0;
491 }
492 #endif
493 
494 /* tty_ioctl.c */
495 int n_tty_ioctl_helper(struct tty_struct *tty, unsigned int cmd,
496 		unsigned long arg);
497 
498 /* vt.c */
499 
500 int vt_ioctl(struct tty_struct *tty, unsigned int cmd, unsigned long arg);
501 
502 long vt_compat_ioctl(struct tty_struct *tty, unsigned int cmd,
503 		unsigned long arg);
504 
505 /* tty_mutex.c */
506 /* functions for preparation of BKL removal */
507 void tty_lock(struct tty_struct *tty);
508 int  tty_lock_interruptible(struct tty_struct *tty);
509 void tty_unlock(struct tty_struct *tty);
510 void tty_lock_slave(struct tty_struct *tty);
511 void tty_unlock_slave(struct tty_struct *tty);
512 void tty_set_lock_subclass(struct tty_struct *tty);
513 
514 #endif
515