| .. | .. |
|---|
| 14 | 14 | #include <uapi/linux/tty.h> |
|---|
| 15 | 15 | #include <linux/rwsem.h> |
|---|
| 16 | 16 | #include <linux/llist.h> |
|---|
| 17 | +#include <linux/android_kabi.h> |
|---|
| 17 | 18 | |
|---|
| 18 | | - |
|---|
| 19 | | -/* |
|---|
| 20 | | - * Lock subclasses for tty locks |
|---|
| 21 | | - * |
|---|
| 22 | | - * TTY_LOCK_NORMAL is for normal ttys and master ptys. |
|---|
| 23 | | - * TTY_LOCK_SLAVE is for slave ptys only. |
|---|
| 24 | | - * |
|---|
| 25 | | - * Lock subclasses are necessary for handling nested locking with pty pairs. |
|---|
| 26 | | - * tty locks which use nested locking: |
|---|
| 27 | | - * |
|---|
| 28 | | - * legacy_mutex - Nested tty locks are necessary for releasing pty pairs. |
|---|
| 29 | | - * The stable lock order is master pty first, then slave pty. |
|---|
| 30 | | - * termios_rwsem - The stable lock order is tty_buffer lock->termios_rwsem. |
|---|
| 31 | | - * Subclassing this lock enables the slave pty to hold its |
|---|
| 32 | | - * termios_rwsem when claiming the master tty_buffer lock. |
|---|
| 33 | | - * tty_buffer lock - slave ptys can claim nested buffer lock when handling |
|---|
| 34 | | - * signal chars. The stable lock order is slave pty, then |
|---|
| 35 | | - * master. |
|---|
| 36 | | - */ |
|---|
| 37 | | - |
|---|
| 38 | | -enum { |
|---|
| 39 | | - TTY_LOCK_NORMAL = 0, |
|---|
| 40 | | - TTY_LOCK_SLAVE, |
|---|
| 41 | | -}; |
|---|
| 42 | 19 | |
|---|
| 43 | 20 | /* |
|---|
| 44 | 21 | * (Note: the *_driver.minor_start values 1, 64, 128, 192 are |
|---|
| .. | .. |
|---|
| 218 | 195 | int (*activate)(struct tty_port *port, struct tty_struct *tty); |
|---|
| 219 | 196 | /* Called on the final put of a port */ |
|---|
| 220 | 197 | void (*destruct)(struct tty_port *port); |
|---|
| 198 | + |
|---|
| 199 | + ANDROID_KABI_RESERVE(1); |
|---|
| 221 | 200 | }; |
|---|
| 222 | 201 | |
|---|
| 223 | 202 | struct tty_port_client_operations { |
|---|
| .. | .. |
|---|
| 252 | 231 | set to size of fifo */ |
|---|
| 253 | 232 | struct kref kref; /* Ref counter */ |
|---|
| 254 | 233 | void *client_data; |
|---|
| 234 | + |
|---|
| 235 | + ANDROID_KABI_RESERVE(1); |
|---|
| 255 | 236 | }; |
|---|
| 256 | 237 | |
|---|
| 257 | 238 | /* tty_port::iflags bits -- use atomic bit ops */ |
|---|
| .. | .. |
|---|
| 303 | 284 | spinlock_t flow_lock; |
|---|
| 304 | 285 | /* Termios values are protected by the termios rwsem */ |
|---|
| 305 | 286 | struct ktermios termios, termios_locked; |
|---|
| 306 | | - struct termiox *termiox; /* May be NULL for unsupported */ |
|---|
| 287 | + |
|---|
| 288 | + /* termiox is estored only for ABI preservation, do not use */ |
|---|
| 289 | + struct termiox *termiox; |
|---|
| 290 | + |
|---|
| 307 | 291 | char name[64]; |
|---|
| 308 | 292 | struct pid *pgrp; /* Protected by ctrl lock */ |
|---|
| 309 | 293 | /* |
|---|
| .. | .. |
|---|
| 342 | 326 | /* If the tty has a pending do_SAK, queue it here - akpm */ |
|---|
| 343 | 327 | struct work_struct SAK_work; |
|---|
| 344 | 328 | struct tty_port *port; |
|---|
| 329 | + |
|---|
| 330 | + ANDROID_KABI_RESERVE(1); |
|---|
| 331 | + ANDROID_KABI_RESERVE(2); |
|---|
| 345 | 332 | } __randomize_layout; |
|---|
| 346 | 333 | |
|---|
| 347 | 334 | /* Each of a tty's open files has private_data pointing to tty_file_private */ |
|---|
| .. | .. |
|---|
| 375 | 362 | #define TTY_LDISC_CHANGING 20 /* Change pending - non-block IO */ |
|---|
| 376 | 363 | #define TTY_LDISC_HALTED 22 /* Line discipline is halted */ |
|---|
| 377 | 364 | |
|---|
| 378 | | -/* Values for tty->flow_change */ |
|---|
| 379 | | -#define TTY_THROTTLE_SAFE 1 |
|---|
| 380 | | -#define TTY_UNTHROTTLE_SAFE 2 |
|---|
| 381 | | - |
|---|
| 382 | | -static inline void __tty_set_flow_change(struct tty_struct *tty, int val) |
|---|
| 383 | | -{ |
|---|
| 384 | | - tty->flow_change = val; |
|---|
| 385 | | -} |
|---|
| 386 | | - |
|---|
| 387 | | -static inline void tty_set_flow_change(struct tty_struct *tty, int val) |
|---|
| 388 | | -{ |
|---|
| 389 | | - tty->flow_change = val; |
|---|
| 390 | | - smp_mb(); |
|---|
| 391 | | -} |
|---|
| 392 | | - |
|---|
| 393 | 365 | static inline bool tty_io_nonblock(struct tty_struct *tty, struct file *file) |
|---|
| 394 | 366 | { |
|---|
| 395 | 367 | return file->f_flags & O_NONBLOCK || |
|---|
| .. | .. |
|---|
| 420 | 392 | extern struct tty_struct *tty_kopen(dev_t device); |
|---|
| 421 | 393 | extern void tty_kclose(struct tty_struct *tty); |
|---|
| 422 | 394 | extern int tty_dev_name_to_number(const char *name, dev_t *number); |
|---|
| 423 | | -extern int tty_ldisc_lock(struct tty_struct *tty, unsigned long timeout); |
|---|
| 424 | | -extern void tty_ldisc_unlock(struct tty_struct *tty); |
|---|
| 425 | 395 | #else |
|---|
| 426 | 396 | static inline void tty_kref_put(struct tty_struct *tty) |
|---|
| 427 | 397 | { } |
|---|
| .. | .. |
|---|
| 474 | 444 | |
|---|
| 475 | 445 | extern const char *tty_driver_name(const struct tty_struct *tty); |
|---|
| 476 | 446 | extern void tty_wait_until_sent(struct tty_struct *tty, long timeout); |
|---|
| 477 | | -extern int __tty_check_change(struct tty_struct *tty, int sig); |
|---|
| 478 | | -extern int tty_check_change(struct tty_struct *tty); |
|---|
| 479 | | -extern void __stop_tty(struct tty_struct *tty); |
|---|
| 480 | 447 | extern void stop_tty(struct tty_struct *tty); |
|---|
| 481 | | -extern void __start_tty(struct tty_struct *tty); |
|---|
| 482 | 448 | extern void start_tty(struct tty_struct *tty); |
|---|
| 483 | 449 | extern int tty_register_driver(struct tty_driver *driver); |
|---|
| 484 | 450 | extern int tty_unregister_driver(struct tty_driver *driver); |
|---|
| .. | .. |
|---|
| 503 | 469 | extern int is_current_pgrp_orphaned(void); |
|---|
| 504 | 470 | extern void tty_hangup(struct tty_struct *tty); |
|---|
| 505 | 471 | extern void tty_vhangup(struct tty_struct *tty); |
|---|
| 506 | | -extern void tty_vhangup_session(struct tty_struct *tty); |
|---|
| 507 | 472 | extern int tty_hung_up_p(struct file *filp); |
|---|
| 508 | 473 | extern void do_SAK(struct tty_struct *tty); |
|---|
| 509 | 474 | extern void __do_SAK(struct tty_struct *tty); |
|---|
| 510 | | -extern void tty_open_proc_set_tty(struct file *filp, struct tty_struct *tty); |
|---|
| 511 | | -extern int tty_signal_session_leader(struct tty_struct *tty, int exit_session); |
|---|
| 512 | | -extern void session_clear_tty(struct pid *session); |
|---|
| 513 | 475 | extern void no_tty(void); |
|---|
| 514 | | -extern void tty_buffer_free_all(struct tty_port *port); |
|---|
| 515 | | -extern void tty_buffer_flush(struct tty_struct *tty, struct tty_ldisc *ld); |
|---|
| 516 | | -extern void tty_buffer_init(struct tty_port *port); |
|---|
| 517 | | -extern void tty_buffer_set_lock_subclass(struct tty_port *port); |
|---|
| 518 | | -extern bool tty_buffer_restart_work(struct tty_port *port); |
|---|
| 519 | | -extern bool tty_buffer_cancel_work(struct tty_port *port); |
|---|
| 520 | | -extern void tty_buffer_flush_work(struct tty_port *port); |
|---|
| 521 | 476 | extern speed_t tty_termios_baud_rate(struct ktermios *termios); |
|---|
| 522 | | -extern speed_t tty_termios_input_baud_rate(struct ktermios *termios); |
|---|
| 523 | 477 | extern void tty_termios_encode_baud_rate(struct ktermios *termios, |
|---|
| 524 | 478 | speed_t ibaud, speed_t obaud); |
|---|
| 525 | 479 | extern void tty_encode_baud_rate(struct tty_struct *tty, |
|---|
| .. | .. |
|---|
| 547 | 501 | extern struct tty_ldisc *tty_ldisc_ref(struct tty_struct *); |
|---|
| 548 | 502 | extern void tty_ldisc_deref(struct tty_ldisc *); |
|---|
| 549 | 503 | extern struct tty_ldisc *tty_ldisc_ref_wait(struct tty_struct *); |
|---|
| 550 | | -extern void tty_ldisc_hangup(struct tty_struct *tty, bool reset); |
|---|
| 551 | | -extern int tty_ldisc_reinit(struct tty_struct *tty, int disc); |
|---|
| 552 | 504 | extern const struct seq_operations tty_ldiscs_seq_ops; |
|---|
| 553 | 505 | |
|---|
| 554 | 506 | extern void tty_wakeup(struct tty_struct *tty); |
|---|
| 555 | 507 | extern void tty_ldisc_flush(struct tty_struct *tty); |
|---|
| 556 | 508 | |
|---|
| 557 | | -extern long tty_ioctl(struct file *file, unsigned int cmd, unsigned long arg); |
|---|
| 558 | 509 | extern int tty_mode_ioctl(struct tty_struct *tty, struct file *file, |
|---|
| 559 | 510 | unsigned int cmd, unsigned long arg); |
|---|
| 560 | | -extern long tty_jobctrl_ioctl(struct tty_struct *tty, struct tty_struct *real_tty, |
|---|
| 561 | | - struct file *file, unsigned int cmd, unsigned long arg); |
|---|
| 562 | 511 | extern int tty_perform_flush(struct tty_struct *tty, unsigned long arg); |
|---|
| 563 | | -extern void tty_default_fops(struct file_operations *fops); |
|---|
| 564 | | -extern struct tty_struct *alloc_tty_struct(struct tty_driver *driver, int idx); |
|---|
| 565 | | -extern int tty_alloc_file(struct file *file); |
|---|
| 566 | | -extern void tty_add_file(struct tty_struct *tty, struct file *file); |
|---|
| 567 | | -extern void tty_free_file(struct file *file); |
|---|
| 568 | 512 | extern struct tty_struct *tty_init_dev(struct tty_driver *driver, int idx); |
|---|
| 569 | 513 | extern void tty_release_struct(struct tty_struct *tty, int idx); |
|---|
| 570 | | -extern int tty_release(struct inode *inode, struct file *filp); |
|---|
| 571 | 514 | extern void tty_init_termios(struct tty_struct *tty); |
|---|
| 572 | 515 | extern void tty_save_termios(struct tty_struct *tty); |
|---|
| 573 | 516 | extern int tty_standard_install(struct tty_driver *driver, |
|---|
| 574 | 517 | struct tty_struct *tty); |
|---|
| 575 | 518 | |
|---|
| 576 | 519 | extern struct mutex tty_mutex; |
|---|
| 577 | | - |
|---|
| 578 | | -#define tty_is_writelocked(tty) (mutex_is_locked(&tty->atomic_write_lock)) |
|---|
| 579 | 520 | |
|---|
| 580 | 521 | extern void tty_port_init(struct tty_port *port); |
|---|
| 581 | 522 | extern void tty_port_link_device(struct tty_port *port, |
|---|
| .. | .. |
|---|
| 714 | 655 | extern int tty_register_ldisc(int disc, struct tty_ldisc_ops *new_ldisc); |
|---|
| 715 | 656 | extern int tty_unregister_ldisc(int disc); |
|---|
| 716 | 657 | extern int tty_set_ldisc(struct tty_struct *tty, int disc); |
|---|
| 717 | | -extern int tty_ldisc_setup(struct tty_struct *tty, struct tty_struct *o_tty); |
|---|
| 718 | | -extern void tty_ldisc_release(struct tty_struct *tty); |
|---|
| 719 | | -extern int __must_check tty_ldisc_init(struct tty_struct *tty); |
|---|
| 720 | | -extern void tty_ldisc_deinit(struct tty_struct *tty); |
|---|
| 721 | 658 | extern int tty_ldisc_receive_buf(struct tty_ldisc *ld, const unsigned char *p, |
|---|
| 722 | 659 | char *f, int count); |
|---|
| 723 | 660 | |
|---|
| .. | .. |
|---|
| 731 | 668 | |
|---|
| 732 | 669 | /* tty_audit.c */ |
|---|
| 733 | 670 | #ifdef CONFIG_AUDIT |
|---|
| 734 | | -extern void tty_audit_add_data(struct tty_struct *tty, const void *data, |
|---|
| 735 | | - size_t size); |
|---|
| 736 | 671 | extern void tty_audit_exit(void); |
|---|
| 737 | 672 | extern void tty_audit_fork(struct signal_struct *sig); |
|---|
| 738 | | -extern void tty_audit_tiocsti(struct tty_struct *tty, char ch); |
|---|
| 739 | 673 | extern int tty_audit_push(void); |
|---|
| 740 | 674 | #else |
|---|
| 741 | | -static inline void tty_audit_add_data(struct tty_struct *tty, const void *data, |
|---|
| 742 | | - size_t size) |
|---|
| 743 | | -{ |
|---|
| 744 | | -} |
|---|
| 745 | | -static inline void tty_audit_tiocsti(struct tty_struct *tty, char ch) |
|---|
| 746 | | -{ |
|---|
| 747 | | -} |
|---|
| 748 | 675 | static inline void tty_audit_exit(void) |
|---|
| 749 | 676 | { |
|---|
| 750 | 677 | } |
|---|
| .. | .. |
|---|
| 759 | 686 | |
|---|
| 760 | 687 | /* tty_ioctl.c */ |
|---|
| 761 | 688 | extern int n_tty_ioctl_helper(struct tty_struct *tty, struct file *file, |
|---|
| 762 | | - unsigned int cmd, unsigned long arg); |
|---|
| 763 | | -extern long n_tty_compat_ioctl_helper(struct tty_struct *tty, struct file *file, |
|---|
| 764 | 689 | unsigned int cmd, unsigned long arg); |
|---|
| 765 | 690 | |
|---|
| 766 | 691 | /* vt.c */ |
|---|
| .. | .. |
|---|
| 787 | 712 | static inline void proc_tty_register_driver(struct tty_driver *d) {} |
|---|
| 788 | 713 | static inline void proc_tty_unregister_driver(struct tty_driver *d) {} |
|---|
| 789 | 714 | #endif |
|---|
| 790 | | - |
|---|
| 791 | | -#define tty_msg(fn, tty, f, ...) \ |
|---|
| 792 | | - fn("%s %s: " f, tty_driver_name(tty), tty_name(tty), ##__VA_ARGS__) |
|---|
| 793 | | - |
|---|
| 794 | | -#define tty_debug(tty, f, ...) tty_msg(pr_debug, tty, f, ##__VA_ARGS__) |
|---|
| 795 | | -#define tty_info(tty, f, ...) tty_msg(pr_info, tty, f, ##__VA_ARGS__) |
|---|
| 796 | | -#define tty_notice(tty, f, ...) tty_msg(pr_notice, tty, f, ##__VA_ARGS__) |
|---|
| 797 | | -#define tty_warn(tty, f, ...) tty_msg(pr_warn, tty, f, ##__VA_ARGS__) |
|---|
| 798 | | -#define tty_err(tty, f, ...) tty_msg(pr_err, tty, f, ##__VA_ARGS__) |
|---|
| 799 | | - |
|---|
| 800 | | -#define tty_info_ratelimited(tty, f, ...) \ |
|---|
| 801 | | - tty_msg(pr_info_ratelimited, tty, f, ##__VA_ARGS__) |
|---|
| 802 | 715 | |
|---|
| 803 | 716 | #endif |
|---|