1*7c478bd9Sstevel@tonic-gate /* 2*7c478bd9Sstevel@tonic-gate * CDDL HEADER START 3*7c478bd9Sstevel@tonic-gate * 4*7c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*7c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*7c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*7c478bd9Sstevel@tonic-gate * with the License. 8*7c478bd9Sstevel@tonic-gate * 9*7c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*7c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*7c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 12*7c478bd9Sstevel@tonic-gate * and limitations under the License. 13*7c478bd9Sstevel@tonic-gate * 14*7c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*7c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*7c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*7c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*7c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*7c478bd9Sstevel@tonic-gate * 20*7c478bd9Sstevel@tonic-gate * CDDL HEADER END 21*7c478bd9Sstevel@tonic-gate */ 22*7c478bd9Sstevel@tonic-gate /* 23*7c478bd9Sstevel@tonic-gate * Copyright 1990-1992,1996,1998-2003 Sun Microsystems, Inc. 24*7c478bd9Sstevel@tonic-gate * All rights reserved. 25*7c478bd9Sstevel@tonic-gate * Use is subject to license terms. 26*7c478bd9Sstevel@tonic-gate */ 27*7c478bd9Sstevel@tonic-gate 28*7c478bd9Sstevel@tonic-gate /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ 29*7c478bd9Sstevel@tonic-gate /* All Rights Reserved */ 30*7c478bd9Sstevel@tonic-gate 31*7c478bd9Sstevel@tonic-gate 32*7c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 33*7c478bd9Sstevel@tonic-gate /* from S5R4 1.22 */ 34*7c478bd9Sstevel@tonic-gate 35*7c478bd9Sstevel@tonic-gate /* 36*7c478bd9Sstevel@tonic-gate * Indirect driver for controlling tty. 37*7c478bd9Sstevel@tonic-gate */ 38*7c478bd9Sstevel@tonic-gate #include <sys/types.h> 39*7c478bd9Sstevel@tonic-gate #include <sys/errno.h> 40*7c478bd9Sstevel@tonic-gate #include <sys/conf.h> 41*7c478bd9Sstevel@tonic-gate #include <sys/proc.h> 42*7c478bd9Sstevel@tonic-gate #include <sys/tty.h> 43*7c478bd9Sstevel@tonic-gate #include <sys/stream.h> 44*7c478bd9Sstevel@tonic-gate #include <sys/strsubr.h> 45*7c478bd9Sstevel@tonic-gate #include <sys/cred.h> 46*7c478bd9Sstevel@tonic-gate #include <sys/uio.h> 47*7c478bd9Sstevel@tonic-gate #include <sys/session.h> 48*7c478bd9Sstevel@tonic-gate #include <sys/ddi.h> 49*7c478bd9Sstevel@tonic-gate #include <sys/debug.h> 50*7c478bd9Sstevel@tonic-gate #include <sys/stat.h> 51*7c478bd9Sstevel@tonic-gate #include <sys/sunddi.h> 52*7c478bd9Sstevel@tonic-gate #include <sys/param.h> 53*7c478bd9Sstevel@tonic-gate #include <sys/systm.h> 54*7c478bd9Sstevel@tonic-gate #include <sys/modctl.h> 55*7c478bd9Sstevel@tonic-gate #include <sys/fs/snode.h> 56*7c478bd9Sstevel@tonic-gate #include <sys/file.h> 57*7c478bd9Sstevel@tonic-gate 58*7c478bd9Sstevel@tonic-gate #define IS_STREAM(dev) (devopsp[getmajor(dev)]->devo_cb_ops->cb_str != NULL) 59*7c478bd9Sstevel@tonic-gate 60*7c478bd9Sstevel@tonic-gate int syopen(dev_t *, int, int, cred_t *); 61*7c478bd9Sstevel@tonic-gate int syclose(dev_t, int, int, cred_t *); 62*7c478bd9Sstevel@tonic-gate int syread(dev_t, struct uio *, cred_t *); 63*7c478bd9Sstevel@tonic-gate int sywrite(dev_t, struct uio *, cred_t *); 64*7c478bd9Sstevel@tonic-gate int sypoll(dev_t, short, int, short *, struct pollhead **); 65*7c478bd9Sstevel@tonic-gate int syioctl(dev_t, int, intptr_t, int, cred_t *, int *); 66*7c478bd9Sstevel@tonic-gate 67*7c478bd9Sstevel@tonic-gate static int sy_info(dev_info_t *, ddi_info_cmd_t, void *, void **); 68*7c478bd9Sstevel@tonic-gate static int sy_attach(dev_info_t *, ddi_attach_cmd_t); 69*7c478bd9Sstevel@tonic-gate static dev_info_t *sy_dip; /* private copy of devinfo pointer */ 70*7c478bd9Sstevel@tonic-gate 71*7c478bd9Sstevel@tonic-gate struct cb_ops sy_cb_ops = { 72*7c478bd9Sstevel@tonic-gate 73*7c478bd9Sstevel@tonic-gate syopen, /* open */ 74*7c478bd9Sstevel@tonic-gate syclose, /* close */ 75*7c478bd9Sstevel@tonic-gate nodev, /* strategy */ 76*7c478bd9Sstevel@tonic-gate nodev, /* print */ 77*7c478bd9Sstevel@tonic-gate nodev, /* dump */ 78*7c478bd9Sstevel@tonic-gate syread, /* read */ 79*7c478bd9Sstevel@tonic-gate sywrite, /* write */ 80*7c478bd9Sstevel@tonic-gate syioctl, /* ioctl */ 81*7c478bd9Sstevel@tonic-gate nodev, /* devmap */ 82*7c478bd9Sstevel@tonic-gate nodev, /* mmap */ 83*7c478bd9Sstevel@tonic-gate nodev, /* segmap */ 84*7c478bd9Sstevel@tonic-gate sypoll, /* poll */ 85*7c478bd9Sstevel@tonic-gate ddi_prop_op, /* cb_prop_op */ 86*7c478bd9Sstevel@tonic-gate 0, /* streamtab */ 87*7c478bd9Sstevel@tonic-gate D_NEW | D_MP /* Driver compatibility flag */ 88*7c478bd9Sstevel@tonic-gate 89*7c478bd9Sstevel@tonic-gate }; 90*7c478bd9Sstevel@tonic-gate 91*7c478bd9Sstevel@tonic-gate struct dev_ops sy_ops = { 92*7c478bd9Sstevel@tonic-gate 93*7c478bd9Sstevel@tonic-gate DEVO_REV, /* devo_rev, */ 94*7c478bd9Sstevel@tonic-gate 0, /* refcnt */ 95*7c478bd9Sstevel@tonic-gate sy_info, /* info */ 96*7c478bd9Sstevel@tonic-gate nulldev, /* identify */ 97*7c478bd9Sstevel@tonic-gate nulldev, /* probe */ 98*7c478bd9Sstevel@tonic-gate sy_attach, /* attach */ 99*7c478bd9Sstevel@tonic-gate nodev, /* detach */ 100*7c478bd9Sstevel@tonic-gate nodev, /* reset */ 101*7c478bd9Sstevel@tonic-gate &sy_cb_ops, /* driver operations */ 102*7c478bd9Sstevel@tonic-gate (struct bus_ops *)0 /* bus operations */ 103*7c478bd9Sstevel@tonic-gate 104*7c478bd9Sstevel@tonic-gate }; 105*7c478bd9Sstevel@tonic-gate 106*7c478bd9Sstevel@tonic-gate 107*7c478bd9Sstevel@tonic-gate extern int nodev(void); 108*7c478bd9Sstevel@tonic-gate extern int nulldev(void); 109*7c478bd9Sstevel@tonic-gate extern int dseekneg_flag; 110*7c478bd9Sstevel@tonic-gate extern struct mod_ops mod_driverops; 111*7c478bd9Sstevel@tonic-gate extern struct dev_ops sy_ops; 112*7c478bd9Sstevel@tonic-gate 113*7c478bd9Sstevel@tonic-gate /* 114*7c478bd9Sstevel@tonic-gate * Module linkage information for the kernel. 115*7c478bd9Sstevel@tonic-gate */ 116*7c478bd9Sstevel@tonic-gate 117*7c478bd9Sstevel@tonic-gate static struct modldrv modldrv = { 118*7c478bd9Sstevel@tonic-gate &mod_driverops, /* Type of module. This one is a pseudo driver */ 119*7c478bd9Sstevel@tonic-gate "Indirect driver for tty 'sy' %I%", 120*7c478bd9Sstevel@tonic-gate &sy_ops, /* driver ops */ 121*7c478bd9Sstevel@tonic-gate }; 122*7c478bd9Sstevel@tonic-gate 123*7c478bd9Sstevel@tonic-gate static struct modlinkage modlinkage = { 124*7c478bd9Sstevel@tonic-gate MODREV_1, 125*7c478bd9Sstevel@tonic-gate &modldrv, 126*7c478bd9Sstevel@tonic-gate NULL 127*7c478bd9Sstevel@tonic-gate }; 128*7c478bd9Sstevel@tonic-gate 129*7c478bd9Sstevel@tonic-gate 130*7c478bd9Sstevel@tonic-gate int 131*7c478bd9Sstevel@tonic-gate _init(void) 132*7c478bd9Sstevel@tonic-gate { 133*7c478bd9Sstevel@tonic-gate return (mod_install(&modlinkage)); 134*7c478bd9Sstevel@tonic-gate } 135*7c478bd9Sstevel@tonic-gate 136*7c478bd9Sstevel@tonic-gate 137*7c478bd9Sstevel@tonic-gate int 138*7c478bd9Sstevel@tonic-gate _fini(void) 139*7c478bd9Sstevel@tonic-gate { 140*7c478bd9Sstevel@tonic-gate return (mod_remove(&modlinkage)); 141*7c478bd9Sstevel@tonic-gate } 142*7c478bd9Sstevel@tonic-gate 143*7c478bd9Sstevel@tonic-gate int 144*7c478bd9Sstevel@tonic-gate _info(struct modinfo *modinfop) 145*7c478bd9Sstevel@tonic-gate { 146*7c478bd9Sstevel@tonic-gate return (mod_info(&modlinkage, modinfop)); 147*7c478bd9Sstevel@tonic-gate } 148*7c478bd9Sstevel@tonic-gate 149*7c478bd9Sstevel@tonic-gate /* ARGSUSED */ 150*7c478bd9Sstevel@tonic-gate static int 151*7c478bd9Sstevel@tonic-gate sy_attach(dev_info_t *devi, ddi_attach_cmd_t cmd) 152*7c478bd9Sstevel@tonic-gate { 153*7c478bd9Sstevel@tonic-gate if (ddi_create_minor_node(devi, "tty", S_IFCHR, 154*7c478bd9Sstevel@tonic-gate 0, DDI_PSEUDO, NULL) == DDI_FAILURE) { 155*7c478bd9Sstevel@tonic-gate ddi_remove_minor_node(devi, NULL); 156*7c478bd9Sstevel@tonic-gate return (-1); 157*7c478bd9Sstevel@tonic-gate } 158*7c478bd9Sstevel@tonic-gate sy_dip = devi; 159*7c478bd9Sstevel@tonic-gate return (DDI_SUCCESS); 160*7c478bd9Sstevel@tonic-gate } 161*7c478bd9Sstevel@tonic-gate 162*7c478bd9Sstevel@tonic-gate /* ARGSUSED */ 163*7c478bd9Sstevel@tonic-gate static int 164*7c478bd9Sstevel@tonic-gate sy_info(dev_info_t *dip, ddi_info_cmd_t infocmd, void *arg, void **result) 165*7c478bd9Sstevel@tonic-gate { 166*7c478bd9Sstevel@tonic-gate dev_t dev = (dev_t)arg; 167*7c478bd9Sstevel@tonic-gate int error; 168*7c478bd9Sstevel@tonic-gate 169*7c478bd9Sstevel@tonic-gate switch (infocmd) { 170*7c478bd9Sstevel@tonic-gate case DDI_INFO_DEVT2DEVINFO: 171*7c478bd9Sstevel@tonic-gate if (sy_dip == NULL) { 172*7c478bd9Sstevel@tonic-gate *result = (void *)NULL; 173*7c478bd9Sstevel@tonic-gate error = DDI_FAILURE; 174*7c478bd9Sstevel@tonic-gate } else { 175*7c478bd9Sstevel@tonic-gate *result = (void *) sy_dip; 176*7c478bd9Sstevel@tonic-gate error = DDI_SUCCESS; 177*7c478bd9Sstevel@tonic-gate } 178*7c478bd9Sstevel@tonic-gate break; 179*7c478bd9Sstevel@tonic-gate case DDI_INFO_DEVT2INSTANCE: 180*7c478bd9Sstevel@tonic-gate if (getminor(dev) != 0) { 181*7c478bd9Sstevel@tonic-gate *result = (void *)-1; 182*7c478bd9Sstevel@tonic-gate error = DDI_FAILURE; 183*7c478bd9Sstevel@tonic-gate } else { 184*7c478bd9Sstevel@tonic-gate *result = (void *)0; 185*7c478bd9Sstevel@tonic-gate error = DDI_SUCCESS; 186*7c478bd9Sstevel@tonic-gate } 187*7c478bd9Sstevel@tonic-gate break; 188*7c478bd9Sstevel@tonic-gate default: 189*7c478bd9Sstevel@tonic-gate error = DDI_FAILURE; 190*7c478bd9Sstevel@tonic-gate } 191*7c478bd9Sstevel@tonic-gate return (error); 192*7c478bd9Sstevel@tonic-gate } 193*7c478bd9Sstevel@tonic-gate 194*7c478bd9Sstevel@tonic-gate 195*7c478bd9Sstevel@tonic-gate /* ARGSUSED */ 196*7c478bd9Sstevel@tonic-gate int 197*7c478bd9Sstevel@tonic-gate syopen(dev_t *devp, int flag, int otyp, struct cred *cr) 198*7c478bd9Sstevel@tonic-gate { 199*7c478bd9Sstevel@tonic-gate dev_t ttyd; 200*7c478bd9Sstevel@tonic-gate vnode_t *ttyvp; 201*7c478bd9Sstevel@tonic-gate sess_t *sp = curproc->p_sessp; 202*7c478bd9Sstevel@tonic-gate int error; 203*7c478bd9Sstevel@tonic-gate 204*7c478bd9Sstevel@tonic-gate if ((ttyd = sp->s_dev) == NODEV) 205*7c478bd9Sstevel@tonic-gate return (ENXIO); 206*7c478bd9Sstevel@tonic-gate TTY_HOLD(sp); 207*7c478bd9Sstevel@tonic-gate if ((ttyvp = sp->s_vp) == NULL) { 208*7c478bd9Sstevel@tonic-gate TTY_RELE(sp); 209*7c478bd9Sstevel@tonic-gate return (EIO); 210*7c478bd9Sstevel@tonic-gate } 211*7c478bd9Sstevel@tonic-gate 212*7c478bd9Sstevel@tonic-gate /* 213*7c478bd9Sstevel@tonic-gate * Open the control terminal. The control terminal may be 214*7c478bd9Sstevel@tonic-gate * opened multiple times and it is closed in freectty(). 215*7c478bd9Sstevel@tonic-gate * The multi-open, single-clone means that no cloning 216*7c478bd9Sstevel@tonic-gate * can happen via this open, hence the assertion. 217*7c478bd9Sstevel@tonic-gate */ 218*7c478bd9Sstevel@tonic-gate error = VOP_OPEN(&ttyvp, FNOCTTY | flag, cr); 219*7c478bd9Sstevel@tonic-gate if (error == 0) { 220*7c478bd9Sstevel@tonic-gate struct snode *csp; 221*7c478bd9Sstevel@tonic-gate 222*7c478bd9Sstevel@tonic-gate /* 223*7c478bd9Sstevel@tonic-gate * XXX: This driver binds a single minor number to the 224*7c478bd9Sstevel@tonic-gate * current controlling tty of the process issueing the 225*7c478bd9Sstevel@tonic-gate * open / close. If we implement a traditional close 226*7c478bd9Sstevel@tonic-gate * for this driver then specfs will only invoke this driver 227*7c478bd9Sstevel@tonic-gate * on the last close of our one minor number - which is not 228*7c478bd9Sstevel@tonic-gate * what we want. Since we already get the open / close 229*7c478bd9Sstevel@tonic-gate * semantic that we want from makectty and freectty, we reach 230*7c478bd9Sstevel@tonic-gate * back into the common snode and decrease the open count so 231*7c478bd9Sstevel@tonic-gate * that the specfs filtering of all but the last close 232*7c478bd9Sstevel@tonic-gate * does not get in our way. To clean this up, a new cb_flag 233*7c478bd9Sstevel@tonic-gate * that causes specfs to call the driver on each close 234*7c478bd9Sstevel@tonic-gate * should be considered. 235*7c478bd9Sstevel@tonic-gate */ 236*7c478bd9Sstevel@tonic-gate ASSERT(ttyd == ttyvp->v_rdev); 237*7c478bd9Sstevel@tonic-gate ASSERT(vn_matchops(ttyvp, spec_getvnodeops())); 238*7c478bd9Sstevel@tonic-gate csp = VTOS(VTOS(ttyvp)->s_commonvp); 239*7c478bd9Sstevel@tonic-gate mutex_enter(&csp->s_lock); 240*7c478bd9Sstevel@tonic-gate csp->s_count--; 241*7c478bd9Sstevel@tonic-gate mutex_exit(&csp->s_lock); 242*7c478bd9Sstevel@tonic-gate } 243*7c478bd9Sstevel@tonic-gate TTY_RELE(sp); 244*7c478bd9Sstevel@tonic-gate return (error); 245*7c478bd9Sstevel@tonic-gate } 246*7c478bd9Sstevel@tonic-gate 247*7c478bd9Sstevel@tonic-gate /* ARGSUSED */ 248*7c478bd9Sstevel@tonic-gate int 249*7c478bd9Sstevel@tonic-gate syclose(dev_t dev, int flag, int otyp, struct cred *cr) 250*7c478bd9Sstevel@tonic-gate { 251*7c478bd9Sstevel@tonic-gate return (0); 252*7c478bd9Sstevel@tonic-gate } 253*7c478bd9Sstevel@tonic-gate 254*7c478bd9Sstevel@tonic-gate /* ARGSUSED */ 255*7c478bd9Sstevel@tonic-gate int 256*7c478bd9Sstevel@tonic-gate syread(dev_t dev, struct uio *uiop, struct cred *cr) 257*7c478bd9Sstevel@tonic-gate { 258*7c478bd9Sstevel@tonic-gate vnode_t *ttyvp; 259*7c478bd9Sstevel@tonic-gate sess_t *sp = curproc->p_sessp; 260*7c478bd9Sstevel@tonic-gate int error; 261*7c478bd9Sstevel@tonic-gate 262*7c478bd9Sstevel@tonic-gate if (sp->s_dev == NODEV) 263*7c478bd9Sstevel@tonic-gate return (ENXIO); 264*7c478bd9Sstevel@tonic-gate TTY_HOLD(sp); 265*7c478bd9Sstevel@tonic-gate if ((ttyvp = sp->s_vp) == NULL) { 266*7c478bd9Sstevel@tonic-gate TTY_RELE(sp); 267*7c478bd9Sstevel@tonic-gate return (EIO); 268*7c478bd9Sstevel@tonic-gate } 269*7c478bd9Sstevel@tonic-gate error = VOP_READ(ttyvp, uiop, 0, cr, NULL); 270*7c478bd9Sstevel@tonic-gate TTY_RELE(sp); 271*7c478bd9Sstevel@tonic-gate return (error); 272*7c478bd9Sstevel@tonic-gate 273*7c478bd9Sstevel@tonic-gate } 274*7c478bd9Sstevel@tonic-gate 275*7c478bd9Sstevel@tonic-gate /* ARGSUSED */ 276*7c478bd9Sstevel@tonic-gate int 277*7c478bd9Sstevel@tonic-gate sywrite(dev_t dev, struct uio *uiop, struct cred *cr) 278*7c478bd9Sstevel@tonic-gate { 279*7c478bd9Sstevel@tonic-gate vnode_t *ttyvp; 280*7c478bd9Sstevel@tonic-gate sess_t *sp = curproc->p_sessp; 281*7c478bd9Sstevel@tonic-gate int error; 282*7c478bd9Sstevel@tonic-gate 283*7c478bd9Sstevel@tonic-gate if (sp->s_dev == NODEV) 284*7c478bd9Sstevel@tonic-gate return (ENXIO); 285*7c478bd9Sstevel@tonic-gate TTY_HOLD(sp); 286*7c478bd9Sstevel@tonic-gate if ((ttyvp = sp->s_vp) == NULL) { 287*7c478bd9Sstevel@tonic-gate TTY_RELE(sp); 288*7c478bd9Sstevel@tonic-gate return (EIO); 289*7c478bd9Sstevel@tonic-gate } 290*7c478bd9Sstevel@tonic-gate 291*7c478bd9Sstevel@tonic-gate error = VOP_WRITE(ttyvp, uiop, 0, cr, NULL); 292*7c478bd9Sstevel@tonic-gate TTY_RELE(sp); 293*7c478bd9Sstevel@tonic-gate return (error); 294*7c478bd9Sstevel@tonic-gate } 295*7c478bd9Sstevel@tonic-gate 296*7c478bd9Sstevel@tonic-gate 297*7c478bd9Sstevel@tonic-gate /* ARGSUSED */ 298*7c478bd9Sstevel@tonic-gate int 299*7c478bd9Sstevel@tonic-gate syioctl(dev_t dev, int cmd, intptr_t arg, int mode, struct cred *cr, 300*7c478bd9Sstevel@tonic-gate int *rvalp) 301*7c478bd9Sstevel@tonic-gate { 302*7c478bd9Sstevel@tonic-gate vnode_t *ttyvp; 303*7c478bd9Sstevel@tonic-gate sess_t *sp = curproc->p_sessp; 304*7c478bd9Sstevel@tonic-gate int error; 305*7c478bd9Sstevel@tonic-gate 306*7c478bd9Sstevel@tonic-gate if (sp->s_dev == NODEV) 307*7c478bd9Sstevel@tonic-gate return (ENXIO); 308*7c478bd9Sstevel@tonic-gate TTY_HOLD(sp); 309*7c478bd9Sstevel@tonic-gate if ((ttyvp = sp->s_vp) == NULL) { 310*7c478bd9Sstevel@tonic-gate TTY_RELE(sp); 311*7c478bd9Sstevel@tonic-gate return (EIO); 312*7c478bd9Sstevel@tonic-gate } 313*7c478bd9Sstevel@tonic-gate error = VOP_IOCTL(ttyvp, cmd, arg, mode, cr, rvalp); 314*7c478bd9Sstevel@tonic-gate TTY_RELE(sp); 315*7c478bd9Sstevel@tonic-gate return (error); 316*7c478bd9Sstevel@tonic-gate } 317*7c478bd9Sstevel@tonic-gate 318*7c478bd9Sstevel@tonic-gate 319*7c478bd9Sstevel@tonic-gate 320*7c478bd9Sstevel@tonic-gate /* ARGSUSED */ 321*7c478bd9Sstevel@tonic-gate int 322*7c478bd9Sstevel@tonic-gate sypoll(dev_t dev, short events, int anyyet, short *reventsp, 323*7c478bd9Sstevel@tonic-gate struct pollhead **phpp) 324*7c478bd9Sstevel@tonic-gate { 325*7c478bd9Sstevel@tonic-gate vnode_t *ttyvp; 326*7c478bd9Sstevel@tonic-gate sess_t *sp = curproc->p_sessp; 327*7c478bd9Sstevel@tonic-gate int error; 328*7c478bd9Sstevel@tonic-gate 329*7c478bd9Sstevel@tonic-gate if (sp->s_dev == NODEV) 330*7c478bd9Sstevel@tonic-gate return (ENXIO); 331*7c478bd9Sstevel@tonic-gate TTY_HOLD(sp); 332*7c478bd9Sstevel@tonic-gate if ((ttyvp = sp->s_vp) == NULL) { 333*7c478bd9Sstevel@tonic-gate TTY_RELE(sp); 334*7c478bd9Sstevel@tonic-gate return (EIO); 335*7c478bd9Sstevel@tonic-gate } 336*7c478bd9Sstevel@tonic-gate error = VOP_POLL(ttyvp, events, anyyet, reventsp, phpp); 337*7c478bd9Sstevel@tonic-gate TTY_RELE(sp); 338*7c478bd9Sstevel@tonic-gate return (error); 339*7c478bd9Sstevel@tonic-gate } 340