FreeBSD kernel kern code
tty_pts.c File Reference
#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/lock.h>
#include <sys/condvar.h>
#include <sys/conf.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/poll.h>
#include <sys/proc.h>
#include <sys/racct.h>
#include <sys/resourcevar.h>
#include <sys/serial.h>
#include <sys/stat.h>
#include <sys/syscall.h>
#include <sys/syscallsubr.h>
#include <sys/sysctl.h>
#include <sys/sysent.h>
#include <sys/sysproto.h>
#include <sys/systm.h>
#include <sys/tty.h>
#include <sys/ttycom.h>
#include <machine/stdarg.h>
Include dependency graph for tty_pts.c:

Go to the source code of this file.

Data Structures

struct  pts_softc
 

Macros

#define PTS_COMPAT
 
#define PTS_EXTERNAL
 
#define PTS_LINUX
 
#define PTS_PKT   0x1 /* Packet mode. */
 
#define PTS_FINISHED   0x2 /* Return errors on read()/write(). */
 

Functions

 __FBSDID ("$BSDSUniX$")
 
static MALLOC_DEFINE (M_PTS,"pts","pseudo tty device")
 
static int ptsdev_read (struct file *fp, struct uio *uio, struct ucred *active_cred, int flags, struct thread *td)
 
static int ptsdev_write (struct file *fp, struct uio *uio, struct ucred *active_cred, int flags, struct thread *td)
 
static int ptsdev_truncate (struct file *fp, off_t length, struct ucred *active_cred, struct thread *td)
 
static int ptsdev_ioctl (struct file *fp, u_long cmd, void *data, struct ucred *active_cred, struct thread *td)
 
static int ptsdev_poll (struct file *fp, int events, struct ucred *active_cred, struct thread *td)
 
static void pts_kqops_read_detach (struct knote *kn)
 
static int pts_kqops_read_event (struct knote *kn, long hint)
 
static void pts_kqops_write_detach (struct knote *kn)
 
static int pts_kqops_write_event (struct knote *kn, long hint)
 
static int ptsdev_kqfilter (struct file *fp, struct knote *kn)
 
static int ptsdev_stat (struct file *fp, struct stat *sb, struct ucred *active_cred, struct thread *td)
 
static int ptsdev_close (struct file *fp, struct thread *td)
 
static void ptsdrv_outwakeup (struct tty *tp)
 
static void ptsdrv_inwakeup (struct tty *tp)
 
static int ptsdrv_open (struct tty *tp)
 
static void ptsdrv_close (struct tty *tp)
 
static void ptsdrv_pktnotify (struct tty *tp, char event)
 
static void ptsdrv_free (void *softc)
 
int pts_alloc (int fflags, struct thread *td, struct file *fp)
 
int pts_alloc_external (int fflags, struct thread *td, struct file *fp, struct cdev *dev, const char *name)
 
int sys_posix_openpt (struct thread *td, struct posix_openpt_args *uap)
 
static void pts_init (void *unused)
 
 SYSINIT (pts, SI_SUB_DRIVERS, SI_ORDER_MIDDLE, pts_init, NULL)
 

Variables

static struct unrhdrpts_pool
 
static struct filterops pts_kqops_read
 
static struct filterops pts_kqops_write
 
static struct fileops ptsdev_ops
 
static struct ttydevsw pts_class
 

Macro Definition Documentation

#define PTS_COMPAT

Definition at line 34 of file tty_pts.c.

#define PTS_EXTERNAL

Definition at line 36 of file tty_pts.c.

#define PTS_FINISHED   0x2 /* Return errors on read()/write(). */
#define PTS_LINUX

Definition at line 38 of file tty_pts.c.

#define PTS_PKT   0x1 /* Packet mode. */

Definition at line 88 of file tty_pts.c.

Referenced by ptsdev_ioctl(), ptsdev_poll(), and ptsdev_read().

Function Documentation

__FBSDID ( "$BSDSUniX$"  )
static MALLOC_DEFINE ( M_PTS  ,
"pts"  ,
"pseudo tty device  
)
static
int pts_alloc ( int  fflags,
struct thread *  td,
struct file *  fp 
)
int pts_alloc_external ( int  fflags,
struct thread *  td,
struct file *  fp,
struct cdev *  dev,
const char *  name 
)
static void pts_init ( void *  unused)
static

Definition at line 851 of file tty_pts.c.

References new_unrhdr().

Here is the call graph for this function:

static void pts_kqops_read_detach ( struct knote kn)
static

