Deleted Added
full compact
svr4_stream.c (130640) svr4_stream.c (131897)
1/*
2 * Copyright (c) 1998 Mark Newton. All rights reserved.
3 * Copyright (c) 1994, 1996 Christos Zoulas. 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

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

31/*
32 * Pretend that we have streams...
33 * Yes, this is gross.
34 *
35 * ToDo: The state machine for getmsg needs re-thinking
36 */
37
38#include <sys/cdefs.h>
1/*
2 * Copyright (c) 1998 Mark Newton. All rights reserved.
3 * Copyright (c) 1994, 1996 Christos Zoulas. 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

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

31/*
32 * Pretend that we have streams...
33 * Yes, this is gross.
34 *
35 * ToDo: The state machine for getmsg needs re-thinking
36 */
37
38#include <sys/cdefs.h>
39__FBSDID("$FreeBSD: head/sys/compat/svr4/svr4_stream.c 130640 2004-06-17 17:16:53Z phk $");
39__FBSDID("$FreeBSD: head/sys/compat/svr4/svr4_stream.c 131897 2004-07-10 15:42:16Z phk $");
40
41#define COMPAT_43 1
42
43#include "opt_mac.h"
44
45#include <sys/param.h>
46#include <sys/systm.h>
47#include <sys/fcntl.h>

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

158 struct uio auio;
159 register struct iovec *iov;
160 register int i;
161 struct mbuf *control;
162 struct sockaddr *to;
163 int len, error;
164 struct socket *so;
165#ifdef KTRACE
40
41#define COMPAT_43 1
42
43#include "opt_mac.h"
44
45#include <sys/param.h>
46#include <sys/systm.h>
47#include <sys/fcntl.h>

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

158 struct uio auio;
159 register struct iovec *iov;
160 register int i;
161 struct mbuf *control;
162 struct sockaddr *to;
163 int len, error;
164 struct socket *so;
165#ifdef KTRACE
166 struct iovec *ktriov = NULL;
167 struct uio ktruio;
166 struct uio *ktruio = NULL;
168#endif
169
170 if ((error = fgetsock(td, s, &so, NULL)) != 0)
171 return (error);
172
173#ifdef MAC
174 SOCK_LOCK(so);
175 error = mac_check_socket_send(td->td_ucred, so);

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

207 error = sockargs(&control, mp->msg_control,
208 mp->msg_controllen, MT_CONTROL);
209 if (error)
210 goto bad;
211 } else {
212 control = 0;
213 }
214#ifdef KTRACE
167#endif
168
169 if ((error = fgetsock(td, s, &so, NULL)) != 0)
170 return (error);
171
172#ifdef MAC
173 SOCK_LOCK(so);
174 error = mac_check_socket_send(td->td_ucred, so);

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

206 error = sockargs(&control, mp->msg_control,
207 mp->msg_controllen, MT_CONTROL);
208 if (error)
209 goto bad;
210 } else {
211 control = 0;
212 }
213#ifdef KTRACE
215 if (KTRPOINT(td, KTR_GENIO)) {
216 int iovlen = auio.uio_iovcnt * sizeof (struct iovec);
217
218 MALLOC(ktriov, struct iovec *, iovlen, M_TEMP, M_WAITOK);
219 bcopy((caddr_t)auio.uio_iov, (caddr_t)ktriov, iovlen);
220 ktruio = auio;
221 }
214 if (KTRPOINT(td, KTR_GENIO))
215 ktruio = cloneuio(&auio);
222#endif
223 len = auio.uio_resid;
224 error = so->so_proto->pr_usrreqs->pru_sosend(so, to, &auio, 0, control,
225 flags, td);
226 if (error) {
227 if (auio.uio_resid != len && (error == ERESTART ||
228 error == EINTR || error == EWOULDBLOCK))
229 error = 0;
230 if (error == EPIPE) {
231 PROC_LOCK(td->td_proc);
232 psignal(td->td_proc, SIGPIPE);
233 PROC_UNLOCK(td->td_proc);
234 }
235 }
236 if (error == 0)
237 td->td_retval[0] = len - auio.uio_resid;
238#ifdef KTRACE
216#endif
217 len = auio.uio_resid;
218 error = so->so_proto->pr_usrreqs->pru_sosend(so, to, &auio, 0, control,
219 flags, td);
220 if (error) {
221 if (auio.uio_resid != len && (error == ERESTART ||
222 error == EINTR || error == EWOULDBLOCK))
223 error = 0;
224 if (error == EPIPE) {
225 PROC_LOCK(td->td_proc);
226 psignal(td->td_proc, SIGPIPE);
227 PROC_UNLOCK(td->td_proc);
228 }
229 }
230 if (error == 0)
231 td->td_retval[0] = len - auio.uio_resid;
232#ifdef KTRACE
239 if (ktriov != NULL) {
240 if (error == 0) {
241 ktruio.uio_iov = ktriov;
242 ktruio.uio_resid = td->td_retval[0];
243 ktrgenio(s, UIO_WRITE, &ktruio, error);
244 }
245 FREE(ktriov, M_TEMP);
233 if (ktruio != NULL) {
234 ktruio->uio_resid = td->td_retval[0];
235 ktrgenio(s, UIO_WRITE, ktruio, error);
246 }
247#endif
248bad:
249 if (to)
250 FREE(to, M_SONAME);
251done1:
252 fputsock(so);
253 return (error);

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

264 register struct iovec *iov;
265 register int i;
266 int len, error;
267 struct mbuf *m, *control = 0;
268 caddr_t ctlbuf;
269 struct socket *so;
270 struct sockaddr *fromsa = 0;
271#ifdef KTRACE
236 }
237#endif
238bad:
239 if (to)
240 FREE(to, M_SONAME);
241done1:
242 fputsock(so);
243 return (error);

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

