sanity checks in getblk() and geteblk()
[unix-history] / usr / src / sys / kern / tty_tty.c
CommitLineData
da7c5cc6
KM
1/*
2 * Copyright (c) 1982 Regents of the University of California.
3 * All rights reserved. The Berkeley software License Agreement
4 * specifies the terms and conditions for redistribution.
5 *
6 * @(#)tty_tty.c 6.3 (Berkeley) %G%
7 */
63c57592
BJ
8
9/*
964bcfb1 10 * Indirect driver for controlling tty.
231ed58b
BJ
11 *
12 * THIS IS GARBAGE: MUST SOON BE DONE WITH struct inode * IN PROC TABLE.
63c57592 13 */
94368568
JB
14#include "param.h"
15#include "systm.h"
16#include "conf.h"
17#include "dir.h"
18#include "user.h"
19#include "ioctl.h"
20#include "tty.h"
21#include "proc.h"
22#include "uio.h"
63c57592
BJ
23
24/*ARGSUSED*/
25syopen(dev, flag)
830bbc16
BJ
26 dev_t dev;
27 int flag;
63c57592
BJ
28{
29
830bbc16
BJ
30 if (u.u_ttyp == NULL)
31 return (ENXIO);
32 return ((*cdevsw[major(u.u_ttyd)].d_open)(u.u_ttyd, flag));
63c57592
BJ
33}
34
35/*ARGSUSED*/
be3a1208
BJ
36syread(dev, uio)
37 dev_t dev;
38 struct uio *uio;
63c57592
BJ
39{
40
840510a3
BJ
41 if (u.u_ttyp == NULL)
42 return (ENXIO);
43 return ((*cdevsw[major(u.u_ttyd)].d_read)(u.u_ttyd, uio));
63c57592
BJ
44}
45
46/*ARGSUSED*/
be3a1208
BJ
47sywrite(dev, uio)
48 dev_t dev;
49 struct uio *uio;
63c57592
BJ
50{
51
840510a3
BJ
52 if (u.u_ttyp == NULL)
53 return (ENXIO);
54 return ((*cdevsw[major(u.u_ttyd)].d_write)(u.u_ttyd, uio));
63c57592
BJ
55}
56
57/*ARGSUSED*/
58syioctl(dev, cmd, addr, flag)
35c1dcdb
BJ
59 dev_t dev;
60 int cmd;
61 caddr_t addr;
62 int flag;
63c57592
BJ
63{
64
9060c89c
BJ
65 if (cmd == TIOCNOTTY) {
66 u.u_ttyp = 0;
67 u.u_ttyd = 0;
68 u.u_procp->p_pgrp = 0;
830bbc16 69 return (0);
4460d508 70 }
830bbc16
BJ
71 if (u.u_ttyp == NULL)
72 return (ENXIO);
73 return ((*cdevsw[major(u.u_ttyd)].d_ioctl)(u.u_ttyd, cmd, addr, flag));
63c57592 74}
231ed58b 75
a8d3bf7f 76/*ARGSUSED*/
231ed58b 77syselect(dev, flag)
a8d3bf7f
BJ
78 dev_t dev;
79 int flag;
231ed58b
BJ
80{
81
e8743532 82 if (u.u_ttyp == NULL) {
231ed58b 83 u.u_error = ENXIO;
9060c89c 84 return (0);
231ed58b 85 }
0f8a7bf9 86 return ((*cdevsw[major(u.u_ttyd)].d_select)(u.u_ttyd, flag));
231ed58b 87}