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.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); |
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 |
266 fp->f_data = (caddr_t)so; |
267 fp->f_flag = fflag; 268 fp->f_ops = &socketops; |
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; |
395 fp1->f_data = (caddr_t)so1; 396 error = falloc(p, &fp2, &fd); 397 if (error) 398 goto free3; |
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; |
415 error = copyout((caddr_t)sv, (caddr_t)uap->rsv, 2 * sizeof (int)); 416 return (error); 417free4: |
418 fdp->fd_ofiles[sv[1]] = 0; |
419 ffree(fp2); |
420free3: |
421 fdp->fd_ofiles[sv[0]] = 0; |
422 ffree(fp1); |
423free2: 424 (void)soclose(so2); 425free1: 426 (void)soclose(so1); 427 return (error); 428} 429 430static int --- 1272 unchanged lines hidden --- |