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