The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/compat/osf1/osf1_generic.c

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /* $NetBSD: osf1_generic.c,v 1.13 2007/12/20 23:03:02 dsl Exp $ */
    2 
    3 /*
    4  * Copyright (c) 1999 Christopher G. Demetriou.  All rights reserved.
    5  *
    6  * Redistribution and use in source and binary forms, with or without
    7  * modification, are permitted provided that the following conditions
    8  * are met:
    9  * 1. Redistributions of source code must retain the above copyright
   10  *    notice, this list of conditions and the following disclaimer.
   11  * 2. Redistributions in binary form must reproduce the above copyright
   12  *    notice, this list of conditions and the following disclaimer in the
   13  *    documentation and/or other materials provided with the distribution.
   14  * 3. All advertising materials mentioning features or use of this software
   15  *    must display the following acknowledgement:
   16  *      This product includes software developed by Christopher G. Demetriou
   17  *      for the NetBSD Project.
   18  * 4. The name of the author may not be used to endorse or promote products
   19  *    derived from this software without specific prior written permission
   20  *
   21  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
   22  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   23  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
   24  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
   25  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
   26  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
   27  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
   28  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
   29  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
   30  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
   31  */
   32 
   33 /*
   34  * Copyright (c) 1994, 1995 Carnegie-Mellon University.
   35  * All rights reserved.
   36  *
   37  * Author: Chris G. Demetriou
   38  *
   39  * Permission to use, copy, modify and distribute this software and
   40  * its documentation is hereby granted, provided that both the copyright
   41  * notice and this permission notice appear in all copies of the
   42  * software, derivative works or modified versions, and any portions
   43  * thereof, and that both notices appear in supporting documentation.
   44  *
   45  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
   46  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
   47  * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
   48  *
   49  * Carnegie Mellon requests users of this software to return to
   50  *
   51  *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
   52  *  School of Computer Science
   53  *  Carnegie Mellon University
   54  *  Pittsburgh PA 15213-3890
   55  *
   56  * any improvements or extensions that they make and grant Carnegie the
   57  * rights to redistribute these changes.
   58  */
   59 
   60 #include <sys/cdefs.h>
   61 __KERNEL_RCSID(0, "$NetBSD: osf1_generic.c,v 1.13 2007/12/20 23:03:02 dsl Exp $");
   62 
   63 #include <sys/param.h>
   64 #include <sys/systm.h>
   65 #include <sys/namei.h>
   66 #include <sys/proc.h>
   67 #include <sys/file.h>
   68 #include <sys/stat.h>
   69 #include <sys/malloc.h>
   70 #include <sys/mman.h>
   71 #include <sys/mount.h>
   72 #include <sys/select.h>
   73 #include <sys/syscallargs.h>
   74 #include <sys/exec.h>
   75 
   76 #include <compat/osf1/osf1.h>
   77 #include <compat/osf1/osf1_syscallargs.h>
   78 #include <compat/osf1/osf1_cvt.h>
   79 
   80 /*
   81  * The structures end up being the same... but we can't be sure that
   82  * the other word of our iov_len is zero!
   83  */
   84 
   85 #if __GNUC_PREREQ__(3, 0)
   86 __attribute ((noinline))
   87 #endif  
   88 static int
   89 osf1_get_iov(struct osf1_iovec *uiov, unsigned int iovcnt, struct iovec **iovp)
   90 {
   91         struct iovec *iov = *iovp;
   92         struct osf1_iovec osf1_iov[UIO_SMALLIOV];
   93         int i, j, n, error;
   94 
   95         if (iovcnt > IOV_MAX)
   96                 return EINVAL;
   97 
   98         if (iovcnt > UIO_SMALLIOV) {
   99                 iov = malloc(iovcnt * sizeof *iov, M_IOV, M_WAITOK);
  100                 *iovp = iov;
  101                 /* Caller must free - even if we return an error */
  102         }
  103 
  104         for (i = 0; i < iovcnt; uiov += UIO_SMALLIOV, i += UIO_SMALLIOV) {
  105                 n = iovcnt - i;
  106                 if (n > UIO_SMALLIOV)
  107                         n = UIO_SMALLIOV;
  108                 error = copyin(uiov, osf1_iov, n * sizeof osf1_iov[0]);
  109                 if (error != 0)
  110                         return error;
  111 
  112                 for (j = 0; j < n; iov++, j++) {
  113                         iov->iov_base = osf1_iov[j].iov_base;
  114                         iov->iov_len = osf1_iov[j].iov_len;
  115                 }
  116         }
  117 
  118         return 0;
  119 }
  120 
  121 int
  122 osf1_sys_readv(struct lwp *l, const struct osf1_sys_readv_args *uap, register_t *retval)
  123 {
  124         struct iovec aiov[UIO_SMALLIOV], *niov = aiov;
  125         int error;
  126 
  127         error = osf1_get_iov(SCARG(uap, iovp), SCARG(uap, iovcnt), &niov);
  128 
  129         if (error == 0) {
  130                 error = do_filereadv(SCARG(uap, fd), niov,
  131                     SCARG(uap, iovcnt), NULL,
  132                     FOF_UPDATE_OFFSET | FOF_IOV_SYSSPACE, retval);
  133         }
  134 
  135         if (niov != aiov)
  136                 free(niov, M_IOV);
  137 
  138         return error;
  139 }
  140 
  141 int
  142 osf1_sys_writev(struct lwp *l, const struct osf1_sys_writev_args *uap, register_t *retval)
  143 {
  144         struct iovec aiov[UIO_SMALLIOV], *niov = aiov;
  145         int error;
  146 
  147         error = osf1_get_iov(SCARG(uap, iovp), SCARG(uap, iovcnt), &niov);
  148 
  149         if (error == 0) {
  150                 error = do_filewritev(SCARG(uap, fd), niov,
  151                     SCARG(uap, iovcnt), NULL,
  152                     FOF_UPDATE_OFFSET | FOF_IOV_SYSSPACE, retval);
  153         }
  154 
  155         if (niov != aiov)
  156                 free(niov, M_IOV);
  157 
  158         return error;
  159 }
  160 
  161 int
  162 osf1_sys_select(struct lwp *l, const struct osf1_sys_select_args *uap, register_t *retval)
  163 {
  164         struct osf1_timeval otv;
  165         struct timeval tv, *tvp;
  166         int error;
  167 
  168         if (SCARG(uap, tv) == NULL)
  169                 tvp = NULL;
  170         else {
  171                 /* get the OSF/1 timeval argument */
  172                 error = copyin(SCARG(uap, tv), &otv, sizeof otv);
  173                 if (error != 0)
  174                         return error;
  175 
  176                 /* copy to the NetBSD timeval */
  177                 tv.tv_sec = otv.tv_sec;
  178                 tv.tv_usec = otv.tv_usec;
  179                 tvp = &tv;
  180         }
  181 
  182         return selcommon(l, retval, SCARG(uap, nd), SCARG(uap, in),
  183             SCARG(uap, ou), SCARG(uap, ex), tvp, NULL);
  184 }

Cache object: 677394d34780e00a98caba69bc8d0fbb


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.