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