Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys Split the SYSV* compat code out into a separate compat_s...
details: https://anonhg.NetBSD.org/src/rev/a05cf41e00d7
branches: trunk
changeset: 338096:a05cf41e00d7
user: pgoyette <pgoyette%NetBSD.org@localhost>
date: Sun May 10 07:41:15 2015 +0000
description:
Split the SYSV* compat code out into a separate compat_sysv module.
For monolithic kernels, both modules will be compiled as "built-ins",
while modular environments will be able to load the SYSVSEM, SYSVSHM,
and SYSVMSG code independant from the rest of compat.
This is a necessary precursor step to making the "STD" SYSV* code
into a separate module.
Tested in both monolithic and modular environments with no errors
seen.
diffstat:
sys/compat/common/compat_mod.c | 41 +++++------
sys/compat/common/compat_sysv_mod.c | 125 ++++++++++++++++++++++++++++++++++++
sys/compat/common/sysv_ipc_50.c | 6 +-
sys/kern/files.kern | 4 +-
sys/kern/syscalls.master | 20 ++--
sys/kern/sysv_ipc.c | 37 +++++++---
sys/modules/Makefile | 3 +-
sys/modules/compat/Makefile | 13 +--
sys/modules/compat_sysv/Makefile | 25 +++++++
sys/sys/ipc.h | 9 ++-
10 files changed, 227 insertions(+), 56 deletions(-)
diffs (truncated from 541 to 300 lines):
diff -r 512650b73484 -r a05cf41e00d7 sys/compat/common/compat_mod.c
--- a/sys/compat/common/compat_mod.c Sun May 10 06:33:28 2015 +0000
+++ b/sys/compat/common/compat_mod.c Sun May 10 07:41:15 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: compat_mod.c,v 1.20 2013/09/19 18:50:35 christos Exp $ */
+/* $NetBSD: compat_mod.c,v 1.21 2015/05/10 07:41:15 pgoyette Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: compat_mod.c,v 1.20 2013/09/19 18:50:35 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: compat_mod.c,v 1.21 2015/05/10 07:41:15 pgoyette Exp $");
#ifdef _KERNEL_OPT
#include "opt_compat_netbsd.h"
@@ -60,12 +60,15 @@
#include <compat/common/compat_util.h>
#include <compat/common/compat_mod.h>
+#ifdef _MODULE
#if defined(COMPAT_09) || defined(COMPAT_43) || defined(COMPAT_50)
static struct sysctllog *compat_clog = NULL;
#endif
+#endif
MODULE(MODULE_CLASS_EXEC, compat, NULL);
+#ifdef _MODULE
int ttcompat(struct tty *, u_long, void *, int, struct lwp *);
#ifdef COMPAT_16
@@ -153,18 +156,6 @@
{ SYS_compat_13_sigsuspend13, 0, (sy_call_t *)compat_13_sys_sigsuspend },
#endif
-#if defined(COMPAT_14)
-# if defined(SYSVSEM)
- { SYS_compat_14___semctl, 0, (sy_call_t *)compat_14_sys___semctl },
-# endif
-# if defined(SYSVMSG)
- { SYS_compat_14_msgctl, 0, (sy_call_t *)compat_14_sys_msgctl },
-# endif
-# if defined(SYSVSHM)
- { SYS_compat_14_shmctl, 0, (sy_call_t *)compat_14_sys_shmctl },
-# endif
-#endif
-
#if defined(COMPAT_16)
#if defined(COMPAT_SIGCONTEXT)
{ SYS_compat_16___sigaction14, 0, (sy_call_t *)compat_16_sys___sigaction14 },
@@ -220,15 +211,6 @@
{ SYS_compat_50_mq_timedsend, 0, (sy_call_t *)compat_50_sys_mq_timedsend },
{ SYS_compat_50_mq_timedreceive, 0, (sy_call_t *)compat_50_sys_mq_timedreceive },
{ SYS_compat_50_lutimes, 0, (sy_call_t *)compat_50_sys_lutimes },
-# if defined(SYSVSEM)
- { SYS_compat_50_____semctl13, 0, (sy_call_t *)compat_50_sys_____semctl13 },
-# endif
-# if defined(SYSVMSG)
- { SYS_compat_50___msgctl13, 0, (sy_call_t *)compat_50_sys___msgctl13 },
-# endif
-# if defined(SYSVSHM)
- { SYS_compat_50___shmctl13, 0, (sy_call_t *)compat_50_sys___shmctl13 },
-# endif
{ SYS_compat_50__lwp_park, 0, (sy_call_t *)compat_50_sys__lwp_park },
{ SYS_compat_50_kevent, 0, (sy_call_t *)compat_50_sys_kevent },
{ SYS_compat_50_pselect, 0, (sy_call_t *)compat_50_sys_pselect },
@@ -248,10 +230,12 @@
#endif
{ 0, 0, NULL },
};
+#endif /* _MODULE */
static int
compat_modcmd(modcmd_t cmd, void *arg)
{
+#ifdef _MODULE
#ifdef COMPAT_16
proc_t *p;
#endif
@@ -342,8 +326,18 @@
default:
return ENOTTY;
}
+#else /* _MODULE */
+ switch (cmd) {
+ case MODULE_CMD_INIT:
+ case MODULE_CMD_FINI:
+ return 0;
+ default:
+ return ENOTTY;
+ }
+#endif
}
+#ifdef _MODULE
void
compat_sysctl_init(void)
{
@@ -364,3 +358,4 @@
sysctl_teardown(&compat_clog);
#endif
}
+#endif
diff -r 512650b73484 -r a05cf41e00d7 sys/compat/common/compat_sysv_mod.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/compat/common/compat_sysv_mod.c Sun May 10 07:41:15 2015 +0000
@@ -0,0 +1,125 @@
+/* $NetBSD: compat_sysv_mod.c,v 1.1 2015/05/10 07:41:15 pgoyette Exp $ */
+
+/*-
+ * Copyright (c) 2008 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software developed for The NetBSD Foundation
+ * by Andrew Doran.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * Linkage for the compat module: spaghetti.
+ */
+
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: compat_sysv_mod.c,v 1.1 2015/05/10 07:41:15 pgoyette Exp $");
+
+#ifdef _KERNEL_OPT
+#include "opt_compat_netbsd.h"
+#endif
+
+#include <sys/systm.h>
+#include <sys/module.h>
+#include <sys/sysctl.h>
+#include <sys/syscall.h>
+#include <sys/syscallargs.h>
+#include <sys/syscallvar.h>
+#include <sys/ipc.h>
+
+MODULE(MODULE_CLASS_EXEC, compat_sysv, NULL);
+
+#ifdef _MODULE
+static const struct syscall_package compat_sysv_syscalls[] = {
+#if defined(COMPAT_10) && !defined(_LP64)
+# if defined(SYSVMSG)
+ { SYS_compat_10_omsgsys, 0, (sy_call_t *)compat_10_sys_msgsys },
+# endif
+# if defined(SYSVSEM)
+ { SYS_compat_10_osemsys, 0, (sy_call_t *)compat_10_sys_semsys },
+# endif
+# if defined(SYSVSHM)
+ { SYS_compat_10_oshmsys, 0, (sy_call_t *)compat_10_sys_shmsys },
+# endif
+#endif
+
+#if defined(COMPAT_14)
+# if defined(SYSVSEM)
+ { SYS_compat_14___semctl, 0, (sy_call_t *)compat_14_sys___semctl },
+# endif
+# if defined(SYSVMSG)
+ { SYS_compat_14_msgctl, 0, (sy_call_t *)compat_14_sys_msgctl },
+# endif
+# if defined(SYSVSHM)
+ { SYS_compat_14_shmctl, 0, (sy_call_t *)compat_14_sys_shmctl },
+# endif
+#endif
+
+#if defined(COMPAT_50)
+# if defined(SYSVSEM)
+ { SYS_compat_50_____semctl13, 0, (sy_call_t *)compat_50_sys_____semctl13 },
+# endif
+# if defined(SYSVMSG)
+ { SYS_compat_50___msgctl13, 0, (sy_call_t *)compat_50_sys___msgctl13 },
+# endif
+# if defined(SYSVSHM)
+ { SYS_compat_50___shmctl13, 0, (sy_call_t *)compat_50_sys___shmctl13 },
+# endif
+#endif
+ { 0, 0, NULL },
+};
+#endif
+
+int sysctl_kern_sysvipc50(SYSCTLFN_ARGS);
+
+static int
+compat_sysv_modcmd(modcmd_t cmd, void *arg)
+{
+ int error = 0;
+
+ switch (cmd) {
+ case MODULE_CMD_INIT:
+#ifdef _MODULE
+ /* Link the system calls */
+ error = syscall_establish(NULL, compat_sysv_syscalls);
+#endif
+#ifdef COMPAT_50
+ sysvipc50_set_compat_sysctl(sysctl_kern_sysvipc50);
+#endif
+ return error;
+
+ case MODULE_CMD_FINI:
+#ifdef _MODULE
+ /* Unlink the system calls. */
+ error = syscall_disestablish(NULL, compat_sysv_syscalls);
+#endif
+#ifdef COMPAT_50
+ sysvipc50_set_compat_sysctl(NULL);
+#endif
+ return error;
+
+ default:
+ return ENOTTY;
+ }
+}
diff -r 512650b73484 -r a05cf41e00d7 sys/compat/common/sysv_ipc_50.c
--- a/sys/compat/common/sysv_ipc_50.c Sun May 10 06:33:28 2015 +0000
+++ b/sys/compat/common/sysv_ipc_50.c Sun May 10 07:41:15 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: sysv_ipc_50.c,v 1.2 2009/01/21 16:12:20 christos Exp $ */
+/* $NetBSD: sysv_ipc_50.c,v 1.3 2015/05/10 07:41:15 pgoyette Exp $ */
/*-
* Copyright (c) 1998, 2007 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sysv_ipc_50.c,v 1.2 2009/01/21 16:12:20 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sysv_ipc_50.c,v 1.3 2015/05/10 07:41:15 pgoyette Exp $");
#ifdef _KERNEL_OPT
#include "opt_sysv.h"
@@ -74,6 +74,8 @@
* Check for ipc permission
*/
+int sysctl_kern_sysvipc50(SYSCTLFN_PROTO);
+
int
sysctl_kern_sysvipc50(SYSCTLFN_ARGS)
{
diff -r 512650b73484 -r a05cf41e00d7 sys/kern/files.kern
--- a/sys/kern/files.kern Sun May 10 06:33:28 2015 +0000
+++ b/sys/kern/files.kern Sun May 10 07:41:15 2015 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: files.kern,v 1.5 2015/05/06 15:57:08 hannken Exp $
+# $NetBSD: files.kern,v 1.6 2015/05/10 07:41:15 pgoyette Exp $
#
# kernel sources
@@ -6,6 +6,8 @@
define kern: machdep, uvm
defflag opt_kern.h KERN
file compat/common/compat_mod.c compat_netbsd | compat_netbsd32
+file compat/common/compat_sysv_mod.c (compat_netbsd | compat_netbsd32) &
+ (sysvshm | sysvsem | sysvmsg)
file conf/debugsyms.c kern
file dev/bio.c bio needs-flag
file dev/ccd.c ccd
diff -r 512650b73484 -r a05cf41e00d7 sys/kern/syscalls.master
--- a/sys/kern/syscalls.master Sun May 10 06:33:28 2015 +0000
+++ b/sys/kern/syscalls.master Sun May 10 07:41:15 2015 +0000
@@ -1,4 +1,4 @@
- $NetBSD: syscalls.master,v 1.275 2015/05/09 06:04:13 pgoyette Exp $
+ $NetBSD: syscalls.master,v 1.276 2015/05/10 07:41:15 pgoyette Exp $
; @(#)syscalls.master 8.2 (Berkeley) 1/13/94
@@ -351,7 +351,7 @@
168 UNIMPL
; XXX more generally, never on machines where sizeof(void *) != sizeof(int)
#if (defined(SYSVSEM) || !defined(_KERNEL_OPT)) && !defined(_LP64)
-169 COMPAT_10 MODULAR compat \
+169 COMPAT_10 MODULAR compat_sysv \
{ int|sys||semsys(int which, int a2, int a3, int a4, \
int a5); } osemsys
#else
@@ -359,7 +359,7 @@
#endif
Home |
Main Index |
Thread Index |
Old Index