FreeBSD kernel kern code
|
#include <sys/cdefs.h>
#include "opt_capsicum.h"
#include "opt_compat.h"
#include <sys/param.h>
#include <sys/capability.h>
#include <sys/conf.h>
#include <sys/cons.h>
#include <sys/fcntl.h>
#include <sys/file.h>
#include <sys/filedesc.h>
#include <sys/filio.h>
#include <sys/kernel.h>
#include <sys/limits.h>
#include <sys/malloc.h>
#include <sys/mount.h>
#include <sys/poll.h>
#include <sys/priv.h>
#include <sys/proc.h>
#include <sys/serial.h>
#include <sys/signal.h>
#include <sys/stat.h>
#include <sys/sx.h>
#include <sys/sysctl.h>
#include <sys/systm.h>
#include <sys/tty.h>
#include <sys/ttycom.h>
#include <sys/ttydefaults.h>
#include <sys/ucred.h>
#include <sys/vnode.h>
#include <machine/stdarg.h>
#include "opt_ddb.h"
Go to the source code of this file.
Macros | |
#define | TTYDEFCHARS |
#define | TTYSUP_IFLAG |
#define | TTYSUP_OFLAG (OPOST|ONLCR|TAB3|ONOEOT|OCRNL|ONOCR|ONLRET) |
#define | TTYSUP_LFLAG |
#define | TTYSUP_CFLAG |
#define | TTY_CALLOUT(tp, d) (dev2unit(d) & TTYUNIT_CALLOUT) |
#define | TTYBUF_MAX 65536 |
#define | PATCH_FUNC(x) |
#define | TF_ACTIVITY (TF_GONE|TF_OPENED|TF_HOOK|TF_OPENCLOSE) |
Functions | |
__FBSDID ("$BSDSUniX$") | |
static | MALLOC_DEFINE (M_TTY,"tty","tty device") |
static void | tty_rel_free (struct tty *tp) |
static | TAILQ_HEAD (tty) |
static int | tty_drain (struct tty *tp) |
static __inline int | ttydev_enter (struct tty *tp) |
static void | ttydev_leave (struct tty *tp) |
static int | ttydev_open (struct cdev *dev, int oflags, int devtype, struct thread *td) |
static int | ttydev_close (struct cdev *dev, int fflag, int devtype, struct thread *td) |
static __inline int | tty_is_ctty (struct tty *tp, struct proc *p) |
int | tty_wait_background (struct tty *tp, struct thread *td, int sig) |
static int | ttydev_read (struct cdev *dev, struct uio *uio, int ioflag) |
static int | ttydev_write (struct cdev *dev, struct uio *uio, int ioflag) |
static int | ttydev_ioctl (struct cdev *dev, u_long cmd, caddr_t data, int fflag, struct thread *td) |
static int | ttydev_poll (struct cdev *dev, int events, struct thread *td) |
static int | ttydev_mmap (struct cdev *dev, vm_ooffset_t offset, vm_paddr_t *paddr, int nprot, vm_memattr_t *memattr) |
static void | tty_kqops_read_detach (struct knote *kn) |
static int | tty_kqops_read_event (struct knote *kn, long hint) |
static void | tty_kqops_write_detach (struct knote *kn) |
static int | tty_kqops_write_event (struct knote *kn, long hint) |
static int | ttydev_kqfilter (struct cdev *dev, struct knote *kn) |
static int | ttyil_open (struct cdev *dev, int oflags, int devtype, struct thread *td) |
static int | ttyil_close (struct cdev *dev, int flag, int mode, struct thread *td) |
static int | ttyil_rdwr (struct cdev *dev, struct uio *uio, int ioflag) |
static int | ttyil_ioctl (struct cdev *dev, u_long cmd, caddr_t data, int fflag, struct thread *td) |
static void | tty_init_termios (struct tty *tp) |
void | tty_init_console (struct tty *tp, speed_t s) |
static int | ttydevsw_defopen (struct tty *tp) |
static void | ttydevsw_defclose (struct tty *tp) |
static void | ttydevsw_defoutwakeup (struct tty *tp) |
static void | ttydevsw_definwakeup (struct tty *tp) |
static int | ttydevsw_defioctl (struct tty *tp, u_long cmd, caddr_t data, struct thread *td) |
static int | ttydevsw_defcioctl (struct tty *tp, int unit, u_long cmd, caddr_t data, struct thread *td) |
static int | ttydevsw_defparam (struct tty *tp, struct termios *t) |
static int | ttydevsw_defmodem (struct tty *tp, int sigon, int sigoff) |
static int | ttydevsw_defmmap (struct tty *tp, vm_ooffset_t offset, vm_paddr_t *paddr, int nprot, vm_memattr_t *memattr) |
static void | ttydevsw_defpktnotify (struct tty *tp, char event) |
static void | ttydevsw_deffree (void *softc) |
struct tty * | tty_alloc (struct ttydevsw *tsw, void *sc) |
struct tty * | tty_alloc_mutex (struct ttydevsw *tsw, void *sc, struct mtx *mutex) |
static void | tty_dealloc (void *arg) |
void | tty_rel_pgrp (struct tty *tp, struct pgrp *pg) |
void | tty_rel_sess (struct tty *tp, struct session *sess) |
void | tty_rel_gone (struct tty *tp) |
static void | tty_to_xtty (struct tty *tp, struct xtty *xt) |
static int | sysctl_kern_ttys (SYSCTL_HANDLER_ARGS) |
SYSCTL_PROC (_kern, OID_AUTO, ttys, CTLTYPE_OPAQUE|CTLFLAG_RD|CTLFLAG_MPSAFE, 0, 0, sysctl_kern_ttys,"S,xtty","List of TTYs") | |
void | tty_makedev (struct tty *tp, struct ucred *cred, const char *fmt,...) |
void | tty_signal_sessleader (struct tty *tp, int sig) |
void | tty_signal_pgrp (struct tty *tp, int sig) |
void | tty_wakeup (struct tty *tp, int flags) |
int | tty_wait (struct tty *tp, struct cv *cv) |
int | tty_timedwait (struct tty *tp, struct cv *cv, int hz) |
void | tty_flush (struct tty *tp, int flags) |
void | tty_set_winsize (struct tty *tp, const struct winsize *wsz) |
static int | tty_generic_ioctl (struct tty *tp, u_long cmd, void *data, int fflag, struct thread *td) |
int | tty_ioctl (struct tty *tp, u_long cmd, void *data, int fflag, struct thread *td) |
dev_t | tty_udev (struct tty *tp) |
int | tty_checkoutq (struct tty *tp) |
void | tty_hiwat_in_block (struct tty *tp) |
void | tty_hiwat_in_unblock (struct tty *tp) |
static int | ttyhook_defrint (struct tty *tp, char c, int flags) |
int | ttyhook_register (struct tty **rtp, struct proc *p, int fd, struct ttyhook *th, void *softc) |
void | ttyhook_unregister (struct tty *tp) |
static int | ttyconsdev_open (struct cdev *dev, int oflags, int devtype, struct thread *td) |
static int | ttyconsdev_write (struct cdev *dev, struct uio *uio, int ioflag) |
static void | ttyconsdev_init (void *unused) |
SYSINIT (tty, SI_SUB_DRIVERS, SI_ORDER_FIRST, ttyconsdev_init, NULL) | |
void | ttyconsdev_select (const char *name) |
Variables | |
static struct filterops | tty_kqops_read |
static struct filterops | tty_kqops_write |
static struct cdevsw | ttydev_cdevsw |
static struct cdevsw | ttyil_cdevsw |
static struct cdevsw | ttyconsdev_cdevsw |
#define PATCH_FUNC | ( | x | ) |
Referenced by tty_alloc_mutex().
#define TF_ACTIVITY (TF_GONE|TF_OPENED|TF_HOOK|TF_OPENCLOSE) |
Referenced by tty_rel_free().
#define TTY_CALLOUT | ( | tp, | |
d | |||
) | (dev2unit(d) & TTYUNIT_CALLOUT) |
Referenced by ttydev_ioctl(), and ttydev_open().
#define TTYBUF_MAX 65536 |
Referenced by TAILQ_HEAD().
#define TTYSUP_CFLAG |
Referenced by tty_generic_ioctl().
#define TTYSUP_IFLAG |
Referenced by tty_generic_ioctl().
#define TTYSUP_LFLAG |
Referenced by tty_generic_ioctl().
#define TTYSUP_OFLAG (OPOST|ONLCR|TAB3|ONOEOT|OCRNL|ONOCR|ONLRET) |
Referenced by tty_generic_ioctl().
__FBSDID | ( | "$BSDSUniX$" | ) |
|
static |
|
static |
Definition at line 1138 of file tty.c.
References free(), malloc(), and tty_to_xtty().
SYSCTL_PROC | ( | _kern | , |
OID_AUTO | , | ||
ttys | , | ||
CTLTYPE_OPAQUE|CTLFLAG_RD| | CTLFLAG_MPSAFE, | ||
0 | , | ||
0 | , | ||
sysctl_kern_ttys | , | ||
" | S, | ||
xtty" | , | ||
"List of TTYs" | |||
) |
SYSINIT | ( | tty | , |
SI_SUB_DRIVERS | , | ||
SI_ORDER_FIRST | , | ||
ttyconsdev_init | , | ||
NULL | |||
) |
|
static |
Definition at line 74 of file tty.c.
References TTYBUF_MAX, ttyinq_setsize(), and ttyoutq_setsize().
struct tty* tty_alloc | ( | struct ttydevsw * | tsw, |
void * | sc | ||
) |
Definition at line 955 of file tty.c.
References tty_alloc_mutex().
Referenced by pts_alloc(), pts_alloc_external(), and terminal_maketty().
struct tty* tty_alloc_mutex | ( | struct ttydevsw * | tsw, |
void * | sc, | ||
struct mtx * | mutex | ||
) |
Definition at line 962 of file tty.c.
References cv_init(), free(), knlist_init_mtx(), malloc(), mtx_init(), PATCH_FUNC, and tty_init_termios().
Referenced by tty_alloc().
int tty_checkoutq | ( | struct tty * | tp | ) |
Definition at line 1767 of file tty.c.
Referenced by tprintf(), and tty_info().
|
static |
Definition at line 1017 of file tty.c.
References cv_destroy(), free(), knlist_destroy(), mtx_destroy(), and seldrain().
Referenced by tty_rel_free().
|
static |
Definition at line 126 of file tty.c.
References tty_wait().
Referenced by tty_generic_ioctl(), and ttydev_leave().
void tty_flush | ( | struct tty * | tp, |
int | flags | ||
) |
Definition at line 1368 of file tty.c.
References tty_hiwat_in_unblock(), tty_wakeup(), ttyinq_flush(), and ttyoutq_flush().
Referenced by tty_generic_ioctl(), ttydisc_modem(), and ttydisc_rint().
|
static |
Definition at line 1395 of file tty.c.
References constty_clear(), constty_set(), fgetown(), fsetown(), pgfind(), priv_check(), proctree_lock, tty_drain(), tty_flush(), tty_info(), tty_ioctl_compat(), tty_is_ctty(), tty_set_winsize(), tty_wakeup(), ttydisc_optimize(), ttydisc_rint(), ttydisc_rint_done(), ttyinq_canonicalize(), TTYSUP_CFLAG, TTYSUP_IFLAG, TTYSUP_LFLAG, and TTYSUP_OFLAG.
Referenced by tty_ioctl().
void tty_hiwat_in_block | ( | struct tty * | tp | ) |
Definition at line 1775 of file tty.c.
References ttyoutq_write_nofrag().
Referenced by ttydisc_rint(), and ttydisc_rint_bypass().
void tty_hiwat_in_unblock | ( | struct tty * | tp | ) |
Definition at line 1795 of file tty.c.
References ttyoutq_write_nofrag().
Referenced by tty_flush(), and ttydisc_read().
|
static |
Definition at line 824 of file tty.c.
Referenced by tty_alloc_mutex().
int tty_ioctl | ( | struct tty * | tp, |
u_long | cmd, | ||
void * | data, | ||
int | fflag, | ||
struct thread * | td | ||
) |
Definition at line 1741 of file tty.c.
References tty_generic_ioctl().
Referenced by ptsdev_ioctl(), tty_ioctl_compat(), and ttydev_ioctl().
|
static |
Definition at line 357 of file tty.c.
Referenced by tty_generic_ioctl(), and tty_wait_background().
|
static |
Definition at line 631 of file tty.c.
References knlist_remove().
|
static |
|
static |
Definition at line 655 of file tty.c.
References knlist_remove().
|
static |
void tty_makedev | ( | struct tty * | tp, |
struct ucred * | cred, | ||
const char * | fmt, | ||
... | |||
) |
Definition at line 1176 of file tty.c.
References dev_depends(), make_dev_cred(), mode, name, vsnrprintf(), and wakeup().
Referenced by pts_alloc(), pts_alloc_external(), and terminal_maketty().
|
static |
Definition at line 1048 of file tty.c.
References destroy_dev_sched_cb(), TF_ACTIVITY, and tty_dealloc().
Referenced by tty_rel_gone(), tty_rel_sess(), ttydev_leave(), and ttyhook_unregister().
void tty_rel_gone | ( | struct tty * | tp | ) |
Definition at line 1097 of file tty.c.
References tty_rel_free(), tty_wakeup(), and ttydisc_modem().
Referenced by ptsdev_close().
void tty_rel_pgrp | ( | struct tty * | tp, |
struct pgrp * | pg | ||
) |
Definition at line 1071 of file tty.c.
Referenced by pgdelete().
void tty_rel_sess | ( | struct tty * | tp, |
struct session * | sess | ||
) |
Definition at line 1083 of file tty.c.
References tty_rel_free().
Referenced by sess_release().
void tty_set_winsize | ( | struct tty * | tp, |
const struct winsize * | wsz | ||
) |
Definition at line 1385 of file tty.c.
References tty_signal_pgrp().
Referenced by terminal_sync_ttysize(), and tty_generic_ioctl().
void tty_signal_pgrp | ( | struct tty * | tp, |
int | sig | ||
) |
Definition at line 1283 of file tty.c.
References pgsignal(), and tty_info().
Referenced by exit1(), ptsdev_ioctl(), tty_set_winsize(), and ttydisc_rint().
void tty_signal_sessleader | ( | struct tty * | tp, |
int | sig | ||
) |
Definition at line 1264 of file tty.c.
References kern_psignal().
Referenced by ttydisc_modem().
int tty_timedwait | ( | struct tty * | tp, |
struct cv * | cv, | ||
int | hz | ||
) |
Definition at line 1346 of file tty.c.
Referenced by ttydisc_read_raw_read_timer().
|
static |
Definition at line 1118 of file tty.c.
Referenced by sysctl_kern_ttys().
dev_t tty_udev | ( | struct tty * | tp | ) |
Definition at line 1758 of file tty.c.
Referenced by acct_process(), fill_kinfo_proc_only(), fill_pts_info(), ptsdev_stat(), and sysctl_kern_proc().
int tty_wait | ( | struct tty * | tp, |
struct cv * | cv | ||
) |
Definition at line 1324 of file tty.c.
Referenced by tty_drain(), tty_wait_background(), ttydev_open(), ttydev_write(), ttydisc_read_canonical(), ttydisc_read_raw_interbyte_timer(), ttydisc_read_raw_no_timer(), and ttydisc_write().
int tty_wait_background | ( | struct tty * | tp, |
struct thread * | td, | ||
int | sig | ||
) |
Definition at line 365 of file tty.c.
References pgsignal(), tty_is_ctty(), and tty_wait().
Referenced by ttydev_ioctl(), ttydev_write(), ttydisc_read_canonical(), ttydisc_read_raw_interbyte_timer(), ttydisc_read_raw_no_timer(), and ttydisc_read_raw_read_timer().
void tty_wakeup | ( | struct tty * | tp, |
int | flags | ||
) |
Definition at line 1306 of file tty.c.
References pgsigio(), and selwakeup().
Referenced by tty_flush(), tty_generic_ioctl(), tty_rel_gone(), ttydev_close(), ttydisc_rint_done(), and ttydisc_wakeup_watermark().
|
static |
Definition at line 1994 of file tty.c.
References make_dev_credf().
|
static |
Definition at line 1940 of file tty.c.
References ttydev_open().
void ttyconsdev_select | ( | const char * | name | ) |
Definition at line 2004 of file tty.c.
References name.
Referenced by cnadd(), cnremove(), and cnselect().
|
static |
Definition at line 1966 of file tty.c.
References log_console(), and ttydev_write().
|
static |
Definition at line 318 of file tty.c.
References tty_wakeup(), and ttydev_leave().
|
static |
Definition at line 159 of file tty.c.
Referenced by ttydev_ioctl(), ttydev_kqfilter(), ttydev_mmap(), ttydev_poll(), ttydev_read(), and ttydev_write().
|
static |
Definition at line 486 of file tty.c.
References TTY_CALLOUT, tty_ioctl(), tty_wait_background(), and ttydev_enter().
|
static |
Definition at line 690 of file tty.c.
References knlist_add(), tty_kqops_read, tty_kqops_write, and ttydev_enter().
|
static |
Definition at line 173 of file tty.c.
References constty_clear(), funsetown(), tty_drain(), tty_rel_free(), ttydisc_close(), ttyinq_free(), and ttyoutq_free().
Referenced by ttydev_close(), and ttydev_open().
|
static |
Definition at line 609 of file tty.c.
References ttydev_enter().
|
static |
Definition at line 220 of file tty.c.
References priv_check(), TTY_CALLOUT, tty_wait(), ttydev_leave(), and ttydisc_open().
Referenced by ttyconsdev_open().
|
static |
Definition at line 572 of file tty.c.
References selrecord(), and ttydev_enter().
|
static |
Definition at line 428 of file tty.c.
References ttydev_enter(), and ttydisc_read().
|
static |
Definition at line 449 of file tty.c.
References cv_signal(), tty_wait(), tty_wait_background(), ttydev_enter(), and ttydisc_write().
Referenced by ttyconsdev_write().
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
Definition at line 1822 of file tty.c.
Referenced by ttyhook_register().
int ttyhook_register | ( | struct tty ** | rtp, |
struct proc * | p, | ||
int | fd, | ||
struct ttyhook * | th, | ||
void * | softc | ||
) |
Definition at line 1832 of file tty.c.
References badfileops, cap_funwrap(), dev_relthread(), devvn_refthread(), fget_unlocked(), ttydisc_optimize(), and ttyhook_defrint().
void ttyhook_unregister | ( | struct tty * | tp | ) |
Definition at line 1918 of file tty.c.
References tty_rel_free(), and ttydisc_optimize().
|
static |
|
static |
Definition at line 769 of file tty.c.
References priv_check().
|
static |
|
static |
|
static |
Definition at line 678 of file tty.c.
Referenced by ttydev_kqfilter().
|
static |
Definition at line 683 of file tty.c.
Referenced by ttydev_kqfilter().
|
static |
|
static |
|
static |