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