Definition at line 444 of file tty_pts.c.

References knlist_remove(), and pts_softc::pts_outpoll.

Here is the call graph for this function:

static int pts_kqops_read_event ( struct knote kn,
long  hint 
)
static

Definition at line 454 of file tty_pts.c.

References PTS_FINISHED, pts_softc::pts_flags, and ttydisc_getc_poll().

Here is the call graph for this function:

static void pts_kqops_write_detach ( struct knote kn)
static

Definition at line 470 of file tty_pts.c.

References knlist_remove(), and pts_softc::pts_inpoll.

Here is the call graph for this function:

static int pts_kqops_write_event ( struct knote kn,
long  hint 
)
static

Definition at line 480 of file tty_pts.c.

References PTS_FINISHED, pts_softc::pts_flags, and ttydisc_rint_poll().

Here is the call graph for this function:

static int ptsdev_close ( struct file *  fp,
struct thread *  td 
)
static

Definition at line 571 of file tty_pts.c.

References tty_rel_gone(), and vnops.

Here is the call graph for this function:

static int ptsdev_ioctl ( struct file *  fp,
u_long  cmd,
void *  data,
struct ucred *  active_cred,
struct thread *  td 
)
static

Definition at line 264 of file tty_pts.c.

References PTS_FINISHED, pts_softc::pts_flags, PTS_PKT, pts_softc::pts_unit, tty_ioctl(), tty_signal_pgrp(), and ttydisc_getc_poll().

Here is the call graph for this function:

static int ptsdev_kqfilter ( struct file *  fp,
struct knote kn 
)
static

Definition at line 507 of file tty_pts.c.

References knlist_add(), pts_softc::pts_inpoll, pts_kqops_read, pts_kqops_write, and pts_softc::pts_outpoll.

Here is the call graph for this function:

static int ptsdev_poll ( struct file *  fp,
int  events,
struct ucred *  active_cred,
struct thread *  td 
)
static
static int ptsdev_read ( struct file *  fp,
struct uio *  uio,
struct ucred *  active_cred,
int  flags,
struct thread *  td 
)
static

Definition at line 109 of file tty_pts.c.

References PTS_FINISHED, pts_softc::pts_flags, pts_softc::pts_outwait, PTS_PKT, pts_softc::pts_pkt, ttydisc_getc_poll(), ttydisc_getc_uio(), and ureadc().

Here is the call graph for this function:

static int ptsdev_stat ( struct file *  fp,
struct stat *  sb,
struct ucred *  active_cred,
struct thread *  td 
)
static

Definition at line 534 of file tty_pts.c.

References pts_softc::pts_cdev, and tty_udev().

Here is the call graph for this function:

static int ptsdev_truncate ( struct file *  fp,
off_t  length,
struct ucred *  active_cred,
struct thread *  td 
)
static

Definition at line 256 of file tty_pts.c.

static int ptsdev_write ( struct file *  fp,
struct uio *  uio,
struct ucred *  active_cred,
int  flags,
struct thread *  td 
)
static

Definition at line 183 of file tty_pts.c.

References PTS_FINISHED, pts_softc::pts_flags, pts_softc::pts_inwait, ttydisc_rint_done(), ttydisc_rint_simple(), and uiomove().

Here is the call graph for this function:

static void ptsdrv_close ( struct tty *  tp)
static

Definition at line 640 of file tty_pts.c.

References PTS_FINISHED, pts_softc::pts_flags, ptsdrv_inwakeup(), and ptsdrv_outwakeup().

Here is the call graph for this function:

static void ptsdrv_free ( void *  softc)
static
static void ptsdrv_inwakeup ( struct tty *  tp)
static

Definition at line 620 of file tty_pts.c.

References pts_softc::pts_inpoll, pts_softc::pts_inwait, and selwakeup().

Referenced by ptsdrv_close().

Here is the call graph for this function:

Here is the caller graph for this function:

static int ptsdrv_open ( struct tty *  tp)
static

Definition at line 630 of file tty_pts.c.

References PTS_FINISHED, and pts_softc::pts_flags.

static void ptsdrv_outwakeup ( struct tty *  tp)
static

Definition at line 610 of file tty_pts.c.

References pts_softc::pts_outpoll, pts_softc::pts_outwait, and selwakeup().

Referenced by ptsdrv_close(), and ptsdrv_pktnotify().

Here is the call graph for this function:

Here is the caller graph for this function:

static void ptsdrv_pktnotify ( struct tty *  tp,
char  event 
)
static

Definition at line 651 of file tty_pts.c.

