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