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