123393Smckusick /* 229112Smckusick * Copyright (c) 1982, 1986 Regents of the University of California. 323393Smckusick * All rights reserved. The Berkeley software License Agreement 423393Smckusick * specifies the terms and conditions for redistribution. 523393Smckusick * 6*35811Smarc * @(#)tty_tty.c 7.2 (Berkeley) 10/18/88 723393Smckusick */ 835Sbill 935Sbill /* 103117Swnj * Indirect driver for controlling tty. 114487Swnj * 124487Swnj * THIS IS GARBAGE: MUST SOON BE DONE WITH struct inode * IN PROC TABLE. 1335Sbill */ 1417097Sbloom #include "param.h" 1517097Sbloom #include "systm.h" 1617097Sbloom #include "conf.h" 1717097Sbloom #include "dir.h" 1817097Sbloom #include "user.h" 1917097Sbloom #include "ioctl.h" 2017097Sbloom #include "tty.h" 2117097Sbloom #include "proc.h" 2217097Sbloom #include "uio.h" 2335Sbill 2435Sbill /*ARGSUSED*/ 2535Sbill syopen(dev, flag) 268558Sroot dev_t dev; 278558Sroot int flag; 2835Sbill { 2935Sbill 308558Sroot if (u.u_ttyp == NULL) 318558Sroot return (ENXIO); 328558Sroot return ((*cdevsw[major(u.u_ttyd)].d_open)(u.u_ttyd, flag)); 3335Sbill } 3435Sbill 3535Sbill /*ARGSUSED*/ 367824Sroot syread(dev, uio) 377824Sroot dev_t dev; 387824Sroot struct uio *uio; 3935Sbill { 4035Sbill 418522Sroot if (u.u_ttyp == NULL) 428522Sroot return (ENXIO); 438522Sroot return ((*cdevsw[major(u.u_ttyd)].d_read)(u.u_ttyd, uio)); 4435Sbill } 4535Sbill 4635Sbill /*ARGSUSED*/ 477824Sroot sywrite(dev, uio) 487824Sroot dev_t dev; 497824Sroot struct uio *uio; 5035Sbill { 5135Sbill 528522Sroot if (u.u_ttyp == NULL) 538522Sroot return (ENXIO); 548522Sroot return ((*cdevsw[major(u.u_ttyd)].d_write)(u.u_ttyd, uio)); 5535Sbill } 5635Sbill 5735Sbill /*ARGSUSED*/ 5835Sbill syioctl(dev, cmd, addr, flag) 595618Sroot dev_t dev; 605618Sroot int cmd; 615618Sroot caddr_t addr; 625618Sroot int flag; 6335Sbill { 6435Sbill 655390Swnj if (cmd == TIOCNOTTY) { 665390Swnj u.u_ttyp = 0; 675390Swnj u.u_ttyd = 0; 68*35811Smarc if (SESS_LEADER(u.u_procp)) { 69*35811Smarc /* 70*35811Smarc * XXX - check posix draft 71*35811Smarc */ 72*35811Smarc u.u_ttyp->t_session = 0; 73*35811Smarc u.u_ttyp->t_pgid = 0; 74*35811Smarc } 758558Sroot return (0); 765390Swnj } 778558Sroot if (u.u_ttyp == NULL) 788558Sroot return (ENXIO); 798558Sroot return ((*cdevsw[major(u.u_ttyd)].d_ioctl)(u.u_ttyd, cmd, addr, flag)); 8035Sbill } 814487Swnj 828591Sroot /*ARGSUSED*/ 834487Swnj syselect(dev, flag) 848591Sroot dev_t dev; 858591Sroot int flag; 864487Swnj { 874487Swnj 885576Swnj if (u.u_ttyp == NULL) { 894487Swnj u.u_error = ENXIO; 905390Swnj return (0); 914487Swnj } 926385Swnj return ((*cdevsw[major(u.u_ttyd)].d_select)(u.u_ttyd, flag)); 934487Swnj } 94