Commit | Line | Data |
---|---|---|
da7c5cc6 | 1 | /* |
0880b18e | 2 | * Copyright (c) 1982, 1986 Regents of the University of California. |
da7c5cc6 KM |
3 | * All rights reserved. The Berkeley software License Agreement |
4 | * specifies the terms and conditions for redistribution. | |
5 | * | |
232c0273 | 6 | * @(#)tty_tty.c 7.5 (Berkeley) %G% |
da7c5cc6 | 7 | */ |
63c57592 BJ |
8 | |
9 | /* | |
964bcfb1 | 10 | * Indirect driver for controlling tty. |
63c57592 | 11 | */ |
94368568 JB |
12 | #include "param.h" |
13 | #include "systm.h" | |
14 | #include "conf.h" | |
94368568 JB |
15 | #include "user.h" |
16 | #include "ioctl.h" | |
17 | #include "tty.h" | |
18 | #include "proc.h" | |
232c0273 MT |
19 | #include "vnode.h" |
20 | #include "file.h" | |
94368568 | 21 | #include "uio.h" |
63c57592 | 22 | |
232c0273 MT |
23 | #define cttyvp(p) ((p)->p_flag&SCTTY ? (p)->p_session->s_ttyvp : NULL) |
24 | ||
25 | static off_t dummyoff; | |
26 | ||
63c57592 BJ |
27 | /*ARGSUSED*/ |
28 | syopen(dev, flag) | |
830bbc16 BJ |
29 | dev_t dev; |
30 | int flag; | |
63c57592 | 31 | { |
232c0273 MT |
32 | struct vnode *ttyvp = cttyvp(u.u_procp); |
33 | int error; | |
63c57592 | 34 | |
232c0273 | 35 | if (ttyvp == NULL) |
830bbc16 | 36 | return (ENXIO); |
232c0273 MT |
37 | if (error = VOP_ACCESS(ttyvp, |
38 | (flag&FREAD ? VREAD : 0) | (flag&FWRITE ? VWRITE : 0), u.u_cred)) | |
39 | return (error); | |
40 | return (VOP_OPEN(ttyvp, flag, NOCRED)); | |
63c57592 BJ |
41 | } |
42 | ||
43 | /*ARGSUSED*/ | |
76e0e3c3 | 44 | syread(dev, uio, flag) |
be3a1208 BJ |
45 | dev_t dev; |
46 | struct uio *uio; | |
63c57592 | 47 | { |
232c0273 | 48 | struct vnode *ttyvp = cttyvp(u.u_procp); |
63c57592 | 49 | |
232c0273 | 50 | if (ttyvp == NULL) |
840510a3 | 51 | return (ENXIO); |
232c0273 | 52 | return (VOP_READ(ttyvp, uio, &dummyoff, flag, NOCRED)); |
63c57592 BJ |
53 | } |
54 | ||
55 | /*ARGSUSED*/ | |
76e0e3c3 | 56 | sywrite(dev, uio, flag) |
be3a1208 BJ |
57 | dev_t dev; |
58 | struct uio *uio; | |
63c57592 | 59 | { |
232c0273 | 60 | struct vnode *ttyvp = cttyvp(u.u_procp); |
63c57592 | 61 | |
232c0273 | 62 | if (ttyvp == NULL) |
840510a3 | 63 | return (ENXIO); |
232c0273 | 64 | return (VOP_WRITE(ttyvp, uio, &dummyoff, flag, NOCRED)); |
63c57592 BJ |
65 | } |
66 | ||
67 | /*ARGSUSED*/ | |
68 | syioctl(dev, cmd, addr, flag) | |
35c1dcdb BJ |
69 | dev_t dev; |
70 | int cmd; | |
71 | caddr_t addr; | |
72 | int flag; | |
63c57592 | 73 | { |
232c0273 | 74 | struct vnode *ttyvp = cttyvp(u.u_procp); |
63c57592 | 75 | |
232c0273 MT |
76 | if (ttyvp == NULL) |
77 | return (ENXIO); | |
9060c89c | 78 | if (cmd == TIOCNOTTY) { |
232c0273 MT |
79 | if (!SESS_LEADER(u.u_procp)) { |
80 | u.u_procp->p_flag &= ~SCTTY; | |
81 | return (0); | |
82 | } else | |
83 | return (EINVAL); | |
4460d508 | 84 | } |
232c0273 | 85 | return (VOP_IOCTL(ttyvp, cmd, addr, flag, NOCRED)); |
63c57592 | 86 | } |
231ed58b | 87 | |
a8d3bf7f | 88 | /*ARGSUSED*/ |
231ed58b | 89 | syselect(dev, flag) |
a8d3bf7f BJ |
90 | dev_t dev; |
91 | int flag; | |
231ed58b | 92 | { |
232c0273 | 93 | struct vnode *ttyvp = cttyvp(u.u_procp); |
231ed58b | 94 | |
232c0273 MT |
95 | if (ttyvp == NULL) |
96 | return (ENXIO); | |
97 | return (VOP_SELECT(ttyvp, flag, NOCRED)); | |
231ed58b | 98 | } |