xref: /netbsd-src/sys/compat/common/compat_sysv_10_mod.c (revision d91f98a8715141154279122ae81737cb65179572)
1*d91f98a8Spgoyette /*	$NetBSD: compat_sysv_10_mod.c,v 1.2 2019/01/27 02:08:39 pgoyette Exp $	*/
2*d91f98a8Spgoyette 
3*d91f98a8Spgoyette /*-
4*d91f98a8Spgoyette  * Copyright (c) 2018 The NetBSD Foundation, Inc.
5*d91f98a8Spgoyette  * All rights reserved.
6*d91f98a8Spgoyette  *
7*d91f98a8Spgoyette  * This code is derived from software developed for The NetBSD Foundation
8*d91f98a8Spgoyette  * by Paul Goyette
9*d91f98a8Spgoyette  *
10*d91f98a8Spgoyette  * Redistribution and use in source and binary forms, with or without
11*d91f98a8Spgoyette  * modification, are permitted provided that the following conditions
12*d91f98a8Spgoyette  * are met:
13*d91f98a8Spgoyette  * 1. Redistributions of source code must retain the above copyright
14*d91f98a8Spgoyette  *    notice, this list of conditions and the following disclaimer.
15*d91f98a8Spgoyette  * 2. Redistributions in binary form must reproduce the above copyright
16*d91f98a8Spgoyette  *    notice, this list of conditions and the following disclaimer in the
17*d91f98a8Spgoyette  *    documentation and/or other materials provided with the distribution.
18*d91f98a8Spgoyette  *
19*d91f98a8Spgoyette  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20*d91f98a8Spgoyette  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21*d91f98a8Spgoyette  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22*d91f98a8Spgoyette  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23*d91f98a8Spgoyette  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24*d91f98a8Spgoyette  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25*d91f98a8Spgoyette  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26*d91f98a8Spgoyette  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27*d91f98a8Spgoyette  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28*d91f98a8Spgoyette  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29*d91f98a8Spgoyette  * POSSIBILITY OF SUCH DAMAGE.
30*d91f98a8Spgoyette  */
31*d91f98a8Spgoyette 
32*d91f98a8Spgoyette #include <sys/cdefs.h>
33*d91f98a8Spgoyette __KERNEL_RCSID(0, "$NetBSD: compat_sysv_10_mod.c,v 1.2 2019/01/27 02:08:39 pgoyette Exp $");
34*d91f98a8Spgoyette 
35*d91f98a8Spgoyette #ifdef _KERNEL_OPT
36*d91f98a8Spgoyette #include "opt_compat_netbsd.h"
37*d91f98a8Spgoyette #include "opt_sysv.h"
38*d91f98a8Spgoyette #endif
39*d91f98a8Spgoyette 
40*d91f98a8Spgoyette #include <sys/systm.h>
41*d91f98a8Spgoyette #include <sys/module.h>
42*d91f98a8Spgoyette #include <sys/syscall.h>
43*d91f98a8Spgoyette #include <sys/syscallargs.h>
44*d91f98a8Spgoyette #include <sys/syscallvar.h>
45*d91f98a8Spgoyette #include <sys/sysctl.h>
46*d91f98a8Spgoyette 
47*d91f98a8Spgoyette MODULE(MODULE_CLASS_EXEC, compat_sysv_10,
48*d91f98a8Spgoyette     "sysv_ipc,compat_sysv_50,compat_sysv_14");
49*d91f98a8Spgoyette 
50*d91f98a8Spgoyette /* Build the syscall package based on options specified */
51*d91f98a8Spgoyette 
52*d91f98a8Spgoyette static const struct syscall_package compat_sysv_10_syscalls[] = {
53*d91f98a8Spgoyette #if !defined(_LP64)
54*d91f98a8Spgoyette #ifdef	SYSVSHM
55*d91f98a8Spgoyette 	{ SYS_compat_10_oshmsys, 0, (sy_call_t *)compat_10_sys_shmsys },
56*d91f98a8Spgoyette #endif
57*d91f98a8Spgoyette #ifdef	SYSVSEM
58*d91f98a8Spgoyette 	{ SYS_compat_10_osemsys, 0, (sy_call_t *)compat_10_sys_semsys },
59*d91f98a8Spgoyette #endif
60*d91f98a8Spgoyette #ifdef	SYSVMSG
61*d91f98a8Spgoyette 	{ SYS_compat_10_omsgsys, 0, (sy_call_t *)compat_10_sys_msgsys },
62*d91f98a8Spgoyette #endif
63*d91f98a8Spgoyette #endif /* !defined(_LP64) */
64*d91f98a8Spgoyette 	{ 0, 0, NULL }
65*d91f98a8Spgoyette };
66*d91f98a8Spgoyette 
67*d91f98a8Spgoyette static int
compat_sysv_10_modcmd(modcmd_t cmd,void * arg)68*d91f98a8Spgoyette compat_sysv_10_modcmd(modcmd_t cmd, void *arg)
69*d91f98a8Spgoyette {
70*d91f98a8Spgoyette 
71*d91f98a8Spgoyette 	int error = 0;
72*d91f98a8Spgoyette 
73*d91f98a8Spgoyette 	switch (cmd) {
74*d91f98a8Spgoyette 	case MODULE_CMD_INIT:
75*d91f98a8Spgoyette 		error = syscall_establish(NULL, compat_sysv_10_syscalls);
76*d91f98a8Spgoyette 		if (error != 0) {
77*d91f98a8Spgoyette 			break;
78*d91f98a8Spgoyette 		}
79*d91f98a8Spgoyette 		break;
80*d91f98a8Spgoyette 
81*d91f98a8Spgoyette 	case MODULE_CMD_FINI:
82*d91f98a8Spgoyette 		error = syscall_disestablish(NULL, compat_sysv_10_syscalls);
83*d91f98a8Spgoyette 		if (error != 0) {
84*d91f98a8Spgoyette 			break;
85*d91f98a8Spgoyette 		}
86*d91f98a8Spgoyette 		break;
87*d91f98a8Spgoyette 
88*d91f98a8Spgoyette 	default:
89*d91f98a8Spgoyette 		error = ENOTTY;
90*d91f98a8Spgoyette 		break;
91*d91f98a8Spgoyette 	}
92*d91f98a8Spgoyette 	return error;
93*d91f98a8Spgoyette }
94