xref: /netbsd-src/sys/compat/common/compat_sysv_14_mod.c (revision d91f98a8715141154279122ae81737cb65179572)
1*d91f98a8Spgoyette /*	$NetBSD: compat_sysv_14_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_14_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_14, "compat_sysv_50,sysv_ipc");
48*d91f98a8Spgoyette 
49*d91f98a8Spgoyette /* Build the syscall package based on options specified */
50*d91f98a8Spgoyette 
51*d91f98a8Spgoyette static const struct syscall_package compat_sysv_14_syscalls[] = {
52*d91f98a8Spgoyette #ifdef SYSVSHM
53*d91f98a8Spgoyette 	{ SYS_compat_14_shmctl, 0, (sy_call_t *)compat_14_sys_shmctl },
54*d91f98a8Spgoyette #endif
55*d91f98a8Spgoyette #ifdef	SYSVSEM
56*d91f98a8Spgoyette 	{ SYS_compat_14___semctl, 0, (sy_call_t *)compat_14_sys___semctl },
57*d91f98a8Spgoyette #endif
58*d91f98a8Spgoyette #ifdef	SYSVMSG
59*d91f98a8Spgoyette 	{ SYS_compat_14_msgctl, 0, (sy_call_t *)compat_14_sys_msgctl },
60*d91f98a8Spgoyette #endif
61*d91f98a8Spgoyette 	{ 0, 0, NULL }
62*d91f98a8Spgoyette };
63*d91f98a8Spgoyette 
64*d91f98a8Spgoyette static int
compat_sysv_14_modcmd(modcmd_t cmd,void * arg)65*d91f98a8Spgoyette compat_sysv_14_modcmd(modcmd_t cmd, void *arg)
66*d91f98a8Spgoyette {
67*d91f98a8Spgoyette 
68*d91f98a8Spgoyette 	int error = 0;
69*d91f98a8Spgoyette 
70*d91f98a8Spgoyette 	switch (cmd) {
71*d91f98a8Spgoyette 	case MODULE_CMD_INIT:
72*d91f98a8Spgoyette 		error = syscall_establish(NULL, compat_sysv_14_syscalls);
73*d91f98a8Spgoyette 		if (error != 0) {
74*d91f98a8Spgoyette 			break;
75*d91f98a8Spgoyette 		}
76*d91f98a8Spgoyette 		break;
77*d91f98a8Spgoyette 
78*d91f98a8Spgoyette 	case MODULE_CMD_FINI:
79*d91f98a8Spgoyette 		error = syscall_disestablish(NULL, compat_sysv_14_syscalls);
80*d91f98a8Spgoyette 		if (error != 0) {
81*d91f98a8Spgoyette 			break;
82*d91f98a8Spgoyette 		}
83*d91f98a8Spgoyette 		break;
84*d91f98a8Spgoyette 
85*d91f98a8Spgoyette 	default:
86*d91f98a8Spgoyette 		error = ENOTTY;
87*d91f98a8Spgoyette 		break;
88*d91f98a8Spgoyette 	}
89*d91f98a8Spgoyette 	return error;
90*d91f98a8Spgoyette }
91