FreeBSD kernel kern code
|
#include <sys/cdefs.h>
#include "opt_capsicum.h"
#include "opt_printf.h"
#include <sys/param.h>
#include <sys/capsicum.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 <fs/devfs/devfs.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 | TTY_PRBUF_SIZE 256 |
#define | PATCH_FUNC(x) |
#define | TF_ACTIVITY (TF_GONE|TF_OPENED|TF_HOOK|TF_OPENCLOSE) |
Functions | |
__FBSDID ("$FreeBSD$") | |
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, int leaving) |
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 __unused, struct thread *td) |
static int | ttydev_close (struct cdev *dev, int fflag, int devtype __unused, struct thread *td __unused) |
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 __unused) |
static void | tty_kqops_write_detach (struct knote *kn) |
static int | tty_kqops_write_event (struct knote *kn, long hint __unused) |
static int | ttydev_kqfilter (struct cdev *dev, struct knote *kn) |
static int | ttyil_open (struct cdev *dev, int oflags __unused, int devtype __unused, struct thread *td) |
static int | ttyil_close (struct cdev *dev __unused, int flag __unused, int mode __unused, struct thread *td __unused) |
static int | ttyil_rdwr (struct cdev *dev __unused, struct uio *uio __unused, int ioflag __unused) |
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 __unused) |
static void | ttydevsw_defclose (struct tty *tp __unused) |
static void | ttydevsw_defoutwakeup (struct tty *tp __unused) |
static void | ttydevsw_definwakeup (struct tty *tp __unused) |
static int | ttydevsw_defioctl (struct tty *tp __unused, u_long cmd __unused, caddr_t data __unused, struct thread *td __unused) |
static int | ttydevsw_defcioctl (struct tty *tp __unused, int unit __unused, u_long cmd __unused, caddr_t data __unused, struct thread *td __unused) |
static int | ttydevsw_defparam (struct tty *tp __unused, struct termios *t) |
static int | ttydevsw_defmodem (struct tty *tp __unused, int sigon __unused, int sigoff __unused) |
static int | ttydevsw_defmmap (struct tty *tp __unused, vm_ooffset_t offset __unused, vm_paddr_t *paddr __unused, int nprot __unused, vm_memattr_t *memattr __unused) |
static void | ttydevsw_defpktnotify (struct tty *tp __unused, char event __unused) |
static void | ttydevsw_deffree (void *softc __unused) |
static bool | ttydevsw_defbusy (struct tty *tp __unused) |
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 int | tty_drop_ctty (struct tty *tp, struct proc *p) |
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") | |
int | tty_makedevf (struct tty *tp, struct ucred *cred, int flags, 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 __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 | ) |
#define TF_ACTIVITY (TF_GONE|TF_OPENED|TF_HOOK|TF_OPENCLOSE) |
#define TTY_CALLOUT | ( | tp, | |
d | |||
) | (dev2unit(d) & TTYUNIT_CALLOUT) |
#define TTY_PRBUF_SIZE 256 |
#define TTYBUF_MAX 65536 |
#define TTYSUP_CFLAG |
#define TTYSUP_IFLAG |
#define TTYSUP_LFLAG |
#define TTYSUP_OFLAG (OPOST|ONLCR|TAB3|ONOEOT|OCRNL|ONOCR|ONLRET) |
__FBSDID | ( | "$FreeBSD$" | ) |
|
static |
|
static |
Definition at line 1309 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 | |||
) |
struct tty * tty_alloc | ( | struct ttydevsw * | tsw, |
void * | sc | ||
) |
Definition at line 1049 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 1056 of file tty.c.
References busy, cv_init(), free(), knlist_init_mtx(), malloc(), PATCH_FUNC, tty_init_termios(), and TTY_PRBUF_SIZE.
Referenced by tty_alloc().
int tty_checkoutq | ( | struct tty * | tp | ) |
Definition at line 2000 of file tty.c.
Referenced by tty_info(), and vtprintf().
|
static |
Definition at line 1110 of file tty.c.
References cv_destroy(), free(), knlist_destroy(), seldrain(), ttyinq_free(), and ttyoutq_free().
Referenced by tty_rel_free().
|
static |
Definition at line 153 of file tty.c.
References hz, and tty_timedwait().
Referenced by tty_generic_ioctl(), and ttydev_leave().
|
static |
Definition at line 1219 of file tty.c.
References proctree_lock.
Referenced by tty_generic_ioctl().
void tty_flush | ( | struct tty * | tp, |
int | flags | ||
) |
Definition at line 1593 of file tty.c.
References flags, tty_hiwat_in_unblock(), tty_wakeup(), ttyinq_flush(), and ttyoutq_flush().
Referenced by tty_generic_ioctl(), ttydev_close(), ttydisc_close(), ttydisc_modem(), and ttydisc_rint().
|
static |
Definition at line 1627 of file tty.c.
References constty_clear(), constty_set(), data, fgetown(), flags, fsetown(), pgfind(), priv_check(), proctree_lock, tty_drain(), tty_drop_ctty(), 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 2008 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 2028 of file tty.c.
References ttyoutq_write_nofrag().
Referenced by tty_flush(), and ttydisc_read().
|
static |
Definition at line 904 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 1973 of file tty.c.
References data, and tty_generic_ioctl().
Referenced by ptsdev_ioctl(), tty_ioctl_compat(), and ttydev_ioctl().
|
static |
Definition at line 414 of file tty.c.
Referenced by tty_generic_ioctl(), and tty_wait_background().
|
static |
Definition at line 708 of file tty.c.
References knlist_remove().
|
static |
|
static |
Definition at line 732 of file tty.c.
References knlist_remove().
|
static |
int tty_makedevf | ( | struct tty * | tp, |
struct ucred * | cred, | ||
int | flags, | ||
const char * | fmt, | ||
... | |||
) |
Definition at line 1347 of file tty.c.
References clock, destroy_dev(), dev_depends(), flags, make_dev_s(), mode, name, ttydev_cdevsw, ttyil_cdevsw, and vsnrprintf().
|
static |
Definition at line 1141 of file tty.c.
References destroy_dev_sched_cb(), funsetown(), 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 1200 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 1172 of file tty.c.
Referenced by pgdelete().
void tty_rel_sess | ( | struct tty * | tp, |
struct session * | sess | ||
) |
Definition at line 1185 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 1617 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 1506 of file tty.c.
References pgsignal(), and tty_info().
Referenced by killjobc(), ptsdev_ioctl(), tty_set_winsize(), and ttydisc_rint().
void tty_signal_sessleader | ( | struct tty * | tp, |
int | sig | ||
) |
Definition at line 1479 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 1571 of file tty.c.
References hz.
Referenced by tty_drain(), and ttydisc_read_raw_read_timer().
|
static |
Definition at line 1288 of file tty.c.
Referenced by sysctl_kern_ttys().
dev_t tty_udev | ( | struct tty * | tp | ) |
Definition at line 1990 of file tty.c.
Referenced by acct_process(), fill_kinfo_proc_pgrp(), ptsdev_fill_kinfo(), ptsdev_stat(), and sysctl_kern_proc_iterate().
int tty_wait | ( | struct tty * | tp, |
struct cv * | cv | ||
) |
Definition at line 1549 of file tty.c.
Referenced by 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 423 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 1530 of file tty.c.
References flags, 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 2226 of file tty.c.
References make_dev_credf(), and ttyconsdev_cdevsw.
|
static |
Definition at line 2172 of file tty.c.
References ttydev_open().
void ttyconsdev_select | ( | const char * | name | ) |
Definition at line 2236 of file tty.c.
References name.
Referenced by cnadd(), cnremove(), and cnselect().
|
static |
Definition at line 2198 of file tty.c.
References log_console(), and ttydev_write().
|
static |
Definition at line 373 of file tty.c.
References tty_flush(), tty_wakeup(), and ttydev_leave().
|
static |
Definition at line 215 of file tty.c.
Referenced by ttydev_ioctl(), ttydev_kqfilter(), ttydev_mmap(), ttydev_poll(), ttydev_read(), and ttydev_write().
|
static |
Definition at line 563 of file tty.c.
References data, TTY_CALLOUT, tty_ioctl(), tty_wait_background(), and ttydev_enter().
|
static |
Definition at line 768 of file tty.c.
References knlist_add(), tty_kqops_read, tty_kqops_write, and ttydev_enter().
|
static |
Definition at line 230 of file tty.c.
References constty_clear(), tty_drain(), tty_rel_free(), ttydisc_close(), ttyinq_free(), and ttyoutq_free().
Referenced by ttydev_close(), and ttydev_open().
|
static |
Definition at line 686 of file tty.c.
References ttydev_enter().
|
static |
Definition at line 273 of file tty.c.
References priv_check(), TTY_CALLOUT, tty_wait(), ttydev_leave(), and ttydisc_open().
Referenced by ttyconsdev_open().
|
static |
Definition at line 649 of file tty.c.
References selrecord(), and ttydev_enter().
|
static |
Definition at line 503 of file tty.c.
References ttydev_enter(), and ttydisc_read().
|
static |
Definition at line 524 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 |
|
static |
|
static |
|
static |
Definition at line 2055 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 2065 of file tty.c.
References badfileops, dev_relthread(), devvn_refthread(), fd, fget_cap_noref(), ttydev_cdevsw, ttydisc_optimize(), and ttyhook_defrint().
void ttyhook_unregister | ( | struct tty * | tp | ) |
Definition at line 2150 of file tty.c.
References tty_rel_free(), and ttydisc_optimize().
|
static |
Definition at line 849 of file tty.c.
References data, and priv_check().
|
static |
|
static |
|
static |
Definition at line 755 of file tty.c.
Referenced by ttydev_kqfilter().
|
static |
Definition at line 761 of file tty.c.
Referenced by ttydev_kqfilter().
|
static |
Definition at line 2211 of file tty.c.
Referenced by ttyconsdev_init().
|
static |
Definition at line 797 of file tty.c.
Referenced by tty_makedevf(), and ttyhook_register().
|
static |
Definition at line 892 of file tty.c.
Referenced by tty_makedevf().