Print this page
14249 pseudo-terminal nomenclature should reflect POSIX
Change-Id: Ib4a3cef899ff4c71b09cb0dc6878863c5e8357bc
*** 10,20 ****
* specifies the terms and conditions for redistribution.
*/
/*
* PTY - Stream "pseudo-tty" device.
! * This is the "slave" side.
*/
#include <sys/param.h>
#include <sys/systm.h>
--- 10,20 ----
* specifies the terms and conditions for redistribution.
*/
/*
* PTY - Stream "pseudo-tty" device.
! * This is the "subsidiary" side.
*/
#include <sys/param.h>
#include <sys/systm.h>
*** 28,38 ****
#include <sys/strsun.h>
#include <sys/tty.h>
#include <sys/user.h>
#include <sys/conf.h>
#include <sys/file.h>
! #include <sys/vnode.h> /* 1/0 on the vomit meter */
#include <sys/proc.h>
#include <sys/uio.h>
#include <sys/errno.h>
#include <sys/strsubr.h>
#include <sys/poll.h>
--- 28,38 ----
#include <sys/strsun.h>
#include <sys/tty.h>
#include <sys/user.h>
#include <sys/conf.h>
#include <sys/file.h>
! #include <sys/vnode.h>
#include <sys/proc.h>
#include <sys/uio.h>
#include <sys/errno.h>
#include <sys/strsubr.h>
#include <sys/poll.h>
*** 63,73 ****
* Most of these should be "void", but the people who defined the "streams"
* data structure for S5 didn't understand data types.
*/
/*
! * Slave side. This is a streams device.
*/
static int ptslopen(queue_t *, dev_t *, int flag, int, cred_t *);
static int ptslclose(queue_t *, int, cred_t *);
static int ptslrserv(queue_t *);
--- 63,73 ----
* Most of these should be "void", but the people who defined the "streams"
* data structure for S5 didn't understand data types.
*/
/*
! * Subsidiary side. This is a streams device.
*/
static int ptslopen(queue_t *, dev_t *, int flag, int, cred_t *);
static int ptslclose(queue_t *, int, cred_t *);
static int ptslrserv(queue_t *);
*** 139,149 ****
* Module linkage information for the kernel.
*/
static struct modldrv modldrv = {
&mod_driverops, /* Type of module. This one is a pseudo driver */
! "tty pseudo driver slave 'ptsl'",
&ptsl_ops, /* driver ops */
};
static struct modlinkage modlinkage = {
MODREV_1,
--- 139,149 ----
* Module linkage information for the kernel.
*/
static struct modldrv modldrv = {
&mod_driverops, /* Type of module. This one is a pseudo driver */
! "tty pseudo driver subsidiary 'ptsl'",
&ptsl_ops, /* driver ops */
};
static struct modlinkage modlinkage = {
MODREV_1,
*** 224,234 ****
return (error);
}
/*
! * Open the slave side of a pty.
*/
/*ARGSUSED*/
static int
ptslopen(queue_t *q, dev_t *devp, int flag, int sflag, cred_t *cred)
{
--- 224,234 ----
return (error);
}
/*
! * Open the subsidiary side of a pty.
*/
/*ARGSUSED*/
static int
ptslopen(queue_t *q, dev_t *devp, int flag, int sflag, cred_t *cred)
{
*** 275,300 ****
}
}
pty->pt_sdev = dev;
q->q_ptr = WR(q)->q_ptr = pty;
! pty->pt_flags &= ~PF_SLAVEGONE;
pty->pt_ttycommon.t_readq = pty->pt_ttycommon.t_writeq = NULL;
/*
! * Slave is ready to accept messages but master still can't send
! * messages to the slave queue since it is not plumbed
! * yet. So do qprocson() and finish slave initialization.
*/
mutex_exit(&pty->ptc_lock);
qprocson(q);
/*
! * Now it is safe to send messages to q, so wakeup master possibly
! * waiting for slave queue to finish open.
*/
mutex_enter(&pty->ptc_lock);
/*
* queue has already been setup with a pointer to
* the stream head that is being referenced
--- 275,300 ----
}
}
pty->pt_sdev = dev;
q->q_ptr = WR(q)->q_ptr = pty;
! pty->pt_flags &= ~PF_SUBSIDGONE;
pty->pt_ttycommon.t_readq = pty->pt_ttycommon.t_writeq = NULL;
/*
! * Subsidiary is ready to accept messages but manager still can't send
! * messages to the subsidiary queue since it is not plumbed
! * yet. So do qprocson() and finish subsidiary initialization.
*/
mutex_exit(&pty->ptc_lock);
qprocson(q);
/*
! * Now it is safe to send messages to q, so wakeup manager possibly
! * waiting for subsidiary queue to finish open.
*/
mutex_enter(&pty->ptc_lock);
/*
* queue has already been setup with a pointer to
* the stream head that is being referenced
*** 301,311 ****
*/
pty->pt_vnode = strq2vp(q);
VN_RELE(pty->pt_vnode);
pty->pt_ttycommon.t_readq = q;
pty->pt_ttycommon.t_writeq = WR(q);
! /* tell master device that slave is ready for writing */
if (pty->pt_flags & PF_CARR_ON)
cv_broadcast(&pty->pt_cv_readq);
mutex_exit(&pty->ptc_lock);
return (0);
--- 301,311 ----
*/
pty->pt_vnode = strq2vp(q);
VN_RELE(pty->pt_vnode);
pty->pt_ttycommon.t_readq = q;
pty->pt_ttycommon.t_writeq = WR(q);
! /* tell manager device that subsidiary is ready for writing */
if (pty->pt_flags & PF_CARR_ON)
cv_broadcast(&pty->pt_cv_readq);
mutex_exit(&pty->ptc_lock);
return (0);
*** 324,337 ****
if ((pty = (struct pty *)q->q_ptr) == NULL)
return (ENODEV); /* already been closed once */
/*
! * Prevent the queues from being uses by master device.
! * This should be done before qprocsoff or writer may attempt
! * to use the slave queue after qprocsoff removed it from the stream and
! * before entering mutex_enter().
*/
mutex_enter(&pty->ptc_lock);
pty->pt_ttycommon.t_readq = NULL;
pty->pt_ttycommon.t_writeq = NULL;
while (pty->pt_flags & PF_IOCTL) {
--- 324,337 ----
if ((pty = (struct pty *)q->q_ptr) == NULL)
return (ENODEV); /* already been closed once */
/*
! * Prevent the queues from being uses by manager device. This should
! * be done before qprocsoff or writer may attempt to use the subsidiary
! * queue after qprocsoff removed it from the stream and before entering
! * mutex_enter().
*/
mutex_enter(&pty->ptc_lock);
pty->pt_ttycommon.t_readq = NULL;
pty->pt_ttycommon.t_writeq = NULL;
while (pty->pt_flags & PF_IOCTL) {
*** 357,371 ****
pt_wbufcid = pty->pt_wbufcid;
pty->pt_wbufcid = 0;
}
/*
! * Clear out all the slave-side state.
*/
pty->pt_flags &= ~(PF_WOPEN|PF_STOPPED|PF_NOSTOP);
if (pty->pt_flags & PF_CARR_ON) {
! pty->pt_flags |= PF_SLAVEGONE; /* let the controller know */
ptcpollwakeup(pty, 0); /* wake up readers/selectors */
ptcpollwakeup(pty, FWRITE); /* wake up writers/selectors */
cv_broadcast(&pty->pt_cv_flags);
}
pty->pt_sdev = 0;
--- 357,371 ----
pt_wbufcid = pty->pt_wbufcid;
pty->pt_wbufcid = 0;
}
/*
! * Clear out all the subsidiary-side state.
*/
pty->pt_flags &= ~(PF_WOPEN|PF_STOPPED|PF_NOSTOP);
if (pty->pt_flags & PF_CARR_ON) {
! pty->pt_flags |= PF_SUBSIDGONE; /* let the controller know */
ptcpollwakeup(pty, 0); /* wake up readers/selectors */
ptcpollwakeup(pty, FWRITE); /* wake up writers/selectors */
cv_broadcast(&pty->pt_cv_flags);
}
pty->pt_sdev = 0;
*** 940,953 ****
ASSERT(MUTEX_HELD(&pty->ptc_lock));
if ((pty->pt_ttycommon.t_cflag&CBAUD) == 0) {
if (pty->pt_flags & PF_CARR_ON) {
/*
! * Let the controller know, then wake up
* readers/selectors and writers/selectors.
*/
! pty->pt_flags |= PF_SLAVEGONE;
ptcpollwakeup(pty, 0);
ptcpollwakeup(pty, FWRITE);
}
}
--- 940,953 ----
ASSERT(MUTEX_HELD(&pty->ptc_lock));
if ((pty->pt_ttycommon.t_cflag&CBAUD) == 0) {
if (pty->pt_flags & PF_CARR_ON) {
/*
! * Let the manager know, then wake up
* readers/selectors and writers/selectors.
*/
! pty->pt_flags |= PF_SUBSIDGONE;
ptcpollwakeup(pty, 0);
ptcpollwakeup(pty, FWRITE);
}
}
*** 975,985 ****
/*
* Wake up controller side. "flag" is 0 if a special packet or
* user control mode message has been queued up (this data is readable,
* so we also treat it as a regular data event; should we send SIGIO,
* though?), FREAD if regular data has been queued up, or FWRITE if
! * the slave's read queue has drained sufficiently to allow writing.
*/
static void
ptcpollwakeup(struct pty *pty, int flag)
{
ASSERT(MUTEX_HELD(&pty->ptc_lock));
--- 975,985 ----
/*
* Wake up controller side. "flag" is 0 if a special packet or
* user control mode message has been queued up (this data is readable,
* so we also treat it as a regular data event; should we send SIGIO,
* though?), FREAD if regular data has been queued up, or FWRITE if
! * the subsidiary's read queue has drained sufficiently to allow writing.
*/
static void
ptcpollwakeup(struct pty *pty, int flag)
{
ASSERT(MUTEX_HELD(&pty->ptc_lock));
*** 995,1015 ****
gsignal(pty->pt_pgrp, SIGURG);
}
if (flag & FREAD) {
/*
* Wake up the parent process as there is regular
! * data to read from slave's write queue
*/
pollwakeup(&ptcph, POLLIN | POLLRDNORM);
cv_broadcast(&pty->pt_cv_writeq);
if (pty->pt_flags & PF_ASYNC)
gsignal(pty->pt_pgrp, SIGIO);
}
if (flag & FWRITE) {
/*
* Wake up the parent process to write
! * data into slave's read queue as the
* read queue has drained enough
*/
pollwakeup(&ptcph, POLLOUT | POLLWRNORM);
cv_broadcast(&pty->pt_cv_readq);
if (pty->pt_flags & PF_ASYNC)
--- 995,1015 ----
gsignal(pty->pt_pgrp, SIGURG);
}
if (flag & FREAD) {
/*
* Wake up the parent process as there is regular
! * data to read from subsidiary's write queue
*/
pollwakeup(&ptcph, POLLIN | POLLRDNORM);
cv_broadcast(&pty->pt_cv_writeq);
if (pty->pt_flags & PF_ASYNC)
gsignal(pty->pt_pgrp, SIGIO);
}
if (flag & FWRITE) {
/*
* Wake up the parent process to write
! * data into subsidiary's read queue as the
* read queue has drained enough
*/
pollwakeup(&ptcph, POLLOUT | POLLWRNORM);
cv_broadcast(&pty->pt_cv_readq);
if (pty->pt_flags & PF_ASYNC)