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