1 /* $NetBSD: freebsd_misc.c,v 1.13 2001/05/30 11:37:23 mrg Exp $ */ 2 3 /* 4 * Copyright (c) 1995 Frank van der Linden 5 * 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 for the NetBSD Project 18 * by Frank van der Linden 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 * FreeBSD compatibility module. Try to deal with various FreeBSD system calls. 36 */ 37 38 #if defined(_KERNEL_OPT) 39 #include "opt_ntp.h" 40 #include "opt_ktrace.h" 41 #endif 42 43 #include <sys/param.h> 44 #include <sys/systm.h> 45 #include <sys/proc.h> 46 #include <sys/mount.h> 47 #include <sys/signal.h> 48 #include <sys/signalvar.h> 49 #include <sys/malloc.h> 50 #ifdef KTRACE 51 #include <sys/ktrace.h> 52 #endif 53 54 #include <sys/syscallargs.h> 55 56 #include <compat/freebsd/freebsd_syscallargs.h> 57 #include <compat/common/compat_util.h> 58 #include <compat/freebsd/freebsd_rtprio.h> 59 #include <compat/freebsd/freebsd_timex.h> 60 #include <compat/freebsd/freebsd_signal.h> 61 62 int 63 freebsd_sys_msync(p, v, retval) 64 struct proc *p; 65 void *v; 66 register_t *retval; 67 { 68 struct freebsd_sys_msync_args /* { 69 syscallarg(caddr_t) addr; 70 syscallarg(size_t) len; 71 syscallarg(int) flags; 72 } */ *uap = v; 73 struct sys___msync13_args bma; 74 75 /* 76 * FreeBSD-2.0-RELEASE's msync(2) is compatible with NetBSD's. 77 * FreeBSD-2.0.5-RELEASE's msync(2) has addtional argument `flags', 78 * but syscall number is not changed. :-< 79 */ 80 SCARG(&bma, addr) = SCARG(uap, addr); 81 SCARG(&bma, len) = SCARG(uap, len); 82 SCARG(&bma, flags) = SCARG(uap, flags); 83 return sys___msync13(p, &bma, retval); 84 } 85 86 /* just a place holder */ 87 88 int 89 freebsd_sys_rtprio(p, v, retval) 90 struct proc *p; 91 void *v; 92 register_t *retval; 93 { 94 #ifdef notyet 95 struct freebsd_sys_rtprio_args /* { 96 syscallarg(int) function; 97 syscallarg(pid_t) pid; 98 syscallarg(struct freebsd_rtprio *) rtp; 99 } */ *uap = v; 100 #endif 101 102 return ENOSYS; /* XXX */ 103 } 104 105 #ifdef NTP 106 int 107 freebsd_ntp_adjtime(p, v, retval) 108 struct proc *p; 109 void *v; 110 register_t *retval; 111 { 112 #ifdef notyet 113 struct freebsd_ntp_adjtime_args /* { 114 syscallarg(struct freebsd_timex *) tp; 115 } */ *uap = v; 116 #endif 117 118 return ENOSYS; /* XXX */ 119 } 120 #endif 121 122 int 123 freebsd_sys_sigaction4(p, v, retval) 124 struct proc *p; 125 void *v; 126 register_t *retval; 127 { 128 struct freebsd_sys_sigaction4_args /* { 129 syscallarg(int) signum; 130 syscallarg(const struct freebsd_sigaction4 *) nsa; 131 syscallarg(struct freebsd_sigaction4 *) osa; 132 } */ *uap = v; 133 struct freebsd_sigaction4 nesa, oesa; 134 struct sigaction nbsa, obsa; 135 int error; 136 137 if (SCARG(uap, nsa)) { 138 error = copyin(SCARG(uap, nsa), &nesa, sizeof(nesa)); 139 if (error) 140 return (error); 141 nbsa.sa_handler = nesa.sa_handler; 142 nbsa.sa_mask = nesa.sa_mask; 143 nbsa.sa_flags = nesa.sa_flags; 144 } 145 error = sigaction1(p, SCARG(uap, signum), 146 SCARG(uap, nsa) ? &nbsa : 0, SCARG(uap, osa) ? &obsa : 0); 147 if (error) 148 return (error); 149 if (SCARG(uap, osa)) { 150 oesa.sa_handler = obsa.sa_handler; 151 oesa.sa_mask = obsa.sa_mask; 152 oesa.sa_flags = obsa.sa_flags; 153 error = copyout(&oesa, SCARG(uap, osa), sizeof(oesa)); 154 if (error) 155 return (error); 156 } 157 return (0); 158 } 159 160 int 161 freebsd_sys_utrace(p, v, retval) 162 struct proc *p; 163 void *v; 164 register_t *retval; 165 { 166 #ifdef KTRACE 167 struct freebsd_sys_utrace_args /* { 168 syscallarg(void *) addr; 169 syscallarg(size_t) len; 170 } */ *uap = v; 171 172 if (KTRPOINT(p, KTR_USER)) 173 ktruser(p, "FreeBSD utrace", SCARG(uap, addr), SCARG(uap, len), 174 0); 175 176 return (0); 177 #else 178 return (ENOSYS); 179 #endif 180 } 181