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