Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/pgoyette-compat]: src/sys Split the sysv_ipc module into two pieces: on...



details:   https://anonhg.NetBSD.org/src/rev/1cf87d6a6caf
branches:  pgoyette-compat
changeset: 830391:1cf87d6a6caf
user:      pgoyette <pgoyette%NetBSD.org@localhost>
date:      Fri Mar 09 01:27:50 2018 +0000

description:
Split the sysv_ipc module into two pieces:  one for contemporary
SYSV* functionality, and one for compatability with previous NetBSD
versions.  No need to pull in all of compat just to have a sysv_ipc
module.

diffstat:

 sys/arch/amd64/conf/NOCOMPAT         |   10 +-
 sys/compat/common/files.common       |    6 +-
 sys/compat/common/sysv_ipc_mod.c     |  134 +++++++++++++++++++++++++++++++++++
 sys/compat/common/sysv_ipc_mod.h     |   39 ++++++++++
 sys/kern/sysv_ipc.c                  |   52 ++++---------
 sys/modules/Makefile                 |    3 +-
 sys/modules/compat_sysv_ipc/Makefile |   23 ++++++
 sys/modules/sysv_ipc/Makefile        |   11 +--
 8 files changed, 225 insertions(+), 53 deletions(-)

diffs (truncated from 416 to 300 lines):

diff -r c5a3d1d1ca9d -r 1cf87d6a6caf sys/arch/amd64/conf/NOCOMPAT
--- a/sys/arch/amd64/conf/NOCOMPAT      Thu Mar 08 09:56:05 2018 +0000
+++ b/sys/arch/amd64/conf/NOCOMPAT      Fri Mar 09 01:27:50 2018 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: NOCOMPAT,v 1.1.2.1 2018/03/06 04:45:04 pgoyette Exp $
+# $NetBSD: NOCOMPAT,v 1.1.2.2 2018/03/09 01:27:50 pgoyette Exp $
 #
 # GENERIC machine description file
 #
@@ -22,7 +22,7 @@
 
 options        INCLUDE_CONFIG_FILE     # embed config file in kernel binary
 
-#ident         "GENERIC-$Revision: 1.1.2.1 $"
+#ident         "GENERIC-$Revision: 1.1.2.2 $"
 
 maxusers       64              # estimated number of users
 
@@ -63,9 +63,9 @@
 options        CPU_UCODE       # cpu ucode loading support
 
 # Note: SysV IPC parameters could be changed dynamically, see sysctl(8).
-options        SYSVMSG         # System V-like message queues
-options        SYSVSEM         # System V-like semaphores
-options        SYSVSHM         # System V-like memory sharing
+#options       SYSVMSG         # System V-like message queues
+#options       SYSVSEM         # System V-like semaphores
+#options       SYSVSHM         # System V-like memory sharing
 
 options        MODULAR         # new style module(7) framework
 options        MODULAR_DEFAULT_AUTOLOAD
diff -r c5a3d1d1ca9d -r 1cf87d6a6caf sys/compat/common/files.common
--- a/sys/compat/common/files.common    Thu Mar 08 09:56:05 2018 +0000
+++ b/sys/compat/common/files.common    Fri Mar 09 01:27:50 2018 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: files.common,v 1.1.2.3 2018/03/06 10:37:41 pgoyette Exp $
+#      $NetBSD: files.common,v 1.1.2.4 2018/03/09 01:27:50 pgoyette Exp $
 
 #
 # Generic files, used by all compat options.
@@ -73,6 +73,10 @@
 # Sources for sysv ipc compatibility across the versions.
 #
 
+# Module interface for sysv ipc compatability options
+
+file   compat/common/sysv_ipc_mod.c            compat_netbsd
+
 # Compatibility code for NetBSD 1.0
 file   compat/common/kern_ipc_10.c             compat_netbsd
 
