uipc_usrreq.c (3175) | uipc_usrreq.c (3308) |
---|---|
1/* 2 * Copyright (c) 1982, 1986, 1989, 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 * @(#)uipc_usrreq.c 8.3 (Berkeley) 1/4/94 | 1/* 2 * Copyright (c) 1982, 1986, 1989, 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 * @(#)uipc_usrreq.c 8.3 (Berkeley) 1/4/94 |
34 * $Id: uipc_usrreq.c,v 1.3 1994/08/02 07:43:12 davidg Exp $ | 34 * $Id: uipc_usrreq.c,v 1.4 1994/09/28 19:55:10 phk Exp $ |
35 */ 36 37#include <sys/param.h> 38#include <sys/systm.h> 39#include <sys/proc.h> 40#include <sys/filedesc.h> 41#include <sys/domain.h> 42#include <sys/protosw.h> | 35 */ 36 37#include <sys/param.h> 38#include <sys/systm.h> 39#include <sys/proc.h> 40#include <sys/filedesc.h> 41#include <sys/domain.h> 42#include <sys/protosw.h> |
43#include <sys/stat.h> |
|
43#include <sys/socket.h> 44#include <sys/socketvar.h> 45#include <sys/unpcb.h> 46#include <sys/un.h> 47#include <sys/namei.h> 48#include <sys/vnode.h> 49#include <sys/file.h> 50#include <sys/stat.h> 51#include <sys/mbuf.h> 52 | 44#include <sys/socket.h> 45#include <sys/socketvar.h> 46#include <sys/unpcb.h> 47#include <sys/un.h> 48#include <sys/namei.h> 49#include <sys/vnode.h> 50#include <sys/file.h> 51#include <sys/stat.h> 52#include <sys/mbuf.h> 53 |
53void unp_detach __P((struct unpcb *)); 54void unp_disconnect __P((struct unpcb *)); 55void unp_shutdown __P((struct unpcb *)); 56void unp_drop __P((struct unpcb *, int)); 57void unp_gc __P((void)); 58void unp_scan __P((struct mbuf *, void (*)(struct file *))); 59void unp_mark __P((struct file *)); 60void unp_discard __P((struct file *)); 61 | |
62/* 63 * Unix communications domain. 64 * 65 * TODO: 66 * SEQPACKET, RDM 67 * rethink name space problems 68 * need a proper out-of-band 69 */ --- 336 unchanged lines hidden (view full) --- 406 if (unp->unp_vnode != NULL) 407 return (EINVAL); 408 if (nam->m_len == MLEN) { 409 if (*(mtod(nam, caddr_t) + nam->m_len - 1) != 0) 410 return (EINVAL); 411 } else 412 *(mtod(nam, caddr_t) + nam->m_len) = 0; 413/* SHOULD BE ABLE TO ADOPT EXISTING AND wakeup() ALA FIFO's */ | 54/* 55 * Unix communications domain. 56 * 57 * TODO: 58 * SEQPACKET, RDM 59 * rethink name space problems 60 * need a proper out-of-band 61 */ --- 336 unchanged lines hidden (view full) --- 398 if (unp->unp_vnode != NULL) 399 return (EINVAL); 400 if (nam->m_len == MLEN) { 401 if (*(mtod(nam, caddr_t) + nam->m_len - 1) != 0) 402 return (EINVAL); 403 } else 404 *(mtod(nam, caddr_t) + nam->m_len) = 0; 405/* SHOULD BE ABLE TO ADOPT EXISTING AND wakeup() ALA FIFO's */ |
414 if (error = namei(&nd)) | 406 error = namei(&nd); 407 if (error) |
415 return (error); 416 vp = nd.ni_vp; 417 if (vp != NULL) { 418 VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd); 419 if (nd.ni_dvp == vp) 420 vrele(nd.ni_dvp); 421 else 422 vput(nd.ni_dvp); 423 vrele(vp); 424 return (EADDRINUSE); 425 } 426 VATTR_NULL(&vattr); 427 vattr.va_type = VSOCK; 428 vattr.va_mode = ACCESSPERMS; 429 LEASE_CHECK(nd.ni_dvp, p, p->p_ucred, LEASE_WRITE); | 408 return (error); 409 vp = nd.ni_vp; 410 if (vp != NULL) { 411 VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd); 412 if (nd.ni_dvp == vp) 413 vrele(nd.ni_dvp); 414 else 415 vput(nd.ni_dvp); 416 vrele(vp); 417 return (EADDRINUSE); 418 } 419 VATTR_NULL(&vattr); 420 vattr.va_type = VSOCK; 421 vattr.va_mode = ACCESSPERMS; 422 LEASE_CHECK(nd.ni_dvp, p, p->p_ucred, LEASE_WRITE); |
430 if (error = VOP_CREATE(nd.ni_dvp, &nd.ni_vp, &nd.ni_cnd, &vattr)) | 423 error = VOP_CREATE(nd.ni_dvp, &nd.ni_vp, &nd.ni_cnd, &vattr); 424 if (error) |
431 return (error); 432 vp = nd.ni_vp; 433 vp->v_socket = unp->unp_socket; 434 unp->unp_vnode = vp; 435 unp->unp_addr = m_copy(nam, 0, (int)M_COPYALL); 436 VOP_UNLOCK(vp); 437 return (0); 438} --- 12 unchanged lines hidden (view full) --- 451 struct nameidata nd; 452 453 NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_SYSSPACE, soun->sun_path, p); 454 if (nam->m_data + nam->m_len == &nam->m_dat[MLEN]) { /* XXX */ 455 if (*(mtod(nam, caddr_t) + nam->m_len - 1) != 0) 456 return (EMSGSIZE); 457 } else 458 *(mtod(nam, caddr_t) + nam->m_len) = 0; | 425 return (error); 426 vp = nd.ni_vp; 427 vp->v_socket = unp->unp_socket; 428 unp->unp_vnode = vp; 429 unp->unp_addr = m_copy(nam, 0, (int)M_COPYALL); 430 VOP_UNLOCK(vp); 431 return (0); 432} --- 12 unchanged lines hidden (view full) --- 445 struct nameidata nd; 446 447 NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_SYSSPACE, soun->sun_path, p); 448 if (nam->m_data + nam->m_len == &nam->m_dat[MLEN]) { /* XXX */ 449 if (*(mtod(nam, caddr_t) + nam->m_len - 1) != 0) 450 return (EMSGSIZE); 451 } else 452 *(mtod(nam, caddr_t) + nam->m_len) = 0; |
459 if (error = namei(&nd)) | 453 error = namei(&nd); 454 if (error) |
460 return (error); 461 vp = nd.ni_vp; 462 if (vp->v_type != VSOCK) { 463 error = ENOTSOCK; 464 goto bad; 465 } | 455 return (error); 456 vp = nd.ni_vp; 457 if (vp->v_type != VSOCK) { 458 error = ENOTSOCK; 459 goto bad; 460 } |
466 if (error = VOP_ACCESS(vp, VWRITE, p->p_ucred, p)) | 461 error = VOP_ACCESS(vp, VWRITE, p->p_ucred, p); 462 if (error) |
467 goto bad; 468 so2 = vp->v_socket; 469 if (so2 == 0) { 470 error = ECONNREFUSED; 471 goto bad; 472 } 473 if (so->so_type != so2->so_type) { 474 error = EPROTOTYPE; --- 374 unchanged lines hidden --- | 463 goto bad; 464 so2 = vp->v_socket; 465 if (so2 == 0) { 466 error = ECONNREFUSED; 467 goto bad; 468 } 469 if (so->so_type != so2->so_type) { 470 error = EPROTOTYPE; --- 374 unchanged lines hidden --- |