| .. | .. |
|---|
| 18 | 18 | |
|---|
| 19 | 19 | |
|---|
| 20 | 20 | /* |
|---|
| 21 | | - * Lock subclasses for tty locks |
|---|
| 22 | | - * |
|---|
| 23 | | - * TTY_LOCK_NORMAL is for normal ttys and master ptys. |
|---|
| 24 | | - * TTY_LOCK_SLAVE is for slave ptys only. |
|---|
| 25 | | - * |
|---|
| 26 | | - * Lock subclasses are necessary for handling nested locking with pty pairs. |
|---|
| 27 | | - * tty locks which use nested locking: |
|---|
| 28 | | - * |
|---|
| 29 | | - * legacy_mutex - Nested tty locks are necessary for releasing pty pairs. |
|---|
| 30 | | - * The stable lock order is master pty first, then slave pty. |
|---|
| 31 | | - * termios_rwsem - The stable lock order is tty_buffer lock->termios_rwsem. |
|---|
| 32 | | - * Subclassing this lock enables the slave pty to hold its |
|---|
| 33 | | - * termios_rwsem when claiming the master tty_buffer lock. |
|---|
| 34 | | - * tty_buffer lock - slave ptys can claim nested buffer lock when handling |
|---|
| 35 | | - * signal chars. The stable lock order is slave pty, then |
|---|
| 36 | | - * master. |
|---|
| 37 | | - */ |
|---|
| 38 | | - |
|---|
| 39 | | -enum { |
|---|
| 40 | | - TTY_LOCK_NORMAL = 0, |
|---|
| 41 | | - TTY_LOCK_SLAVE, |
|---|
| 42 | | -}; |
|---|
| 43 | | - |
|---|
| 44 | | -/* |
|---|
| 45 | 21 | * (Note: the *_driver.minor_start values 1, 64, 128, 192 are |
|---|
| 46 | 22 | * hardcoded at present.) |
|---|
| 47 | 23 | */ |
|---|
| .. | .. |
|---|
| 386 | 362 | #define TTY_LDISC_CHANGING 20 /* Change pending - non-block IO */ |
|---|
| 387 | 363 | #define TTY_LDISC_HALTED 22 /* Line discipline is halted */ |
|---|
| 388 | 364 | |
|---|
| 389 | | -/* Values for tty->flow_change */ |
|---|
| 390 | | -#define TTY_THROTTLE_SAFE 1 |
|---|
| 391 | | -#define TTY_UNTHROTTLE_SAFE 2 |
|---|
| 392 | | - |
|---|
| 393 | | -static inline void __tty_set_flow_change(struct tty_struct *tty, int val) |
|---|
| 394 | | -{ |
|---|
| 395 | | - tty->flow_change = val; |
|---|
| 396 | | -} |
|---|
| 397 | | - |
|---|
| 398 | | -static inline void tty_set_flow_change(struct tty_struct *tty, int val) |
|---|
| 399 | | -{ |
|---|
| 400 | | - tty->flow_change = val; |
|---|
| 401 | | - smp_mb(); |
|---|
| 402 | | -} |
|---|
| 403 | | - |
|---|
| 404 | 365 | static inline bool tty_io_nonblock(struct tty_struct *tty, struct file *file) |
|---|
| 405 | 366 | { |
|---|
| 406 | 367 | return file->f_flags & O_NONBLOCK || |
|---|
| .. | .. |
|---|
| 431 | 392 | extern struct tty_struct *tty_kopen(dev_t device); |
|---|
| 432 | 393 | extern void tty_kclose(struct tty_struct *tty); |
|---|
| 433 | 394 | extern int tty_dev_name_to_number(const char *name, dev_t *number); |
|---|
| 434 | | -extern int tty_ldisc_lock(struct tty_struct *tty, unsigned long timeout); |
|---|
| 435 | | -extern void tty_ldisc_unlock(struct tty_struct *tty); |
|---|
| 436 | | -extern ssize_t redirected_tty_write(struct kiocb *, struct iov_iter *); |
|---|
| 437 | 395 | #else |
|---|
| 438 | 396 | static inline void tty_kref_put(struct tty_struct *tty) |
|---|
| 439 | 397 | { } |
|---|
| .. | .. |
|---|
| 486 | 444 | |
|---|
| 487 | 445 | extern const char *tty_driver_name(const struct tty_struct *tty); |
|---|
| 488 | 446 | extern void tty_wait_until_sent(struct tty_struct *tty, long timeout); |
|---|
| 489 | | -extern int __tty_check_change(struct tty_struct *tty, int sig); |
|---|
| 490 | | -extern int tty_check_change(struct tty_struct *tty); |
|---|
| 491 | | -extern void __stop_tty(struct tty_struct *tty); |
|---|
| 492 | 447 | extern void stop_tty(struct tty_struct *tty); |
|---|
| 493 | | -extern void __start_tty(struct tty_struct *tty); |
|---|
| 494 | 448 | extern void start_tty(struct tty_struct *tty); |
|---|
| 495 | 449 | extern int tty_register_driver(struct tty_driver *driver); |
|---|
| 496 | 450 | extern int tty_unregister_driver(struct tty_driver *driver); |
|---|
| .. | .. |
|---|
| 515 | 469 | extern int is_current_pgrp_orphaned(void); |
|---|
| 516 | 470 | extern void tty_hangup(struct tty_struct *tty); |
|---|
| 517 | 471 | extern void tty_vhangup(struct tty_struct *tty); |
|---|
| 518 | | -extern void tty_vhangup_session(struct tty_struct *tty); |
|---|
| 519 | 472 | extern int tty_hung_up_p(struct file *filp); |
|---|
| 520 | 473 | extern void do_SAK(struct tty_struct *tty); |
|---|
| 521 | 474 | extern void __do_SAK(struct tty_struct *tty); |
|---|
| 522 | | -extern void tty_open_proc_set_tty(struct file *filp, struct tty_struct *tty); |
|---|
| 523 | | -extern int tty_signal_session_leader(struct tty_struct *tty, int exit_session); |
|---|
| 524 | | -extern void session_clear_tty(struct pid *session); |
|---|
| 525 | 475 | extern void no_tty(void); |
|---|
| 526 | | -extern void tty_buffer_free_all(struct tty_port *port); |
|---|
| 527 | | -extern void tty_buffer_flush(struct tty_struct *tty, struct tty_ldisc *ld); |
|---|
| 528 | | -extern void tty_buffer_init(struct tty_port *port); |
|---|
| 529 | | -extern void tty_buffer_set_lock_subclass(struct tty_port *port); |
|---|
| 530 | | -extern bool tty_buffer_restart_work(struct tty_port *port); |
|---|
| 531 | | -extern bool tty_buffer_cancel_work(struct tty_port *port); |
|---|
| 532 | | -extern void tty_buffer_flush_work(struct tty_port *port); |
|---|
| 533 | 476 | extern speed_t tty_termios_baud_rate(struct ktermios *termios); |
|---|
| 534 | | -extern speed_t tty_termios_input_baud_rate(struct ktermios *termios); |
|---|
| 535 | 477 | extern void tty_termios_encode_baud_rate(struct ktermios *termios, |
|---|
| 536 | 478 | speed_t ibaud, speed_t obaud); |
|---|
| 537 | 479 | extern void tty_encode_baud_rate(struct tty_struct *tty, |
|---|
| .. | .. |
|---|
| 559 | 501 | extern struct tty_ldisc *tty_ldisc_ref(struct tty_struct *); |
|---|
| 560 | 502 | extern void tty_ldisc_deref(struct tty_ldisc *); |
|---|
| 561 | 503 | extern struct tty_ldisc *tty_ldisc_ref_wait(struct tty_struct *); |
|---|
| 562 | | -extern void tty_ldisc_hangup(struct tty_struct *tty, bool reset); |
|---|
| 563 | | -extern int tty_ldisc_reinit(struct tty_struct *tty, int disc); |
|---|
| 564 | 504 | extern const struct seq_operations tty_ldiscs_seq_ops; |
|---|
| 565 | 505 | |
|---|
| 566 | 506 | extern void tty_wakeup(struct tty_struct *tty); |
|---|
| 567 | 507 | extern void tty_ldisc_flush(struct tty_struct *tty); |
|---|
| 568 | 508 | |
|---|
| 569 | | -extern long tty_ioctl(struct file *file, unsigned int cmd, unsigned long arg); |
|---|
| 570 | 509 | extern int tty_mode_ioctl(struct tty_struct *tty, struct file *file, |
|---|
| 571 | 510 | unsigned int cmd, unsigned long arg); |
|---|
| 572 | | -extern long tty_jobctrl_ioctl(struct tty_struct *tty, struct tty_struct *real_tty, |
|---|
| 573 | | - struct file *file, unsigned int cmd, unsigned long arg); |
|---|
| 574 | 511 | extern int tty_perform_flush(struct tty_struct *tty, unsigned long arg); |
|---|
| 575 | | -extern void tty_default_fops(struct file_operations *fops); |
|---|
| 576 | | -extern struct tty_struct *alloc_tty_struct(struct tty_driver *driver, int idx); |
|---|
| 577 | | -extern int tty_alloc_file(struct file *file); |
|---|
| 578 | | -extern void tty_add_file(struct tty_struct *tty, struct file *file); |
|---|
| 579 | | -extern void tty_free_file(struct file *file); |
|---|
| 580 | 512 | extern struct tty_struct *tty_init_dev(struct tty_driver *driver, int idx); |
|---|
| 581 | 513 | extern void tty_release_struct(struct tty_struct *tty, int idx); |
|---|
| 582 | | -extern int tty_release(struct inode *inode, struct file *filp); |
|---|
| 583 | 514 | extern void tty_init_termios(struct tty_struct *tty); |
|---|
| 584 | 515 | extern void tty_save_termios(struct tty_struct *tty); |
|---|
| 585 | 516 | extern int tty_standard_install(struct tty_driver *driver, |
|---|
| 586 | 517 | struct tty_struct *tty); |
|---|
| 587 | 518 | |
|---|
| 588 | 519 | extern struct mutex tty_mutex; |
|---|
| 589 | | - |
|---|
| 590 | | -#define tty_is_writelocked(tty) (mutex_is_locked(&tty->atomic_write_lock)) |
|---|
| 591 | 520 | |
|---|
| 592 | 521 | extern void tty_port_init(struct tty_port *port); |
|---|
| 593 | 522 | extern void tty_port_link_device(struct tty_port *port, |
|---|
| .. | .. |
|---|
| 726 | 655 | extern int tty_register_ldisc(int disc, struct tty_ldisc_ops *new_ldisc); |
|---|
| 727 | 656 | extern int tty_unregister_ldisc(int disc); |
|---|
| 728 | 657 | extern int tty_set_ldisc(struct tty_struct *tty, int disc); |
|---|
| 729 | | -extern int tty_ldisc_setup(struct tty_struct *tty, struct tty_struct *o_tty); |
|---|
| 730 | | -extern void tty_ldisc_release(struct tty_struct *tty); |
|---|
| 731 | | -extern int __must_check tty_ldisc_init(struct tty_struct *tty); |
|---|
| 732 | | -extern void tty_ldisc_deinit(struct tty_struct *tty); |
|---|
| 733 | 658 | extern int tty_ldisc_receive_buf(struct tty_ldisc *ld, const unsigned char *p, |
|---|
| 734 | 659 | char *f, int count); |
|---|
| 735 | 660 | |
|---|
| .. | .. |
|---|
| 743 | 668 | |
|---|
| 744 | 669 | /* tty_audit.c */ |
|---|
| 745 | 670 | #ifdef CONFIG_AUDIT |
|---|
| 746 | | -extern void tty_audit_add_data(struct tty_struct *tty, const void *data, |
|---|
| 747 | | - size_t size); |
|---|
| 748 | 671 | extern void tty_audit_exit(void); |
|---|
| 749 | 672 | extern void tty_audit_fork(struct signal_struct *sig); |
|---|
| 750 | | -extern void tty_audit_tiocsti(struct tty_struct *tty, char ch); |
|---|
| 751 | 673 | extern int tty_audit_push(void); |
|---|
| 752 | 674 | #else |
|---|
| 753 | | -static inline void tty_audit_add_data(struct tty_struct *tty, const void *data, |
|---|
| 754 | | - size_t size) |
|---|
| 755 | | -{ |
|---|
| 756 | | -} |
|---|
| 757 | | -static inline void tty_audit_tiocsti(struct tty_struct *tty, char ch) |
|---|
| 758 | | -{ |
|---|
| 759 | | -} |
|---|
| 760 | 675 | static inline void tty_audit_exit(void) |
|---|
| 761 | 676 | { |
|---|
| 762 | 677 | } |
|---|
| .. | .. |
|---|
| 797 | 712 | static inline void proc_tty_register_driver(struct tty_driver *d) {} |
|---|
| 798 | 713 | static inline void proc_tty_unregister_driver(struct tty_driver *d) {} |
|---|
| 799 | 714 | #endif |
|---|
| 800 | | - |
|---|
| 801 | | -#define tty_msg(fn, tty, f, ...) \ |
|---|
| 802 | | - fn("%s %s: " f, tty_driver_name(tty), tty_name(tty), ##__VA_ARGS__) |
|---|
| 803 | | - |
|---|
| 804 | | -#define tty_debug(tty, f, ...) tty_msg(pr_debug, tty, f, ##__VA_ARGS__) |
|---|
| 805 | | -#define tty_info(tty, f, ...) tty_msg(pr_info, tty, f, ##__VA_ARGS__) |
|---|
| 806 | | -#define tty_notice(tty, f, ...) tty_msg(pr_notice, tty, f, ##__VA_ARGS__) |
|---|
| 807 | | -#define tty_warn(tty, f, ...) tty_msg(pr_warn, tty, f, ##__VA_ARGS__) |
|---|
| 808 | | -#define tty_err(tty, f, ...) tty_msg(pr_err, tty, f, ##__VA_ARGS__) |
|---|
| 809 | | - |
|---|
| 810 | | -#define tty_info_ratelimited(tty, f, ...) \ |
|---|
| 811 | | - tty_msg(pr_info_ratelimited, tty, f, ##__VA_ARGS__) |
|---|
| 812 | 715 | |
|---|
| 813 | 716 | #endif |
|---|