Deleted Added
full compact
kern_sendfile.c (43301) kern_sendfile.c (49413)
1/*
2 * Copyright (c) 1982, 1986, 1989, 1990, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * sendfile(2) and related extensions:
6 * Copyright (c) 1998, David Greenman. All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without

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

29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.
35 *
36 * @(#)uipc_syscalls.c 8.4 (Berkeley) 2/21/94
1/*
2 * Copyright (c) 1982, 1986, 1989, 1990, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * sendfile(2) and related extensions:
6 * Copyright (c) 1998, David Greenman. All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without

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

29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.
35 *
36 * @(#)uipc_syscalls.c 8.4 (Berkeley) 2/21/94
37 * $Id: uipc_syscalls.c,v 1.54 1999/01/25 16:53:53 fenner Exp $
37 * $Id: uipc_syscalls.c,v 1.55 1999/01/27 21:49:57 dillon Exp $
38 */
39
40#include "opt_compat.h"
41#include "opt_ktrace.h"
42
43#include <sys/param.h>
44#include <sys/systm.h>
45#include <sys/kernel.h>

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

113 struct filedesc *fdp = p->p_fd;
114 struct socket *so;
115 struct file *fp;
116 int fd, error;
117
118 error = falloc(p, &fp, &fd);
119 if (error)
120 return (error);
38 */
39
40#include "opt_compat.h"
41#include "opt_ktrace.h"
42
43#include <sys/param.h>
44#include <sys/systm.h>
45#include <sys/kernel.h>

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

113 struct filedesc *fdp = p->p_fd;
114 struct socket *so;
115 struct file *fp;
116 int fd, error;
117
118 error = falloc(p, &fp, &fd);
119 if (error)
120 return (error);
121 fp->f_flag = FREAD|FWRITE;
122 fp->f_type = DTYPE_SOCKET;
123 fp->f_ops = &socketops;
124 error = socreate(uap->domain, &so, uap->type, uap->protocol, p);
125 if (error) {
126 fdp->fd_ofiles[fd] = 0;
127 ffree(fp);
128 } else {
129 fp->f_data = (caddr_t)so;
121 error = socreate(uap->domain, &so, uap->type, uap->protocol, p);
122 if (error) {
123 fdp->fd_ofiles[fd] = 0;
124 ffree(fp);
125 } else {
126 fp->f_data = (caddr_t)so;
127 fp->f_flag = FREAD|FWRITE;
128 fp->f_ops = &socketops;
129 fp->f_type = DTYPE_SOCKET;
130 p->p_retval[0] = fd;
131 }
132 return (error);
133}
134
135/* ARGSUSED */
136int
137bind(p, uap)

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

258 } else
259 p->p_retval[0] = fd;
260
261 so->so_state &= ~SS_COMP;
262 so->so_head = NULL;
263 if (head->so_sigio != NULL)
264 fsetown(fgetown(head->so_sigio), &so->so_sigio);
265
130 p->p_retval[0] = fd;
131 }
132 return (error);
133}
134
135/* ARGSUSED */
136int
137bind(p, uap)

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

258 } else
259 p->p_retval[0] = fd;
260
261 so->so_state &= ~SS_COMP;
262 so->so_head = NULL;
263 if (head->so_sigio != NULL)
264 fsetown(fgetown(head->so_sigio), &so->so_sigio);
265
266 fp->f_type = DTYPE_SOCKET;
266 fp->f_data = (caddr_t)so;
267 fp->f_flag = fflag;
268 fp->f_ops = &socketops;
267 fp->f_flag = fflag;
268 fp->f_ops = &socketops;
269 fp->f_data = (caddr_t)so;
269 fp->f_type = DTYPE_SOCKET;
270 sa = 0;
271 (void) soaccept(so, &sa);
272 if (sa == 0) {
273 namelen = 0;
274 if (uap->name)
275 goto gotnoname;
276 return 0;
277 }

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

387 return (error);
388 error = socreate(uap->domain, &so2, uap->type, uap->protocol, p);
389 if (error)
390 goto free1;
391 error = falloc(p, &fp1, &fd);
392 if (error)
393 goto free2;
394 sv[0] = fd;
270 sa = 0;
271 (void) soaccept(so, &sa);
272 if (sa == 0) {
273 namelen = 0;
274 if (uap->name)
275 goto gotnoname;
276 return 0;
277 }

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

387 return (error);
388 error = socreate(uap->domain, &so2, uap->type, uap->protocol, p);
389 if (error)
390 goto free1;
391 error = falloc(p, &fp1, &fd);
392 if (error)
393 goto free2;
394 sv[0] = fd;
395 fp1->f_flag = FREAD|FWRITE;
396 fp1->f_type = DTYPE_SOCKET;
397 fp1->f_ops = &socketops;
398 fp1->f_data = (caddr_t)so1;
399 error = falloc(p, &fp2, &fd);
400 if (error)
401 goto free3;
395 fp1->f_data = (caddr_t)so1;
396 error = falloc(p, &fp2, &fd);
397 if (error)
398 goto free3;
402 fp2->f_flag = FREAD|FWRITE;
403 fp2->f_type = DTYPE_SOCKET;
404 fp2->f_ops = &socketops;
405 fp2->f_data = (caddr_t)so2;
406 sv[1] = fd;
407 error = soconnect2(so1, so2);
408 if (error)
409 goto free4;
410 if (uap->type == SOCK_DGRAM) {
411 /*
412 * Datagram socket connection is asymmetric.
413 */
414 error = soconnect2(so2, so1);
415 if (error)
416 goto free4;
417 }
399 fp2->f_data = (caddr_t)so2;
400 sv[1] = fd;
401 error = soconnect2(so1, so2);
402 if (error)
403 goto free4;
404 if (uap->type == SOCK_DGRAM) {
405 /*
406 * Datagram socket connection is asymmetric.
407 */
408 error = soconnect2(so2, so1);
409 if (error)
410 goto free4;
411 }
412 fp1->f_flag = fp2->f_flag = FREAD|FWRITE;
413 fp1->f_ops = fp2->f_ops = &socketops;
414 fp1->f_type = fp2->f_type = DTYPE_SOCKET;
418 error = copyout((caddr_t)sv, (caddr_t)uap->rsv, 2 * sizeof (int));
419 return (error);
420free4:
415 error = copyout((caddr_t)sv, (caddr_t)uap->rsv, 2 * sizeof (int));
416 return (error);
417free4:
421 ffree(fp2);
422 fdp->fd_ofiles[sv[1]] = 0;
418 fdp->fd_ofiles[sv[1]] = 0;
419 ffree(fp2);
423free3:
420free3:
424 ffree(fp1);
425 fdp->fd_ofiles[sv[0]] = 0;
421 fdp->fd_ofiles[sv[0]] = 0;
422 ffree(fp1);
426free2:
427 (void)soclose(so2);
428free1:
429 (void)soclose(so1);
430 return (error);
431}
432
433static int

--- 1272 unchanged lines hidden ---
423free2:
424 (void)soclose(so2);
425free1:
426 (void)soclose(so1);
427 return (error);
428}
429
430static int

--- 1272 unchanged lines hidden ---