254 register struct iovec *iov;
255 register int i;
256 int len, error;
257 struct mbuf *m, *control = 0;
258 caddr_t ctlbuf;
259 struct socket *so;
260 struct sockaddr *fromsa = 0;
261#ifdef KTRACE
272 struct iovec *ktriov = NULL;
273 struct uio ktruio;
262 struct uio *ktruio = NULL;
274#endif
275
276 if ((error = fgetsock(td, s, &so, NULL)) != 0)
277 return (error);
278
279#ifdef MAC
280 SOCK_LOCK(so);
281 error = mac_check_socket_receive(td->td_ucred, so);

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

294 iov = mp->msg_iov;
295 for (i = 0; i < mp->msg_iovlen; i++, iov++) {
296 if ((auio.uio_resid += iov->iov_len) < 0) {
297 error = EINVAL;
298 goto done1;
299 }
300 }
301#ifdef KTRACE
263#endif
264
265 if ((error = fgetsock(td, s, &so, NULL)) != 0)
266 return (error);
267
268#ifdef MAC
269 SOCK_LOCK(so);
270 error = mac_check_socket_receive(td->td_ucred, so);

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

283 iov = mp->msg_iov;
284 for (i = 0; i < mp->msg_iovlen; i++, iov++) {
285 if ((auio.uio_resid += iov->iov_len) < 0) {
286 error = EINVAL;
287 goto done1;
288 }
289 }
290#ifdef KTRACE
302 if (KTRPOINT(td, KTR_GENIO)) {
303 int iovlen = auio.uio_iovcnt * sizeof (struct iovec);
304
305 MALLOC(ktriov, struct iovec *, iovlen, M_TEMP, M_WAITOK);
306 bcopy((caddr_t)auio.uio_iov, (caddr_t)ktriov, iovlen);
307 ktruio = auio;
308 }
291 if (KTRPOINT(td, KTR_GENIO))
292 ktruio = cloneuio(&auio);
309#endif
310 len = auio.uio_resid;
311 error = so->so_proto->pr_usrreqs->pru_soreceive(so, &fromsa, &auio,
312 (struct mbuf **)0, mp->msg_control ? &control : (struct mbuf **)0,
313 &mp->msg_flags);
314 if (error) {
315 if (auio.uio_resid != len && (error == ERESTART ||
316 error == EINTR || error == EWOULDBLOCK))
317 error = 0;
318 }
319#ifdef KTRACE
293#endif
294 len = auio.uio_resid;
295 error = so->so_proto->pr_usrreqs->pru_soreceive(so, &fromsa, &auio,
296 (struct mbuf **)0, mp->msg_control ? &control : (struct mbuf **)0,
297 &mp->msg_flags);
298 if (error) {
299 if (auio.uio_resid != len && (error == ERESTART ||
300 error == EINTR || error == EWOULDBLOCK))
301 error = 0;
302 }
303#ifdef KTRACE
320 if (ktriov != NULL) {
321 if (error == 0) {
322 ktruio.uio_iov = ktriov;
323 ktruio.uio_resid = len - auio.uio_resid;
324 ktrgenio(s, UIO_READ, &ktruio, error);
325 }
326 FREE(ktriov, M_TEMP);
304 if (ktruio != NULL) {
305 ktruio->uio_resid = len - auio.uio_resid;
306 ktrgenio(s, UIO_READ, ktruio, error);
327 }
328#endif
329 if (error)
330 goto out;
331 td->td_retval[0] = len - auio.uio_resid;
332 if (mp->msg_name) {
333 len = mp->msg_namelen;
334 if (len <= 0 || fromsa == 0)

--- 2014 unchanged lines hidden ---
307 }
308#endif
309 if (error)
310 goto out;
311 td->td_retval[0] = len - auio.uio_resid;
312 if (mp->msg_name) {
313 len = mp->msg_namelen;
314 if (len <= 0 || fromsa == 0)

--- 2014 unchanged lines hidden ---