diff -r c5a3d1d1ca9d -r 1cf87d6a6caf sys/compat/common/sysv_ipc_mod.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/compat/common/sysv_ipc_mod.c  Fri Mar 09 01:27:50 2018 +0000
@@ -0,0 +1,134 @@
+/*     $NetBSD: sysv_ipc_mod.c,v 1.1.2.1 2018/03/09 01:27:50 pgoyette Exp $    */
+
+/*-
+ * Copyright (c) 2018 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software developed for The NetBSD Foundation
+ * by Paul Goyette
+ *
+ * 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.
+ */
+
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: sysv_ipc_mod.c,v 1.1.2.1 2018/03/09 01:27:50 pgoyette Exp $");
+
+#ifdef _KERNEL_OPT
+#include "opt_compat_netbsd.h"
+#include "opt_compat_50.h"
+#include "opt_compat_14.h"
+#include "opt_compat_10.h"
+#include "opt_sysv.h"
+#endif
+
+#include <sys/systm.h>
+#include <sys/module.h>
+#include <sys/syscall.h>
+#include <sys/syscallargs.h>
+#include <sys/syscallvar.h>
+#include <sys/sysctl.h>
+
+#include <compat/common/sysv_ipc_mod.h>
+
+#ifdef COMPAT_50
+int sysctl_kern_sysvipc50(SYSCTLFN_PROTO);
+#endif
+
+MODULE(MODULE_CLASS_EXEC, compat_sysv_ipc, NULL);
+
+/* Build the syscall package based on options specified */
+
+static const struct syscall_package compat_syscalls[] = {
+#if defined(COMPAT_10) && !defined(_LP64)
+#ifdef SYSVSHM
+       { SYS_compat_10_oshmsys, 0, (sy_call_t *)compat_10_sys_shmsys },
+#endif
+#ifdef SYSVSEM
+       { SYS_compat_10_osemsys, 0, (sy_call_t *)compat_10_sys_semsys },
+#endif
+#ifdef SYSVMSG
+       { SYS_compat_10_omsgsys, 0, (sy_call_t *)compat_10_sys_msgsys },
+#endif
+#endif /* defined(COMPAT_10) && !defined(_LP64) */
+
+#if defined(COMPAT_14)
+#ifdef SYSVSHM
+       { SYS_compat_14_shmctl, 0, (sy_call_t *)compat_14_sys_shmctl },
+#endif
+#ifdef SYSVSEM
+       { SYS_compat_14___semctl, 0, (sy_call_t *)compat_14_sys___semctl },
+#endif
+#ifdef SYSVMSG
+       { SYS_compat_14_msgctl, 0, (sy_call_t *)compat_14_sys_msgctl },
+#endif
+#endif /* defined(COMPAT_14) */
+
+#if defined(COMPAT_50)
+#ifdef SYSVSHM
+       { SYS_compat_50___shmctl13, 0, (sy_call_t *)compat_50_sys___shmctl13 },
+#endif
+#ifdef SYSVSEM
+       { SYS_compat_50_____semctl13, 0, (sy_call_t *)compat_50_sys_____semctl13 },
+#endif
+#ifdef SYSVMSG
+       { SYS_compat_50___msgctl13, 0, (sy_call_t *)compat_50_sys___msgctl13 },
+#endif
+#endif /* defined(COMPAT_50) */
+
+       { 0, 0, NULL }
+};
+
+static int
+compat_sysv_ipc_modcmd(modcmd_t cmd, void *arg)
+{
+       static (*orig_sysvipc50_sysctl)(SYSCTLFN_PROTO);
+
+       int error = 0;
+
+       switch (cmd) {
+       case MODULE_CMD_INIT:
+               error = syscall_establish(NULL, compat_syscalls);
+               if (error != 0) {
+                       break;
+               }
+#if defined(COMPAT_50)
+               orig_sysvipc50_sysctl = vec_sysvipc50_sysctl;
+               vec_sysvipc50_sysctl = sysctl_kern_sysvipc50;
+#endif
+               break;
+
+       case MODULE_CMD_FINI:
+#if defined(COMPAT_50)
+               vec_sysvipc50_sysctl = orig_sysvipc50_sysctl;
+#endif
+               error = syscall_disestablish(NULL, compat_syscalls);
+               if (error != 0) {
+                       break;
+               }
+               break;
+
+       default:
+               error = ENOTTY;
+               break;
+       }
+       return error;
+}
diff -r c5a3d1d1ca9d -r 1cf87d6a6caf sys/compat/common/sysv_ipc_mod.h
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/compat/common/sysv_ipc_mod.h  Fri Mar 09 01:27:50 2018 +0000
@@ -0,0 +1,39 @@
+/*     $NetBSD: sysv_ipc_mod.h,v 1.1.2.1 2018/03/09 01:27:50 pgoyette Exp $    */
+
+/*-
+ * Copyright (c) 2018 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software developed for The NetBSD Foundation
+ * by Paul Goyette
+ *
+ * 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.
+ */
+
+#ifndef _COMPAT_COMMON_SYSV_IPC_MOD_H_
+#define _COMPAT_COMMON_SYSV_IPC_MOD_H_
+
+#include <sys/sysctl.h>
+
+int (*vec_sysvipc50_sysctl)(SYSCTLFN_PROTO);
+
+#endif /* _COMPAT_COMMON_SYSV_IPC_MOD_H_ */
diff -r c5a3d1d1ca9d -r 1cf87d6a6caf sys/kern/sysv_ipc.c
--- a/sys/kern/sysv_ipc.c       Thu Mar 08 09:56:05 2018 +0000
+++ b/sys/kern/sysv_ipc.c       Fri Mar 09 01:27:50 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: sysv_ipc.c,v 1.32 2015/12/05 00:51:42 pgoyette Exp $   */
+/*     $NetBSD: sysv_ipc.c,v 1.32.16.1 2018/03/09 01:27:50 pgoyette Exp $      */
 
 /*-
  * Copyright (c) 1998, 2007 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sysv_ipc.c,v 1.32 2015/12/05 00:51:42 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sysv_ipc.c,v 1.32.16.1 2018/03/09 01:27:50 pgoyette Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_sysv.h"
@@ -62,6 +62,8 @@
 #include <sys/sysctl.h>
 #include <sys/kauth.h>
 
+#include <compat/common/sysv_ipc_mod.h>        /* for sysctl routine vector */
+
 /*
  * Values in support of System V compatible shared memory.     XXX
  * (originally located in sys/conf/param.c)
@@ -124,10 +126,6 @@
 };
 #endif
 
-#if defined(COMPAT_50)
-int sysctl_kern_sysvipc50(SYSCTLFN_PROTO);
-#endif
-
 MODULE(MODULE_CLASS_EXEC, sysv_ipc, NULL);
  
 SYSCTL_SETUP_PROTO(sysctl_ipc_setup);
@@ -140,15 +138,6 @@
        { SYS_shmat, 0, (sy_call_t *)sys_shmat },
        { SYS_shmdt, 0, (sy_call_t *)sys_shmdt },
        { SYS_shmget, 0, (sy_call_t *)sys_shmget },
-#if defined(COMPAT_10) && !defined(_LP64)
-       { SYS_compat_10_oshmsys, 0, (sy_call_t *)compat_10_sys_shmsys },
-#endif
-#if defined(COMPAT_14)
-       { SYS_compat_14_shmctl, 0, (sy_call_t *)compat_14_sys_shmctl },
-#endif
-#if defined(COMPAT_50)
-       { SYS_compat_50___shmctl13, 0, (sy_call_t *)compat_50_sys___shmctl13 },
-#endif
 #endif /* SYSVSHM */
 
 #if defined(SYSVSEM)
@@ -156,15 +145,6 @@
        { SYS_semget, 0, (sy_call_t *)sys_semget },
        { SYS_semop, 0, (sy_call_t *)sys_semop },
        { SYS_semconfig, 0, (sy_call_t *)sys_semconfig },
-#if defined(COMPAT_10) && !defined(_LP64)
-       { SYS_compat_10_osemsys, 0, (sy_call_t *)compat_10_sys_semsys },
-#endif
-#if defined(COMPAT_14)
-       { SYS_compat_14___semctl, 0, (sy_call_t *)compat_14_sys___semctl },
-#endif
-#if defined(COMPAT_50)
-       { SYS_compat_50_____semctl13, 0, (sy_call_t *)compat_50_sys_____semctl13 },
-#endif
 #endif /* SYSVSEM */



Home | Main Index | Thread Index | Old Index