Linux Kernel
3.7.1
|
#include <linux/types.h>
#include <linux/major.h>
#include <linux/errno.h>
#include <linux/signal.h>
#include <linux/fcntl.h>
#include <linux/sched.h>
#include <linux/interrupt.h>
#include <linux/tty.h>
#include <linux/tty_driver.h>
#include <linux/tty_flip.h>
#include <linux/devpts_fs.h>
#include <linux/file.h>
#include <linux/fdtable.h>
#include <linux/console.h>
#include <linux/timer.h>
#include <linux/ctype.h>
#include <linux/kd.h>
#include <linux/mm.h>
#include <linux/string.h>
#include <linux/slab.h>
#include <linux/poll.h>
#include <linux/proc_fs.h>
#include <linux/init.h>
#include <linux/module.h>
#include <linux/device.h>
#include <linux/wait.h>
#include <linux/bitops.h>
#include <linux/delay.h>
#include <linux/seq_file.h>
#include <linux/serial.h>
#include <linux/ratelimit.h>
#include <linux/uaccess.h>
#include <linux/kbd_kern.h>
#include <linux/vt_kern.h>
#include <linux/selection.h>
#include <linux/kmod.h>
#include <linux/nsproxy.h>
Go to the source code of this file.
Macros | |
#define | TTY_PARANOIA_CHECK 1 |
#define | CHECK_TTY_COUNT 1 |
#define | tty_compat_ioctl NULL |
#define | TTY_NUMBER(tty) ((tty)->index + (tty)->driver->name_base) |
Variables | |
struct ktermios | tty_std_termios |
struct class * | tty_class |
void __do_SAK | ( | struct tty_struct * | tty | ) |
|
read |
__tty_alloc_driver – allocate tty driver : count of lines this driver can handle at most : module which is repsonsible for this driver : some of TTY_DRIVER_* flags, will be set in driver->flags
This should not be called directly, some of the provided macros should be used instead. Use IS_ERR and friends on
void __tty_hangup | ( | struct tty_struct * | tty | ) |
__tty_hangup - actual handler for hangup events : tty device
This can be called by the "eventd" kernel thread. That is process synchronous but doesn't hold any locks, so we need to make sure we have the appropriate locks for what we're doing.
The hangup event clears any pending redirections onto the hung up device. It ensures future writes will error and it does the needed line discipline hangup and signal delivery. The tty object itself remains intact.
Locking: BTM redirect lock for undoing redirection file list lock for manipulating list of ttys tty_ldisc_lock from called functions termios_mutex resetting termios data tasklist_lock to walk task list for hangup event ->siglock to protect ->signal/->sighand
|
read |
DEFINE_MUTEX | ( | tty_mutex | ) |
DEFINE_SPINLOCK | ( | tty_files_lock | ) |
void deinitialize_tty_struct | ( | struct tty_struct * | tty | ) |
disassociate_ctty - disconnect controlling tty : true if exiting so need to "hang up" the session
This function is typically called only by the session leader, when it wants to disassociate itself from its controlling tty.
It performs the following functions: (1) Sends a SIGHUP and SIGCONT to the foreground process group (2) Clears the tty from being controlling the session (3) Clears the controlling tty for all processes in the session group.
The argument on_exit is set to 1 if called when a process is exiting; it is 0 if called by the ioctl TIOCNOTTY.
Locking: BTM is taken for hysterical raisins, and held when called from no_tty(). tty_mutex is taken to protect tty ->siglock is taken to protect ->signal/->sighand tasklist_lock is taken to walk process list for sessions ->siglock is taken to protect ->signal/->sighand
void do_SAK | ( | struct tty_struct * | tty | ) |
EXPORT_SYMBOL | ( | tty_std_termios | ) |
EXPORT_SYMBOL | ( | tty_mutex | ) |
EXPORT_SYMBOL | ( | tty_name | ) |
EXPORT_SYMBOL | ( | tty_check_change | ) |
EXPORT_SYMBOL | ( | tty_hangup | ) |
EXPORT_SYMBOL | ( | tty_vhangup | ) |
EXPORT_SYMBOL | ( | tty_hung_up_p | ) |
EXPORT_SYMBOL | ( | stop_tty | ) |
EXPORT_SYMBOL | ( | start_tty | ) |
EXPORT_SYMBOL | ( | tty_free_termios | ) |
EXPORT_SYMBOL | ( | tty_kref_put | ) |
EXPORT_SYMBOL | ( | tty_pair_get_tty | ) |
EXPORT_SYMBOL | ( | tty_pair_get_pty | ) |
EXPORT_SYMBOL | ( | do_SAK | ) |
EXPORT_SYMBOL | ( | tty_register_device | ) |
EXPORT_SYMBOL | ( | tty_unregister_device | ) |
EXPORT_SYMBOL | ( | __tty_alloc_driver | ) |
EXPORT_SYMBOL | ( | tty_driver_kref_put | ) |
EXPORT_SYMBOL | ( | tty_set_operations | ) |
EXPORT_SYMBOL | ( | put_tty_driver | ) |
EXPORT_SYMBOL | ( | tty_register_driver | ) |
EXPORT_SYMBOL | ( | tty_unregister_driver | ) |
EXPORT_SYMBOL | ( | tty_devnum | ) |
EXPORT_SYMBOL_GPL | ( | tty_wakeup | ) |
EXPORT_SYMBOL_GPL | ( | tty_init_termios | ) |
EXPORT_SYMBOL_GPL | ( | tty_standard_install | ) |
EXPORT_SYMBOL_GPL | ( | tty_get_pgrp | ) |
EXPORT_SYMBOL_GPL | ( | tty_put_char | ) |
EXPORT_SYMBOL_GPL | ( | tty_register_device_attr | ) |
EXPORT_SYMBOL_GPL | ( | get_current_tty | ) |
void free_tty_struct | ( | struct tty_struct * | tty | ) |
|
read |
void initialize_tty_struct | ( | struct tty_struct * | tty, |
struct tty_driver * | driver, | ||
int | idx | ||
) |
LIST_HEAD | ( | tty_drivers | ) |
postcore_initcall | ( | tty_class_init | ) |
void proc_clear_tty | ( | struct task_struct * | p | ) |
void put_tty_driver | ( | struct tty_driver * | d | ) |
void start_tty | ( | struct tty_struct * | tty | ) |
start_tty - propagate flow control : tty to start
Start a tty that has been stopped if at all possible. Perform any necessary wakeups and propagate the TIOCPKT status. If this is the tty was previous stopped and is being started then the driver start method is invoked and the line discipline woken.
Locking: ctrl_lock
void stop_tty | ( | struct tty_struct * | tty | ) |
stop_tty - propagate flow control : tty to stop
Perform flow control to the driver. For PTY/TTY pairs we must also propagate the TIOCKPKT status. May be called on an already stopped device and will not re-call the driver method.
This functionality is used by both the line disciplines for halting incoming flow and by the driver. It may therefore be called from any context, may be under the tty atomic_write_lock but not always.
Locking: Uses the tty control lock internally
void tty_add_file | ( | struct tty_struct * | tty, |
struct file * | file | ||
) |
int tty_check_change | ( | struct tty_struct * | tty | ) |
void tty_default_fops | ( | struct file_operations * | fops | ) |
dev_t tty_devnum | ( | struct tty_struct * | tty | ) |
int tty_do_resize | ( | struct tty_struct * | tty, |
struct winsize * | ws | ||
) |
void tty_driver_kref_put | ( | struct tty_driver * | driver | ) |
void tty_driver_remove_tty | ( | struct tty_driver * | driver, |
struct tty_struct * | tty | ||
) |
void tty_free_termios | ( | struct tty_struct * | tty | ) |
|
read |
void tty_hangup | ( | struct tty_struct * | tty | ) |
|
read |
tty_init_dev - initialise a tty device : tty driver we are opening a device on : device index : returned tty structure
Prepare a tty device. This may not be a "new" clean device but could also be an active device. The pty drivers require special handling because of this.
Locking: The function is called under the tty_mutex, which protects us from the tty struct or driver itself going away.
On exit the tty device has the line discipline attached and a reference count of 1. If a pair was created for pty/tty use and the other was a pty master then it too has a reference count of 1.
WSH 06/09/97: Rewritten to remove races and properly clean up after a failed open. The new code protects the open with a mutex, so it's really quite straightforward. The mutex locking can probably be relaxed for the (most common) case of reopening a tty.
int tty_init_termios | ( | struct tty_struct * | tty | ) |
void tty_kref_put | ( | struct tty_struct * | tty | ) |
char* tty_name | ( | struct tty_struct * | tty, |
char * | buf | ||
) |
|
read |
|
read |
int tty_put_char | ( | struct tty_struct * | tty, |
unsigned char | ch | ||
) |
tty_put_char - write one character to a tty : tty : character
Write one byte to the tty using the provided put_char method if present. Returns the number of characters successfully output.
Note: the specific put_char operation in the driver layer may go away soon. Don't call it directly, use this method
|
read |
tty_register_device - register a tty device : the tty driver that describes the tty device : the index in the tty driver for this tty device : a struct device that is associated with this tty device. This field is optional, if there is no known struct device for this tty device it can be set to NULL safely.
Returns a pointer to the struct device for this tty device (or ERR_PTR(-EFOO) on error).
This call is required to be made to register an individual tty device if the tty driver's flags have the TTY_DRIVER_DYNAMIC_DEV bit set. If that bit is not set, this function should not be called by a tty driver.
Locking: ??
|
read |
tty_register_device_attr - register a tty device : the tty driver that describes the tty device : the index in the tty driver for this tty device : a struct device that is associated with this tty device. This field is optional, if there is no known struct device for this tty device it can be set to NULL safely. : Driver data to be set to device. : Attribute group to be set on device.
Returns a pointer to the struct device for this tty device (or ERR_PTR(-EFOO) on error).
This call is required to be made to register an individual tty device if the tty driver's flags have the TTY_DRIVER_DYNAMIC_DEV bit set. If that bit is not set, this function should not be called by a tty driver.
Locking: ??
int tty_register_driver | ( | struct tty_driver * | driver | ) |
tty_release - vfs callback for close : inode of tty : file pointer for handle to tty
Called the last time each file handle is closed that references this tty. There may however be several such references.
Locking: Takes bkl. See tty_release_dev
Even releasing the tty structures is a tricky business.. We have to be very careful that the structures are all released at the same time, as interrupts might otherwise get the wrong pointers.
WSH 09/09/97: rewritten to avoid some nasty race conditions that could lead to double frees or releasing memory still in use.
void tty_set_operations | ( | struct tty_driver * | driver, |
const struct tty_operations * | op | ||
) |
int tty_standard_install | ( | struct tty_driver * | driver, |
struct tty_struct * | tty | ||
) |
void tty_unregister_device | ( | struct tty_driver * | driver, |
unsigned | index | ||
) |
int tty_unregister_driver | ( | struct tty_driver * | driver | ) |
void tty_vhangup | ( | struct tty_struct * | tty | ) |
void tty_wakeup | ( | struct tty_struct * | tty | ) |
int tty_write_lock | ( | struct tty_struct * | tty, |
int | ndelay | ||
) | -> atomic_write_lock) |
void tty_write_message | ( | struct tty_struct * | tty, |
char * | msg | ||
) |
tty_write_message - write a message to a certain tty, not just the console. : the destination tty_struct : the message to write
This is used for messages that need to be redirected to a specific tty. We don't put it into the syslog queue right now maybe in the future if really needed.
We must still hold the BTM and test the CLOSING flag for the moment.
void tty_write_unlock | ( | struct tty_struct * | tty | ) | -> atomic_write_lock) |