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*37588Smarc * @(#)tty_tty.c 7.3 (Berkeley) 05/01/89 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*/ 36*37588Smarc syread(dev, uio, flag) 377824Sroot dev_t dev; 387824Sroot struct uio *uio; 3935Sbill { 4035Sbill 418522Sroot if (u.u_ttyp == NULL) 428522Sroot return (ENXIO); 43*37588Smarc return ((*cdevsw[major(u.u_ttyd)].d_read)(u.u_ttyd, uio, flag)); 4435Sbill } 4535Sbill 4635Sbill /*ARGSUSED*/ 47*37588Smarc sywrite(dev, uio, flag) 487824Sroot dev_t dev; 497824Sroot struct uio *uio; 5035Sbill { 5135Sbill 528522Sroot if (u.u_ttyp == NULL) 538522Sroot return (ENXIO); 54*37588Smarc return ((*cdevsw[major(u.u_ttyd)].d_write)(u.u_ttyd, uio, flag)); 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) { 6635811Smarc if (SESS_LEADER(u.u_procp)) { 6735811Smarc /* 6835811Smarc * XXX - check posix draft 6935811Smarc */ 7035811Smarc u.u_ttyp->t_session = 0; 7135811Smarc u.u_ttyp->t_pgid = 0; 7235811Smarc } 73*37588Smarc u.u_ttyp = 0; 74*37588Smarc u.u_ttyd = 0; 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