clopen(dev, flag, mode, p)
int clopen (dev, flag, mode, p)
clopen(dev, flag, mode, p)	dev_t dev;	int flag;	int mode;	struct proc *p;{	int s, unit, channel;	struct cl_info *cl;	struct clsoftc *sc;	struct tty *tp;		unit = CL_UNIT(dev);	if (unit >= clcd.cd_ndevs || 	    (sc = (struct clsoftc *) clcd.cd_devs[unit]) == NULL) {		return (ENODEV);	}	channel = CL_CHANNEL(dev);	cl = &sc->sc_cl[channel];	s = spltty();	if (cl->tty) {		tp = cl->tty;	} else {		tp = cl->tty = ttymalloc();	}	tp->t_oproc = clstart;	tp->t_param = clparam;	tp->t_dev = dev;	if ((tp->t_state & TS_ISOPEN) == 0) {		tp->t_state |= TS_WOPEN;		ttychars(tp);		if (tp->t_ispeed == 0) {			/*			 * only when cleared do we reset to defaults.			 */			tp->t_iflag = TTYDEF_IFLAG;			tp->t_oflag = TTYDEF_OFLAG;			tp->t_cflag = TTYDEF_CFLAG;			tp->t_lflag = TTYDEF_LFLAG;			tp->t_ispeed = tp->t_ospeed = cldefaultrate;		}		/*		 * do these all the time		 */		if (cl->cl_swflags & TIOCFLAG_CLOCAL)			tp->t_cflag |= CLOCAL;		if (cl->cl_swflags & TIOCFLAG_CRTSCTS)			tp->t_cflag |= CRTSCTS;		if (cl->cl_swflags & TIOCFLAG_MDMBUF)			tp->t_cflag |= MDMBUF;		clparam(tp, &tp->t_termios);		ttsetwater(tp);		(void)clmctl(dev, TIOCM_DTR | TIOCM_RTS, DMSET);#ifdef XXX		if ((cl->cl_swflags & TIOCFLAG_SOFTCAR) ||			(clmctl(dev, 0, DMGET) & TIOCM_CD)) {			tp->t_state |= TS_CARR_ON;		} else {			tp->t_state &= ~TS_CARR_ON;		}#endif		tp->t_state |= TS_CARR_ON;	} else if (tp->t_state & TS_XCLUDE && p->p_ucred->cr_uid != 0) {		splx(s);		return (EBUSY);	}#ifdef XXX	/*	 * if NONBLOCK requested, ignore carrier	 */	if (flag & O_NONBLOCK)		goto done;#endif	splx(s);	/*	 * Reset the tty pointer, as there could have been a dialout	 * use of the tty with a dialin open waiting.	 */	tp->t_dev = dev;#ifdef DEBUG	cl_dumpport(channel);#endif	return ((*linesw[tp->t_line].l_open)(dev, tp));}