References pts_softc::pts_pkt, and ptsdrv_outwakeup().

Here is the call graph for this function:

int sys_posix_openpt ( struct thread *  td,
struct posix_openpt_args *  uap 
)

Definition at line 819 of file tty_pts.c.

References falloc(), fd, fdclose(), and pts_alloc().

Here is the call graph for this function:

SYSINIT ( pts  ,
SI_SUB_DRIVERS  ,
SI_ORDER_MIDDLE  ,
pts_init  ,
NULL   
)

Variable Documentation

struct ttydevsw pts_class
static
Initial value:
= {
.tsw_flags = TF_NOPREFIX,
.tsw_outwakeup = ptsdrv_outwakeup,
.tsw_inwakeup = ptsdrv_inwakeup,
.tsw_open = ptsdrv_open,
.tsw_close = ptsdrv_close,
.tsw_pktnotify = ptsdrv_pktnotify,
.tsw_free = ptsdrv_free,
}
static void ptsdrv_outwakeup(struct tty *tp)
Definition: tty_pts.c:610
static int ptsdrv_open(struct tty *tp)
Definition: tty_pts.c:630
static void ptsdrv_pktnotify(struct tty *tp, char event)
Definition: tty_pts.c:651
static void ptsdrv_close(struct tty *tp)
Definition: tty_pts.c:640
static void ptsdrv_free(void *softc)
Definition: tty_pts.c:679
static void ptsdrv_inwakeup(struct tty *tp)
Definition: tty_pts.c:620

Definition at line 705 of file tty_pts.c.

Referenced by pts_alloc(), and pts_alloc_external().

struct filterops pts_kqops_read
static
Initial value:
= {
.f_isfd = 1,
.f_detach = pts_kqops_read_detach,
}
static int pts_kqops_read_event(struct knote *kn, long hint)
Definition: tty_pts.c:454
static void pts_kqops_read_detach(struct knote *kn)
Definition: tty_pts.c:444

Definition at line 495 of file tty_pts.c.

Referenced by ptsdev_kqfilter().

struct filterops pts_kqops_write
static
Initial value:
= {
.f_isfd = 1,
}
static int pts_kqops_write_event(struct knote *kn, long hint)
Definition: tty_pts.c:480
static void pts_kqops_write_detach(struct knote *kn)
Definition: tty_pts.c:470

Definition at line 500 of file tty_pts.c.

Referenced by ptsdev_kqfilter().

struct unrhdr* pts_pool
static

Definition at line 74 of file tty_pts.c.

struct fileops ptsdev_ops
static
Initial value:
= {
.fo_read = ptsdev_read,
.fo_write = ptsdev_write,
.fo_truncate = ptsdev_truncate,
.fo_ioctl = ptsdev_ioctl,
.fo_poll = ptsdev_poll,
.fo_kqfilter = ptsdev_kqfilter,
.fo_stat = ptsdev_stat,
.fo_close = ptsdev_close,
.fo_chmod = invfo_chmod,
.fo_chown = invfo_chown,
.fo_flags = DFLAG_PASSABLE,
}
int invfo_chmod(struct file *fp, mode_t mode, struct ucred *active_cred, struct thread *td)
int invfo_chown(struct file *fp, uid_t uid, gid_t gid, struct ucred *active_cred, struct thread *td)
static int ptsdev_truncate(struct file *fp, off_t length, struct ucred *active_cred, struct thread *td)
Definition: tty_pts.c:256
static int ptsdev_ioctl(struct file *fp, u_long cmd, void *data, struct ucred *active_cred, struct thread *td)
Definition: tty_pts.c:264
static int ptsdev_read(struct file *fp, struct uio *uio, struct ucred *active_cred, int flags, struct thread *td)
Definition: tty_pts.c:109
static int ptsdev_poll(struct file *fp, int events, struct ucred *active_cred, struct thread *td)
Definition: tty_pts.c:389
static int ptsdev_stat(struct file *fp, struct stat *sb, struct ucred *active_cred, struct thread *td)
Definition: tty_pts.c:534
static int ptsdev_kqfilter(struct file *fp, struct knote *kn)
Definition: tty_pts.c:507
static int ptsdev_close(struct file *fp, struct thread *td)
Definition: tty_pts.c:571
static int ptsdev_write(struct file *fp, struct uio *uio, struct ucred *active_cred, int flags, struct thread *td)
Definition: tty_pts.c:183

Definition at line 591 of file tty_pts.c.

Referenced by pts_alloc(), and pts_alloc_external().