BSD 4_3_Net_2 release
[unix-history] / usr / src / sys / kern / uipc_syscalls.c
index 39eb74f..3e92785 100644 (file)
@@ -1,12 +1,39 @@
 /*
 /*
+ * Copyright (c) 1982, 1986, 1989, 1990 Regents of the University of California.
+ * All rights reserved.
  *
  *
- * %sccs.include.redist.c%
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *     This product includes software developed by the University of
+ *     California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
  *
  *
- *     @(#)uipc_syscalls.c     7.22 (Berkeley) %G%
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *     @(#)uipc_syscalls.c     7.24 (Berkeley) 6/3/91
  */
 
 #include "param.h"
  */
 
 #include "param.h"
-#include "user.h"
 #include "filedesc.h"
 #include "proc.h"
 #include "file.h"
 #include "filedesc.h"
 #include "proc.h"
 #include "file.h"
@@ -46,9 +73,8 @@ socket(p, uap, retval)
        fp->f_type = DTYPE_SOCKET;
        fp->f_ops = &socketops;
        if (error = socreate(uap->domain, &so, uap->type, uap->protocol)) {
        fp->f_type = DTYPE_SOCKET;
        fp->f_ops = &socketops;
        if (error = socreate(uap->domain, &so, uap->type, uap->protocol)) {
-               OFILE(fdp, fd) = 0;
-               crfree(fp->f_cred);
-               fp->f_count = 0;
+               fdp->fd_ofiles[fd] = 0;
+               ffree(fp);
        } else {
                fp->f_data = (caddr_t)so;
                *retval = fd;
        } else {
                fp->f_data = (caddr_t)so;
                *retval = fd;
@@ -308,13 +334,11 @@ socketpair(p, uap, retval)
        retval[1] = sv[1];              /* XXX ??? */
        return (error);
 free4:
        retval[1] = sv[1];              /* XXX ??? */
        return (error);
 free4:
-       crfree(fp2->f_cred);
-       fp2->f_count = 0;
-       OFILE(fdp, sv[1]) = 0;
+       ffree(fp2);
+       fdp->fd_ofiles[sv[1]] = 0;
 free3:
 free3:
-       crfree(fp1->f_cred);
-       fp1->f_count = 0;
-       OFILE(fdp, sv[0]) = 0;
+       ffree(fp1);
+       fdp->fd_ofiles[sv[0]] = 0;
 free2:
        (void)soclose(so2);
 free1:
 free2:
        (void)soclose(so2);
 free1:
@@ -473,6 +497,7 @@ sendit(p, s, mp, flags, retsize)
        auio.uio_iovcnt = mp->msg_iovlen;
        auio.uio_segflg = UIO_USERSPACE;
        auio.uio_rw = UIO_WRITE;
        auio.uio_iovcnt = mp->msg_iovlen;
        auio.uio_segflg = UIO_USERSPACE;
        auio.uio_rw = UIO_WRITE;
+       auio.uio_procp = p;
        auio.uio_offset = 0;                    /* XXX */
        auio.uio_resid = 0;
        iov = mp->msg_iov;
        auio.uio_offset = 0;                    /* XXX */
        auio.uio_resid = 0;
        iov = mp->msg_iov;
@@ -739,6 +764,7 @@ recvit(p, s, mp, namelenp, retsize)
        auio.uio_iovcnt = mp->msg_iovlen;
        auio.uio_segflg = UIO_USERSPACE;
        auio.uio_rw = UIO_READ;
        auio.uio_iovcnt = mp->msg_iovlen;
        auio.uio_segflg = UIO_USERSPACE;
        auio.uio_rw = UIO_READ;
+       auio.uio_procp = p;
        auio.uio_offset = 0;                    /* XXX */
        auio.uio_resid = 0;
        iov = mp->msg_iov;
        auio.uio_offset = 0;                    /* XXX */
        auio.uio_resid = 0;
        iov = mp->msg_iov;
@@ -967,11 +993,11 @@ pipe(p, uap, retval)
                goto free4;
        return (0);
 free4:
                goto free4;
        return (0);
 free4:
-       wf->f_count = 0;
-       OFILE(fdp, retval[1]) = 0;
+       ffree(wf);
+       fdp->fd_ofiles[retval[1]] = 0;
 free3:
 free3:
-       rf->f_count = 0;
-       OFILE(fdp, retval[0]) = 0;
+       ffree(rf);
+       fdp->fd_ofiles[retval[0]] = 0;
 free2:
        (void)soclose(wso);
 free1:
 free2:
        (void)soclose(wso);
 free1:
@@ -1189,7 +1215,7 @@ getsock(fdp, fdes, fpp)
        register struct file *fp;
 
        if ((unsigned)fdes >= fdp->fd_nfiles ||
        register struct file *fp;
 
        if ((unsigned)fdes >= fdp->fd_nfiles ||
-           (fp = OFILE(fdp, fdes)) == NULL)
+           (fp = fdp->fd_ofiles[fdes]) == NULL)
                return (EBADF);
        if (fp->f_type != DTYPE_SOCKET)
                return (ENOTSOCK);
                return (EBADF);
        if (fp->f_type != DTYPE_SOCKET)
                return (ENOTSOCK);