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