Home | History | Annotate | Line # | Download | only in freebsd
freebsd_misc.c revision 1.5.4.1
      1 /*	$NetBSD: freebsd_misc.c,v 1.5.4.1 2002/03/06 22:03:59 he 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 #include "opt_ntp.h"
     39 
     40 #include <sys/param.h>
     41 #include <sys/systm.h>
     42 #include <sys/proc.h>
     43 #include <sys/mount.h>
     44 #include <sys/signal.h>
     45 #include <sys/signalvar.h>
     46 
     47 #include <sys/syscallargs.h>
     48 
     49 #include <compat/freebsd/freebsd_syscallargs.h>
     50 #include <compat/freebsd/freebsd_util.h>
     51 #include <compat/freebsd/freebsd_rtprio.h>
     52 #include <compat/freebsd/freebsd_timex.h>
     53 #include <compat/freebsd/freebsd_signal.h>
     54 
     55 int
     56 freebsd_sys_msync(p, v, retval)
     57 	struct proc *p;
     58 	void *v;
     59 	register_t *retval;
     60 {
     61 	struct freebsd_sys_msync_args /* {
     62 		syscallarg(caddr_t) addr;
     63 		syscallarg(size_t) len;
     64 		syscallarg(int) flags;
     65 	} */ *uap = v;
     66 	struct sys___msync13_args bma;
     67 
     68 	/*
     69 	 * FreeBSD-2.0-RELEASE's msync(2) is compatible with NetBSD's.
     70 	 * FreeBSD-2.0.5-RELEASE's msync(2) has addtional argument `flags',
     71 	 * but syscall number is not changed. :-<
     72 	 */
     73 	SCARG(&bma, addr) = SCARG(uap, addr);
     74 	SCARG(&bma, len) = SCARG(uap, len);
     75 	SCARG(&bma, flags) = SCARG(uap, flags);
     76 	return sys___msync13(p, &bma, retval);
     77 }
     78 
     79 /* just a place holder */
     80 
     81 int
     82 freebsd_sys_rtprio(p, v, retval)
     83 	struct proc *p;
     84 	void *v;
     85 	register_t *retval;
     86 {
     87 #ifdef notyet
     88 	struct freebsd_sys_rtprio_args /* {
     89 		syscallarg(int) function;
     90 		syscallarg(pid_t) pid;
     91 		syscallarg(struct freebsd_rtprio *) rtp;
     92 	} */ *uap = v;
     93 #endif
     94 
     95 	return ENOSYS;	/* XXX */
     96 }
     97 
     98 #ifdef NTP
     99 int
    100 freebsd_ntp_adjtime(p, v, retval)
    101 	struct proc *p;
    102 	void *v;
    103 	register_t *retval;
    104 {
    105 #ifdef notyet
    106 	struct freebsd_ntp_adjtime_args /* {
    107 		syscallarg(struct freebsd_timex *) tp;
    108 	} */ *uap = v;
    109 #endif
    110 
    111 	return ENOSYS;	/* XXX */
    112 }
    113 #endif
    114 
    115 int
    116 freebsd_sys_sigaction4(p, v, retval)
    117 	struct proc *p;
    118 	void *v;
    119 	register_t *retval;
    120 {
    121 	struct freebsd_sys_sigaction4_args /* {
    122 		syscallarg(int) signum;
    123 		syscallarg(const struct freebsd_sigaction4 *) nsa;
    124 		syscallarg(struct freebsd_sigaction4 *) osa;
    125 	} */ *uap = v;
    126 	struct freebsd_sigaction4 nesa, oesa;
    127 	struct sigaction nbsa, obsa;
    128 	int error;
    129 
    130 	if (SCARG(uap, nsa)) {
    131 		error = copyin(SCARG(uap, nsa), &nesa, sizeof(nesa));
    132 		if (error)
    133 			return (error);
    134 		nbsa.sa_handler = nesa.sa_handler;
    135 		nbsa.sa_mask    = nesa.sa_mask;
    136 		nbsa.sa_flags   = nesa.sa_flags;
    137 	}
    138 	error = sigaction1(p, SCARG(uap, signum),
    139 	    SCARG(uap, nsa) ? &nbsa : 0, SCARG(uap, osa) ? &obsa : 0);
    140 	if (error)
    141 		return (error);
    142 	if (SCARG(uap, osa)) {
    143 		oesa.sa_handler = obsa.sa_handler;
    144 		oesa.sa_mask    = obsa.sa_mask;
    145 		oesa.sa_flags   = obsa.sa_flags;
    146 		error = copyout(&oesa, SCARG(uap, osa), sizeof(oesa));
    147 		if (error)
    148 			return (error);
    149 	}
    150 	return (0);
    151 }
    152