xref: /netbsd-src/sys/kern/kern_stub.c (revision 8b0f9554ff8762542c4defc4f70e1eb76fb508fa)
1 /*	$NetBSD: kern_stub.c,v 1.4 2007/08/27 13:33:45 dsl Exp $	*/
2 
3 /*-
4  * Copyright (c) 2007 The NetBSD Foundation, Inc.
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 by the NetBSD
18  *	Foundation, Inc. and its contributors.
19  * 4. Neither the name of The NetBSD Foundation nor the names of its
20  *    contributors may be used to endorse or promote products derived
21  *    from this software without specific prior written permission.
22  *
23  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
24  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
25  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
26  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
27  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
29  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
30  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
31  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
32  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33  * POSSIBILITY OF SUCH DAMAGE.
34  */
35 
36 /*
37  * Copyright (c) 1982, 1986, 1991, 1993
38  *	The Regents of the University of California.  All rights reserved.
39  *
40  * Redistribution and use in source and binary forms, with or without
41  * modification, are permitted provided that the following conditions
42  * are met:
43  * 1. Redistributions of source code must retain the above copyright
44  *    notice, this list of conditions and the following disclaimer.
45  * 2. Redistributions in binary form must reproduce the above copyright
46  *    notice, this list of conditions and the following disclaimer in the
47  *    documentation and/or other materials provided with the distribution.
48  * 3. Neither the name of the University nor the names of its contributors
49  *    may be used to endorse or promote products derived from this software
50  *    without specific prior written permission.
51  *
52  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
53  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
54  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
55  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
56  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
57  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
58  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
59  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
60  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
61  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
62  * SUCH DAMAGE.
63  *
64  *	@(#)subr_xxx.c	8.3 (Berkeley) 3/29/95
65  */
66 
67 /*
68  * Stubs for system calls and facilities not included in the system.
69  */
70 
71 #include <sys/cdefs.h>
72 __KERNEL_RCSID(0, "$NetBSD: kern_stub.c,v 1.4 2007/08/27 13:33:45 dsl Exp $");
73 
74 #include "opt_ptrace.h"
75 #include "opt_ktrace.h"
76 
77 #include <sys/param.h>
78 #include <sys/kernel.h>
79 #include <sys/proc.h>
80 #include <sys/signalvar.h>
81 #include <sys/syscallargs.h>
82 #include <sys/ktrace.h>
83 
84 /*
85  * Nonexistent system call-- signal process (may want to handle it).  Flag
86  * error in case process won't see signal immediately (blocked or ignored).
87  */
88 #ifndef PTRACE
89 __weak_alias(sys_ptrace,sys_nosys);
90 #endif	/* PTRACE */
91 
92 /*
93  * ktrace stubs.  ktruser() goes to enosys as we want to fail the syscall,
94  * but not kill the process: utrace() is a debugging feature.
95  */
96 #ifndef KTRACE
97 __weak_alias(ktr_csw,nullop);		/* Probes */
98 __weak_alias(ktr_emul,nullop);
99 __weak_alias(ktr_geniov,nullop);
100 __weak_alias(ktr_genio,nullop);
101 __weak_alias(ktr_mibio,nullop);
102 __weak_alias(ktr_namei,nullop);
103 __weak_alias(ktr_namei2,nullop);
104 __weak_alias(ktr_psig,nullop);
105 __weak_alias(ktr_syscall,nullop);
106 __weak_alias(ktr_sysret,nullop);
107 __weak_alias(ktr_kuser,nullop);
108 __weak_alias(ktr_mmsg,nullop);
109 __weak_alias(ktr_mib,nullop);
110 __weak_alias(ktr_mool,nullop);
111 __weak_alias(ktr_execarg,nullop);
112 __weak_alias(ktr_execenv,nullop);
113 
114 __weak_alias(sys_fktrace,sys_nosys);	/* Syscalls */
115 __weak_alias(sys_ktrace,sys_nosys);
116 __weak_alias(sys_utrace,sys_nosys);
117 
118 int	ktrace_on;			/* Misc */
119 __weak_alias(ktruser,enosys);
120 __weak_alias(ktr_point,nullop);
121 #endif	/* KTRACE */
122 
123 /*
124  * Scheduler activations system calls.  These need to remain until libc's
125  * major version is bumped.
126  */
127 __strong_alias(sys_sa_register,sys_nosys);
128 __strong_alias(sys_sa_stacks,sys_nosys);
129 __strong_alias(sys_sa_enable,sys_nosys);
130 __strong_alias(sys_sa_setconcurrency,sys_nosys);
131 __strong_alias(sys_sa_yield,sys_nosys);
132 __strong_alias(sys_sa_preempt,sys_nosys);
133 __strong_alias(sys_sa_unblockyield,sys_nosys);
134 
135 /* ARGSUSED */
136 int
137 sys_nosys(struct lwp *l, void *v, register_t *retval)
138 {
139 
140 	mutex_enter(&proclist_mutex);
141 	psignal(l->l_proc, SIGSYS);
142 	mutex_exit(&proclist_mutex);
143 	return ENOSYS;
144 }
145 
146 /*
147  * Unsupported device function (e.g. writing to read-only device).
148  */
149 int
150 enodev(void)
151 {
152 
153 	return (ENODEV);
154 }
155 
156 /*
157  * Unconfigured device function; driver not configured.
158  */
159 int
160 enxio(void)
161 {
162 
163 	return (ENXIO);
164 }
165 
166 /*
167  * Unsupported ioctl function.
168  */
169 int
170 enoioctl(void)
171 {
172 
173 	return (ENOTTY);
174 }
175 
176 /*
177  * Unsupported system function.
178  * This is used for an otherwise-reasonable operation
179  * that is not supported by the current system binary.
180  */
181 int
182 enosys(void)
183 {
184 
185 	return (ENOSYS);
186 }
187 
188 /*
189  * Return error for operation not supported
190  * on a specific object or file type.
191  */
192 int
193 eopnotsupp(void)
194 {
195 
196 	return (EOPNOTSUPP);
197 }
198 
199 /*
200  * Generic null operation, always returns success.
201  */
202 /*ARGSUSED*/
203 int
204 nullop(void *v)
205 {
206 
207 	return (0);
208 }
209