xref: /csrg-svn/sys/kern/tty_tty.c (revision 17097)
1*17097Sbloom /*	tty_tty.c	6.2	84/08/29	*/
235Sbill 
335Sbill /*
43117Swnj  * Indirect driver for controlling tty.
54487Swnj  *
64487Swnj  * THIS IS GARBAGE: MUST SOON BE DONE WITH struct inode * IN PROC TABLE.
735Sbill  */
8*17097Sbloom #include "param.h"
9*17097Sbloom #include "systm.h"
10*17097Sbloom #include "conf.h"
11*17097Sbloom #include "dir.h"
12*17097Sbloom #include "user.h"
13*17097Sbloom #include "ioctl.h"
14*17097Sbloom #include "tty.h"
15*17097Sbloom #include "proc.h"
16*17097Sbloom #include "uio.h"
1735Sbill 
1835Sbill /*ARGSUSED*/
1935Sbill syopen(dev, flag)
208558Sroot 	dev_t dev;
218558Sroot 	int flag;
2235Sbill {
2335Sbill 
248558Sroot 	if (u.u_ttyp == NULL)
258558Sroot 		return (ENXIO);
268558Sroot 	return ((*cdevsw[major(u.u_ttyd)].d_open)(u.u_ttyd, flag));
2735Sbill }
2835Sbill 
2935Sbill /*ARGSUSED*/
307824Sroot syread(dev, uio)
317824Sroot 	dev_t dev;
327824Sroot 	struct uio *uio;
3335Sbill {
3435Sbill 
358522Sroot 	if (u.u_ttyp == NULL)
368522Sroot 		return (ENXIO);
378522Sroot 	return ((*cdevsw[major(u.u_ttyd)].d_read)(u.u_ttyd, uio));
3835Sbill }
3935Sbill 
4035Sbill /*ARGSUSED*/
417824Sroot sywrite(dev, uio)
427824Sroot 	dev_t dev;
437824Sroot 	struct uio *uio;
4435Sbill {
4535Sbill 
468522Sroot 	if (u.u_ttyp == NULL)
478522Sroot 		return (ENXIO);
488522Sroot 	return ((*cdevsw[major(u.u_ttyd)].d_write)(u.u_ttyd, uio));
4935Sbill }
5035Sbill 
5135Sbill /*ARGSUSED*/
5235Sbill syioctl(dev, cmd, addr, flag)
535618Sroot 	dev_t dev;
545618Sroot 	int cmd;
555618Sroot 	caddr_t addr;
565618Sroot 	int flag;
5735Sbill {
5835Sbill 
595390Swnj 	if (cmd == TIOCNOTTY) {
605390Swnj 		u.u_ttyp = 0;
615390Swnj 		u.u_ttyd = 0;
625390Swnj 		u.u_procp->p_pgrp = 0;
638558Sroot 		return (0);
645390Swnj 	}
658558Sroot 	if (u.u_ttyp == NULL)
668558Sroot 		return (ENXIO);
678558Sroot 	return ((*cdevsw[major(u.u_ttyd)].d_ioctl)(u.u_ttyd, cmd, addr, flag));
6835Sbill }
694487Swnj 
708591Sroot /*ARGSUSED*/
714487Swnj syselect(dev, flag)
728591Sroot 	dev_t dev;
738591Sroot 	int flag;
744487Swnj {
754487Swnj 
765576Swnj 	if (u.u_ttyp == NULL) {
774487Swnj 		u.u_error = ENXIO;
785390Swnj 		return (0);
794487Swnj 	}
806385Swnj 	return ((*cdevsw[major(u.u_ttyd)].d_select)(u.u_ttyd, flag));
814487Swnj }
82