0001
0002
0003
0004
0005
0006 #ifndef _TTY_INTERNAL_H
0007 #define _TTY_INTERNAL_H
0008
0009 #define tty_msg(fn, tty, f, ...) \
0010 fn("%s %s: " f, tty_driver_name(tty), tty_name(tty), ##__VA_ARGS__)
0011
0012 #define tty_debug(tty, f, ...) tty_msg(pr_debug, tty, f, ##__VA_ARGS__)
0013 #define tty_notice(tty, f, ...) tty_msg(pr_notice, tty, f, ##__VA_ARGS__)
0014 #define tty_warn(tty, f, ...) tty_msg(pr_warn, tty, f, ##__VA_ARGS__)
0015 #define tty_err(tty, f, ...) tty_msg(pr_err, tty, f, ##__VA_ARGS__)
0016
0017 #define tty_info_ratelimited(tty, f, ...) \
0018 tty_msg(pr_info_ratelimited, tty, f, ##__VA_ARGS__)
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038 enum {
0039 TTY_LOCK_NORMAL = 0,
0040 TTY_LOCK_SLAVE,
0041 };
0042
0043
0044 #define TTY_THROTTLE_SAFE 1
0045 #define TTY_UNTHROTTLE_SAFE 2
0046
0047 static inline void __tty_set_flow_change(struct tty_struct *tty, int val)
0048 {
0049 tty->flow_change = val;
0050 }
0051
0052 static inline void tty_set_flow_change(struct tty_struct *tty, int val)
0053 {
0054 tty->flow_change = val;
0055 smp_mb();
0056 }
0057
0058 int tty_ldisc_lock(struct tty_struct *tty, unsigned long timeout);
0059 void tty_ldisc_unlock(struct tty_struct *tty);
0060
0061 int __tty_check_change(struct tty_struct *tty, int sig);
0062 int tty_check_change(struct tty_struct *tty);
0063 void __stop_tty(struct tty_struct *tty);
0064 void __start_tty(struct tty_struct *tty);
0065 void tty_vhangup_session(struct tty_struct *tty);
0066 void tty_open_proc_set_tty(struct file *filp, struct tty_struct *tty);
0067 int tty_signal_session_leader(struct tty_struct *tty, int exit_session);
0068 void session_clear_tty(struct pid *session);
0069 void tty_buffer_free_all(struct tty_port *port);
0070 void tty_buffer_flush(struct tty_struct *tty, struct tty_ldisc *ld);
0071 void tty_buffer_init(struct tty_port *port);
0072 void tty_buffer_set_lock_subclass(struct tty_port *port);
0073 bool tty_buffer_restart_work(struct tty_port *port);
0074 bool tty_buffer_cancel_work(struct tty_port *port);
0075 void tty_buffer_flush_work(struct tty_port *port);
0076 speed_t tty_termios_input_baud_rate(struct ktermios *termios);
0077 void tty_ldisc_hangup(struct tty_struct *tty, bool reset);
0078 int tty_ldisc_reinit(struct tty_struct *tty, int disc);
0079 long tty_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
0080 long tty_jobctrl_ioctl(struct tty_struct *tty, struct tty_struct *real_tty,
0081 struct file *file, unsigned int cmd, unsigned long arg);
0082 void tty_default_fops(struct file_operations *fops);
0083 struct tty_struct *alloc_tty_struct(struct tty_driver *driver, int idx);
0084 int tty_alloc_file(struct file *file);
0085 void tty_add_file(struct tty_struct *tty, struct file *file);
0086 void tty_free_file(struct file *file);
0087 int tty_release(struct inode *inode, struct file *filp);
0088
0089 #define tty_is_writelocked(tty) (mutex_is_locked(&tty->atomic_write_lock))
0090
0091 int tty_ldisc_setup(struct tty_struct *tty, struct tty_struct *o_tty);
0092 void tty_ldisc_release(struct tty_struct *tty);
0093 int __must_check tty_ldisc_init(struct tty_struct *tty);
0094 void tty_ldisc_deinit(struct tty_struct *tty);
0095
0096 void tty_sysctl_init(void);
0097
0098
0099 #ifdef CONFIG_AUDIT
0100 void tty_audit_add_data(struct tty_struct *tty, const void *data, size_t size);
0101 void tty_audit_tiocsti(struct tty_struct *tty, char ch);
0102 #else
0103 static inline void tty_audit_add_data(struct tty_struct *tty, const void *data,
0104 size_t size)
0105 {
0106 }
0107 static inline void tty_audit_tiocsti(struct tty_struct *tty, char ch)
0108 {
0109 }
0110 #endif
0111
0112 ssize_t redirected_tty_write(struct kiocb *, struct iov_iter *);
0113
0114 int tty_insert_flip_string_and_push_buffer(struct tty_port *port,
0115 const unsigned char *chars, size_t cnt);
0116
0117 #endif