Set tp->t_dev to the correct dev_t value in both ptmopen and ptsopen.

Depending on how the pty had been opened, t_dev could previously have
been set to NODEV.  This was probably harmless before, but it caused the
compatibility handler for the COMPAT_60_TIOCPTSNAME ioctl to fail for
ptys that were allocated by screen(1), but only if this was the first
time that the pty had ever been used.
This commit is contained in:
apb 2012-10-20 00:21:10 +00:00
parent 10aef5a73b
commit b6366e94c8
1 changed files with 4 additions and 2 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: tty_pty.c,v 1.131 2011/09/24 04:10:03 christos Exp $ */
/* $NetBSD: tty_pty.c,v 1.132 2012/10/20 00:21:10 apb Exp $ */
/*
* Copyright (c) 1982, 1986, 1989, 1993
@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: tty_pty.c,v 1.131 2011/09/24 04:10:03 christos Exp $");
__KERNEL_RCSID(0, "$NetBSD: tty_pty.c,v 1.132 2012/10/20 00:21:10 apb Exp $");
#include "opt_ptm.h"
@ -338,6 +338,7 @@ ptsopen(dev_t dev, int flag, int devtype, struct lwp *l)
pti = pt_softc[ptn];
tp = pti->pt_tty;
if (!ISSET(tp->t_state, TS_ISOPEN)) {
tp->t_dev = dev;
ttychars(tp); /* Set up default chars */
tp->t_iflag = TTYDEF_IFLAG;
tp->t_oflag = TTYDEF_OFLAG;
@ -569,6 +570,7 @@ ptcopen(dev_t dev, int flag, int devtype, struct lwp *l)
mutex_spin_exit(&tty_lock);
return EIO;
}
tp->t_dev = dev;
tp->t_oproc = ptsstart;
mutex_spin_exit(&tty_lock);
(void)(*tp->t_linesw->l_modem)(tp, 1);