Deleted Added
full compact
tty_tty.c (102112) tty_tty.c (102129)
1/*-
2 * Copyright (c) 1982, 1986, 1991, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 17 unchanged lines hidden (view full) ---

26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 *
33 * @(#)tty_tty.c 8.2 (Berkeley) 9/23/93
1/*-
2 * Copyright (c) 1982, 1986, 1991, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 17 unchanged lines hidden (view full) ---

26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 *
33 * @(#)tty_tty.c 8.2 (Berkeley) 9/23/93
34 * $FreeBSD: head/sys/kern/tty_tty.c 102112 2002-08-19 16:43:25Z rwatson $
34 * $FreeBSD: head/sys/kern/tty_tty.c 102129 2002-08-19 19:04:53Z rwatson $
35 */
36
37/*
38 * Indirect driver for controlling tty.
39 */
40
41#include "opt_mac.h"
42

--- 56 unchanged lines hidden (view full) ---

99 vn_lock(ttyvp, LK_EXCLUSIVE | LK_RETRY, td);
100#ifdef MAC
101 error = mac_check_vnode_open(td->td_ucred, ttyvp, flag);
102 if (error) {
103 VOP_UNLOCK(ttyvp, 0, td);
104 return (error);
105 }
106#endif
35 */
36
37/*
38 * Indirect driver for controlling tty.
39 */
40
41#include "opt_mac.h"
42

--- 56 unchanged lines hidden (view full) ---

99 vn_lock(ttyvp, LK_EXCLUSIVE | LK_RETRY, td);
100#ifdef MAC
101 error = mac_check_vnode_open(td->td_ucred, ttyvp, flag);
102 if (error) {
103 VOP_UNLOCK(ttyvp, 0, td);
104 return (error);
105 }
106#endif
107 /* XXX: Shouldn't this cred be td->td_ucred not NOCRED? */
107 error = VOP_OPEN(ttyvp, flag, NOCRED, td);
108 VOP_UNLOCK(ttyvp, 0, td);
109 return (error);
110}
111
112/*ARGSUSED*/
113static int
114cttyread(dev, uio, flag)

--- 10 unchanged lines hidden (view full) ---

125 ttyvp = cttyvp(td);
126 SESS_UNLOCK(td->td_proc->p_session);
127 PROC_UNLOCK(td->td_proc);
128
129 if (ttyvp == NULL)
130 return (EIO);
131 vn_lock(ttyvp, LK_EXCLUSIVE | LK_RETRY, td);
132#ifdef MAC
108 error = VOP_OPEN(ttyvp, flag, NOCRED, td);
109 VOP_UNLOCK(ttyvp, 0, td);
110 return (error);
111}
112
113/*ARGSUSED*/
114static int
115cttyread(dev, uio, flag)

--- 10 unchanged lines hidden (view full) ---

126 ttyvp = cttyvp(td);
127 SESS_UNLOCK(td->td_proc->p_session);
128 PROC_UNLOCK(td->td_proc);
129
130 if (ttyvp == NULL)
131 return (EIO);
132 vn_lock(ttyvp, LK_EXCLUSIVE | LK_RETRY, td);
133#ifdef MAC
133 /* XXX: Shouldn't the cred below be td->td_ucred not NOCRED? */
134 error = mac_check_vnode_read(td->td_ucred, ttyvp);
134 error = mac_check_vnode_read(td->td_ucred, NOCRED, ttyvp);
135 if (error == 0)
136#endif
135 if (error == 0)
136#endif
137 /* XXX: Shouldn't this cred be td->td_ucred not NOCRED? */
137 error = VOP_READ(ttyvp, uio, flag, NOCRED);
138 VOP_UNLOCK(ttyvp, 0, td);
139 return (error);
140}
141
142/*ARGSUSED*/
143static int
144cttywrite(dev, uio, flag)

--- 15 unchanged lines hidden (view full) ---

160 if (ttyvp == NULL)
161 return (EIO);
162 mp = NULL;
163 if (ttyvp->v_type != VCHR &&
164 (error = vn_start_write(ttyvp, &mp, V_WAIT | PCATCH)) != 0)
165 return (error);
166 vn_lock(ttyvp, LK_EXCLUSIVE | LK_RETRY, td);
167#ifdef MAC
138 error = VOP_READ(ttyvp, uio, flag, NOCRED);
139 VOP_UNLOCK(ttyvp, 0, td);
140 return (error);
141}
142
143/*ARGSUSED*/
144static int
145cttywrite(dev, uio, flag)

--- 15 unchanged lines hidden (view full) ---

161 if (ttyvp == NULL)
162 return (EIO);
163 mp = NULL;
164 if (ttyvp->v_type != VCHR &&
165 (error = vn_start_write(ttyvp, &mp, V_WAIT | PCATCH)) != 0)
166 return (error);
167 vn_lock(ttyvp, LK_EXCLUSIVE | LK_RETRY, td);
168#ifdef MAC
168 /* XXX: shouldn't the cred below be td->td_ucred not NOCRED? */
169 error = mac_check_vnode_write(td->td_ucred, ttyvp);
169 error = mac_check_vnode_write(td->td_ucred, NOCRED, ttyvp);
170 if (error == 0)
171#endif
170 if (error == 0)
171#endif
172 /* XXX: shouldn't this cred be td->td_ucred not NOCRED? */
172 error = VOP_WRITE(ttyvp, uio, flag, NOCRED);
173 VOP_UNLOCK(ttyvp, 0, td);
174 vn_finished_write(mp);
175 return (error);
176}
177
178/*ARGSUSED*/
179static int

--- 51 unchanged lines hidden (view full) ---

231 SESS_UNLOCK(td->td_proc->p_session);
232 PROC_UNLOCK(td->td_proc);
233
234 if (ttyvp == NULL)
235 /* try operation to get EOF/failure */
236 return (seltrue(dev, events, td));
237#ifdef MAC
238 vn_lock(ttyvp, LK_EXCLUSIVE | LK_RETRY, td);
173 error = VOP_WRITE(ttyvp, uio, flag, NOCRED);
174 VOP_UNLOCK(ttyvp, 0, td);
175 vn_finished_write(mp);
176 return (error);
177}
178
179/*ARGSUSED*/
180static int

--- 51 unchanged lines hidden (view full) ---

232 SESS_UNLOCK(td->td_proc->p_session);
233 PROC_UNLOCK(td->td_proc);
234
235 if (ttyvp == NULL)
236 /* try operation to get EOF/failure */
237 return (seltrue(dev, events, td));
238#ifdef MAC
239 vn_lock(ttyvp, LK_EXCLUSIVE | LK_RETRY, td);
239 error = mac_check_vnode_poll(td->td_ucred, ttyvp);
240 error = mac_check_vnode_poll(td->td_ucred, NOCRED, ttyvp);
240 VOP_UNLOCK(ttyvp, 0, td);
241 if (error)
242 return (error);
243#endif
244 return (VOP_POLL(ttyvp, events, td->td_ucred, td));
245}
246
247static void ctty_clone(void *arg, char *name, int namelen, dev_t *dev);

--- 36 unchanged lines hidden ---
241 VOP_UNLOCK(ttyvp, 0, td);
242 if (error)
243 return (error);
244#endif
245 return (VOP_POLL(ttyvp, events, td->td_ucred, td));
246}
247
248static void ctty_clone(void *arg, char *name, int namelen, dev_t *dev);

--- 36 unchanged lines hidden ---