Module Name: src Committed By: pgoyette Date: Wed Sep 12 04:35:22 UTC 2018
Modified Files: src/distrib/sets/lists/modules [pgoyette-compat]: ad.arm ad.mips md.amd64 src/sys/compat/netbsd32 [pgoyette-compat]: files.netbsd32 netbsd32_compat_50_sysv.c netbsd32_ipc.c src/sys/modules [pgoyette-compat]: Makefile src/sys/modules/compat_netbsd32 [pgoyette-compat]: Makefile src/sys/modules/compat_netbsd32_sysvipc [pgoyette-compat]: Makefile Added Files: src/sys/compat/netbsd32 [pgoyette-compat]: netbsd32_compat_10_sysv.c netbsd32_compat_14_sysv.c Removed Files: src/sys/compat/netbsd32 [pgoyette-compat]: netbsd32_compat_10.c netbsd32_compat_14.c Log Message: Split compat_netbsd32_sysvipc into version-specific modules To generate a diff of this commit: cvs rdiff -u -r1.10.12.4 -r1.10.12.5 src/distrib/sets/lists/modules/ad.arm \ src/distrib/sets/lists/modules/ad.mips cvs rdiff -u -r1.75.2.6 -r1.75.2.7 src/distrib/sets/lists/modules/md.amd64 cvs rdiff -u -r1.39.14.3 -r1.39.14.4 src/sys/compat/netbsd32/files.netbsd32 cvs rdiff -u -r1.25.16.2 -r0 src/sys/compat/netbsd32/netbsd32_compat_10.c cvs rdiff -u -r0 -r1.1.2.1 src/sys/compat/netbsd32/netbsd32_compat_10_sysv.c \ src/sys/compat/netbsd32/netbsd32_compat_14_sysv.c cvs rdiff -u -r1.26 -r0 src/sys/compat/netbsd32/netbsd32_compat_14.c cvs rdiff -u -r1.1 -r1.1.20.1 \ src/sys/compat/netbsd32/netbsd32_compat_50_sysv.c cvs rdiff -u -r1.18.16.3 -r1.18.16.4 src/sys/compat/netbsd32/netbsd32_ipc.c cvs rdiff -u -r1.202.2.31 -r1.202.2.32 src/sys/modules/Makefile cvs rdiff -u -r1.20.12.8 -r1.20.12.9 src/sys/modules/compat_netbsd32/Makefile cvs rdiff -u -r1.1 -r1.1.20.1 \ src/sys/modules/compat_netbsd32_sysvipc/Makefile Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/distrib/sets/lists/modules/ad.arm diff -u src/distrib/sets/lists/modules/ad.arm:1.10.12.4 src/distrib/sets/lists/modules/ad.arm:1.10.12.5 --- src/distrib/sets/lists/modules/ad.arm:1.10.12.4 Wed Sep 12 01:28:32 2018 +++ src/distrib/sets/lists/modules/ad.arm Wed Sep 12 04:35:22 2018 @@ -1,4 +1,4 @@ -# $NetBSD: ad.arm,v 1.10.12.4 2018/09/12 01:28:32 pgoyette Exp $ +# $NetBSD: ad.arm,v 1.10.12.5 2018/09/12 04:35:22 pgoyette Exp $ ./@MODULEDIR@/compat_netbsd32 base-kernel-modules kmod ./@MODULEDIR@/compat_netbsd32/compat_netbsd32.kmod base-kernel-modules kmod @@ -36,5 +36,11 @@ ./@MODULEDIR@/compat_netbsd32_ptrace/compat_netbsd32_ptrace.kmod base-kernel-modules kmod ./@MODULEDIR@/compat_netbsd32_sysvipc base-kernel-modules kmod ./@MODULEDIR@/compat_netbsd32_sysvipc/compat_netbsd32_sysvipc.kmod base-kernel-modules kmod +./@MODULEDIR@/compat_netbsd32_sysvipc_10 base-kernel-modules kmod +./@MODULEDIR@/compat_netbsd32_sysvipc_10/compat_netbsd32_sysvipc_10.kmod base-kernel-modules kmod +./@MODULEDIR@/compat_netbsd32_sysvipc_14 base-kernel-modules kmod +./@MODULEDIR@/compat_netbsd32_sysvipc_14/compat_netbsd32_sysvipc_14.kmod base-kernel-modules kmod +./@MODULEDIR@/compat_netbsd32_sysvipc_50 base-kernel-modules kmod +./@MODULEDIR@/compat_netbsd32_sysvipc_50/compat_netbsd32_sysvipc_50.kmod base-kernel-modules kmod ./@MODULEDIR@/exec_elf32 base-kernel-modules kmod ./@MODULEDIR@/exec_elf32/exec_elf32.kmod base-kernel-modules kmod Index: src/distrib/sets/lists/modules/ad.mips diff -u src/distrib/sets/lists/modules/ad.mips:1.10.12.4 src/distrib/sets/lists/modules/ad.mips:1.10.12.5 --- src/distrib/sets/lists/modules/ad.mips:1.10.12.4 Wed Sep 12 01:28:32 2018 +++ src/distrib/sets/lists/modules/ad.mips Wed Sep 12 04:35:22 2018 @@ -1,4 +1,4 @@ -# $NetBSD: ad.mips,v 1.10.12.4 2018/09/12 01:28:32 pgoyette Exp $ +# $NetBSD: ad.mips,v 1.10.12.5 2018/09/12 04:35:22 pgoyette Exp $ ./@MODULEDIR@/compat_netbsd32 base-kernel-modules kmod,arch64,nocompatmodules ./@MODULEDIR@/compat_netbsd32/compat_netbsd32.kmod base-kernel-modules kmod,arch64,nocompatmodules ./@MODULEDIR@/compat_netbsd32_09 base-kernel-modules kmod @@ -35,5 +35,11 @@ ./@MODULEDIR@/compat_netbsd32_ptrace/compat_netbsd32_ptrace.kmod base-kernel-modules kmod,arch64,nocompatmodules ./@MODULEDIR@/compat_netbsd32_sysvipc base-kernel-modules kmod,arch64,nocompatmodules ./@MODULEDIR@/compat_netbsd32_sysvipc/compat_netbsd32_sysvipc.kmod base-kernel-modules kmod,arch64,nocompatmodules +./@MODULEDIR@/compat_netbsd32_sysvipc_10 base-kernel-modules kmod,arch64,nocompatmodules +./@MODULEDIR@/compat_netbsd32_sysvipc_10/compat_netbsd32_sysvipc_10.kmod base-kernel-modules kmod,arch64,nocompatmodules +./@MODULEDIR@/compat_netbsd32_sysvipc_14 base-kernel-modules kmod,arch64,nocompatmodules +./@MODULEDIR@/compat_netbsd32_sysvipc_14/compat_netbsd32_sysvipc_14.kmod base-kernel-modules kmod,arch64,nocompatmodules +./@MODULEDIR@/compat_netbsd32_sysvipc_50 base-kernel-modules kmod,arch64,nocompatmodules +./@MODULEDIR@/compat_netbsd32_sysvipc_50/compat_netbsd32_sysvipc_50.kmod base-kernel-modules kmod,arch64,nocompatmodules ./@MODULEDIR@/exec_elf32 base-kernel-modules kmod ./@MODULEDIR@/exec_elf32/exec_elf32.kmod base-kernel-modules kmod Index: src/distrib/sets/lists/modules/md.amd64 diff -u src/distrib/sets/lists/modules/md.amd64:1.75.2.6 src/distrib/sets/lists/modules/md.amd64:1.75.2.7 --- src/distrib/sets/lists/modules/md.amd64:1.75.2.6 Wed Sep 12 01:28:32 2018 +++ src/distrib/sets/lists/modules/md.amd64 Wed Sep 12 04:35:22 2018 @@ -1,4 +1,4 @@ -# $NetBSD: md.amd64,v 1.75.2.6 2018/09/12 01:28:32 pgoyette Exp $ +# $NetBSD: md.amd64,v 1.75.2.7 2018/09/12 04:35:22 pgoyette Exp $ # # NOTE that there are two sets of files here: # @MODULEDIR@ and amd64-xen @@ -89,6 +89,12 @@ ./@MODULEDIR@/compat_netbsd32_ptrace/compat_netbsd32_ptrace.kmod base-kernel-modules kmod ./@MODULEDIR@/compat_netbsd32_sysvipc base-kernel-modules kmod ./@MODULEDIR@/compat_netbsd32_sysvipc/compat_netbsd32_sysvipc.kmod base-kernel-modules kmod +./@MODULEDIR@/compat_netbsd32_sysvipc_10 base-kernel-modules kmod +./@MODULEDIR@/compat_netbsd32_sysvipc_10/compat_netbsd32_sysvipc_10.kmod base-kernel-modules kmod +./@MODULEDIR@/compat_netbsd32_sysvipc_14 base-kernel-modules kmod +./@MODULEDIR@/compat_netbsd32_sysvipc_14/compat_netbsd32_sysvipc_14.kmod base-kernel-modules kmod +./@MODULEDIR@/compat_netbsd32_sysvipc_50 base-kernel-modules kmod +./@MODULEDIR@/compat_netbsd32_sysvipc_50/compat_netbsd32_sysvipc_50.kmod base-kernel-modules kmod ./@MODULEDIR@/coram base-kernel-modules kmod ./@MODULEDIR@/coram/coram.kmod base-kernel-modules kmod ./@MODULEDIR@/coretemp base-kernel-modules kmod Index: src/sys/compat/netbsd32/files.netbsd32 diff -u src/sys/compat/netbsd32/files.netbsd32:1.39.14.3 src/sys/compat/netbsd32/files.netbsd32:1.39.14.4 --- src/sys/compat/netbsd32/files.netbsd32:1.39.14.3 Wed Sep 12 01:26:40 2018 +++ src/sys/compat/netbsd32/files.netbsd32 Wed Sep 12 04:35:22 2018 @@ -1,4 +1,4 @@ -# $NetBSD: files.netbsd32,v 1.39.14.3 2018/09/12 01:26:40 pgoyette Exp $ +# $NetBSD: files.netbsd32,v 1.39.14.4 2018/09/12 04:35:22 pgoyette Exp $ # # config file description for machine-independent netbsd32 compat code. # included by ports that need it. @@ -33,10 +33,12 @@ file compat/netbsd32/netbsd32_sysent.c c file compat/netbsd32/netbsd32_syscalls.c compat_netbsd32 & syscall_debug file compat/netbsd32/netbsd32_compat_09.c compat_netbsd32 & (compat_09 | compat_sunos) -file compat/netbsd32/netbsd32_compat_10.c compat_netbsd32 & (compat_10 | compat_sunos) +file compat/netbsd32/netbsd32_compat_10_sysv.c compat_netbsd32 & compat_10 & + (sysvmsg | sysvsem | sysvshm) file compat/netbsd32/netbsd32_compat_12.c compat_netbsd32 & (compat_12 | compat_sunos) file compat/netbsd32/netbsd32_compat_13.c compat_netbsd32 & compat_13 -file compat/netbsd32/netbsd32_compat_14.c compat_netbsd32 & compat_14 +file compat/netbsd32/netbsd32_compat_14_sysv.c compat_netbsd32 & compat_14 & + (sysvmsg | sysvsem | sysvshm) file compat/netbsd32/netbsd32_compat_16.c compat_netbsd32 & compat_16 file compat/netbsd32/netbsd32_compat_20.c compat_netbsd32 & compat_20 file compat/netbsd32/netbsd32_compat_30.c compat_netbsd32 & compat_30 Index: src/sys/compat/netbsd32/netbsd32_compat_50_sysv.c diff -u src/sys/compat/netbsd32/netbsd32_compat_50_sysv.c:1.1 src/sys/compat/netbsd32/netbsd32_compat_50_sysv.c:1.1.20.1 --- src/sys/compat/netbsd32/netbsd32_compat_50_sysv.c:1.1 Thu Dec 3 10:38:21 2015 +++ src/sys/compat/netbsd32/netbsd32_compat_50_sysv.c Wed Sep 12 04:35:22 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: netbsd32_compat_50_sysv.c,v 1.1 2015/12/03 10:38:21 pgoyette Exp $ */ +/* $NetBSD: netbsd32_compat_50_sysv.c,v 1.1.20.1 2018/09/12 04:35:22 pgoyette Exp $ */ /*- * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -36,7 +36,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: netbsd32_compat_50_sysv.c,v 1.1 2015/12/03 10:38:21 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: netbsd32_compat_50_sysv.c,v 1.1.20.1 2018/09/12 04:35:22 pgoyette Exp $"); #if defined(_KERNEL_OPT) #include "opt_sysv.h" @@ -45,11 +45,15 @@ __KERNEL_RCSID(0, "$NetBSD: netbsd32_com #include <sys/param.h> #include <sys/systm.h> +#include <sys/module.h> #include <sys/msg.h> #include <sys/sem.h> #include <sys/shm.h> +#include <sys/syscallvar.h> + #include <compat/netbsd32/netbsd32.h> +#include <compat/netbsd32/netbsd32_syscall.h> #include <compat/netbsd32/netbsd32_syscallargs.h> #include <compat/netbsd32/netbsd32_conv.h> @@ -207,4 +211,43 @@ compat_50_netbsd32___shmctl13(struct lwp } #endif +#define _PKG_ENTRY(name) \ + { NETBSD32_SYS_ ## name, 0, (sy_call_t *)name } + +static const struct syscall_package compat_sysvipc_50_syscalls[] = { +#if defined(SYSVSEM) + _PKG_ENTRY(compat_50_netbsd32___semctl14), +#endif +#if defined(SYSVSHM) + _PKG_ENTRY(compat_50_netbsd32___shmctl13), +#endif +#if defined(SYSVMSG) + _PKG_ENTRY(compat_50_netbsd32___msgctl13), +#endif + { 0, 0, NULL } +}; + +#define REQ1 "sysv_ipc,compat_sysv_50," +#define REQ2 "compat_netbsd32,compat_netbsd32_sysvipc," + +MODULE(MODULE_CLASS_EXEC, compat_netbsd32_sysvipc_50, REQ1 REQ2); + +static int +compat_netbsd32_sysvipc_50_modcmd(modcmd_t cmd, void *arg) +{ + + switch (cmd) { + case MODULE_CMD_INIT: + return syscall_establish(&emul_netbsd32, + compat_sysvipc_50_syscalls); + + case MODULE_CMD_FINI: + return syscall_disestablish(&emul_netbsd32, + compat_sysvipc_50_syscalls); + + default: + return ENOTTY; + } +} + #endif /* COMPAT_50 */ Index: src/sys/compat/netbsd32/netbsd32_ipc.c diff -u src/sys/compat/netbsd32/netbsd32_ipc.c:1.18.16.3 src/sys/compat/netbsd32/netbsd32_ipc.c:1.18.16.4 --- src/sys/compat/netbsd32/netbsd32_ipc.c:1.18.16.3 Tue Sep 11 21:18:32 2018 +++ src/sys/compat/netbsd32/netbsd32_ipc.c Wed Sep 12 04:35:22 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: netbsd32_ipc.c,v 1.18.16.3 2018/09/11 21:18:32 pgoyette Exp $ */ +/* $NetBSD: netbsd32_ipc.c,v 1.18.16.4 2018/09/12 04:35:22 pgoyette Exp $ */ /* * Copyright (c) 1998, 2001 Matthew R. Green @@ -27,7 +27,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: netbsd32_ipc.c,v 1.18.16.3 2018/09/11 21:18:32 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: netbsd32_ipc.c,v 1.18.16.4 2018/09/12 04:35:22 pgoyette Exp $"); #if defined(_KERNEL_OPT) #include "opt_sysv.h" @@ -64,15 +64,6 @@ static const struct syscall_package comp _PKG_ENTRY(netbsd32_semget), _PKG_ENTRY(netbsd32_semop), _PKG_ENTRY(netbsd32_semconfig), -#if defined(COMPAT_10) - _PKG_ENTRY2(compat_10_osemsys, compat_10_netbsd32_semsys), -#endif -#if defined(COMPAT_14) - _PKG_ENTRY(compat_14_netbsd32___semctl), -#endif -#if defined(COMPAT_50) - _PKG_ENTRY(compat_50_netbsd32___semctl14), -#endif #endif /* SYSVSEM */ #if defined(SYSVSHM) @@ -80,15 +71,6 @@ static const struct syscall_package comp _PKG_ENTRY(netbsd32___shmctl50), _PKG_ENTRY(netbsd32_shmdt), _PKG_ENTRY(netbsd32_shmget), -#if defined(COMPAT_10) - _PKG_ENTRY2(compat_10_oshmsys, compat_10_netbsd32_shmsys), -#endif -#if defined(COMPAT_14) - _PKG_ENTRY(compat_14_netbsd32_shmctl), -#endif -#if defined(COMPAT_50) - _PKG_ENTRY(compat_50_netbsd32___shmctl13), -#endif #endif /* SYSVSHM */ #if defined(SYSVMSG) @@ -96,15 +78,6 @@ static const struct syscall_package comp _PKG_ENTRY(netbsd32_msgget), _PKG_ENTRY(netbsd32_msgsnd), _PKG_ENTRY(netbsd32_msgrcv), -#if defined(COMPAT_10) - _PKG_ENTRY2(compat_10_omsgsys, compat_10_netbsd32_msgsys), -#endif -#if defined(COMPAT_14) - _PKG_ENTRY(compat_14_netbsd32_msgctl), -#endif -#if defined(COMPAT_50) - _PKG_ENTRY(compat_50_netbsd32___msgctl13), -#endif #endif /* SYSVMSG */ { 0, 0, NULL } }; Index: src/sys/modules/Makefile diff -u src/sys/modules/Makefile:1.202.2.31 src/sys/modules/Makefile:1.202.2.32 --- src/sys/modules/Makefile:1.202.2.31 Wed Sep 12 01:26:39 2018 +++ src/sys/modules/Makefile Wed Sep 12 04:35:22 2018 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.202.2.31 2018/09/12 01:26:39 pgoyette Exp $ +# $NetBSD: Makefile,v 1.202.2.32 2018/09/12 04:35:22 pgoyette Exp $ .include <bsd.own.mk> @@ -277,6 +277,9 @@ SUBDIR+= compat_netbsd32_mqueue SUBDIR+= compat_netbsd32_nfssrv SUBDIR+= compat_netbsd32_ptrace SUBDIR+= compat_netbsd32_sysvipc +SUBDIR+= compat_netbsd32_sysvipc_10 +SUBDIR+= compat_netbsd32_sysvipc_14 +SUBDIR+= compat_netbsd32_sysvipc_50 .endif .if ${MACHINE_ARCH} == "x86_64" @@ -292,6 +295,9 @@ SUBDIR+= compat_netbsd32_mqueue SUBDIR+= compat_netbsd32_nfssrv SUBDIR+= compat_netbsd32_ptrace SUBDIR+= compat_netbsd32_sysvipc +SUBDIR+= compat_netbsd32_sysvipc_10 +SUBDIR+= compat_netbsd32_sysvipc_14 +SUBDIR+= compat_netbsd32_sysvipc_50 .endif .if ${MACHINE_ARCH} == "i386" Index: src/sys/modules/compat_netbsd32/Makefile diff -u src/sys/modules/compat_netbsd32/Makefile:1.20.12.8 src/sys/modules/compat_netbsd32/Makefile:1.20.12.9 --- src/sys/modules/compat_netbsd32/Makefile:1.20.12.8 Tue Sep 11 23:58:46 2018 +++ src/sys/modules/compat_netbsd32/Makefile Wed Sep 12 04:35:22 2018 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.20.12.8 2018/09/11 23:58:46 pgoyette Exp $ +# $NetBSD: Makefile,v 1.20.12.9 2018/09/12 04:35:22 pgoyette Exp $ .include "../Makefile.inc" .include "../Makefile.assym" @@ -24,8 +24,6 @@ CPPFLAGS+= -DCOREDUMP -DNTP -DVMSWAP CPPFLAGS+= -DKTRACE -DMODULAR .PATH: ${S}/compat/netbsd32 -SRCS+= netbsd32_compat_10.c # belongs to compat_netbsd32_sysvipc_10 -SRCS+= netbsd32_compat_14.c # belongs to compat_netbsd32_sysvipc_14 SRCS+= netbsd32_core.c netbsd32_event.c SRCS+= netbsd32_exec_elf32.c SRCS+= netbsd32_execve.c netbsd32_fs.c Index: src/sys/modules/compat_netbsd32_sysvipc/Makefile diff -u src/sys/modules/compat_netbsd32_sysvipc/Makefile:1.1 src/sys/modules/compat_netbsd32_sysvipc/Makefile:1.1.20.1 --- src/sys/modules/compat_netbsd32_sysvipc/Makefile:1.1 Thu Dec 3 10:38:21 2015 +++ src/sys/modules/compat_netbsd32_sysvipc/Makefile Wed Sep 12 04:35:22 2018 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.1 2015/12/03 10:38:21 pgoyette Exp $ +# $NetBSD: Makefile,v 1.1.20.1 2018/09/12 04:35:22 pgoyette Exp $ .include "../Makefile.inc" .include "../Makefile.assym" @@ -12,8 +12,5 @@ CPPFLAGS+= -DSYSVSHM -DSYSVSEM -DSYSVMSG .PATH: ${S}/compat/netbsd32 SRCS+= netbsd32_ipc.c -SRCS+= netbsd32_compat_10.c -SRCS+= netbsd32_compat_14.c -SRCS+= netbsd32_compat_50_sysv.c .include <bsd.kmodule.mk> Added files: Index: src/sys/compat/netbsd32/netbsd32_compat_10_sysv.c diff -u /dev/null src/sys/compat/netbsd32/netbsd32_compat_10_sysv.c:1.1.2.1 --- /dev/null Wed Sep 12 04:35:23 2018 +++ src/sys/compat/netbsd32/netbsd32_compat_10_sysv.c Wed Sep 12 04:35:22 2018 @@ -0,0 +1,290 @@ +/* $NetBSD: netbsd32_compat_10_sysv.c,v 1.1.2.1 2018/09/12 04:35:22 pgoyette Exp $ */ + +/* + * Copyright (c) 1994 Adam Glass and Charles M. Hannum. All rights reserved. + * + * 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. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by Adam Glass and Charles M. + * Hannum. + * 4. The names of the authors may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``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 AUTHORS 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: netbsd32_compat_10_sysv.c,v 1.1.2.1 2018/09/12 04:35:22 pgoyette Exp $"); + +#ifdef _KERNEL_OPT +#include "opt_sysv.h" +#include "opt_compat_netbsd.h" +#endif + +#include <sys/param.h> +#include <sys/systm.h> +#include <sys/module.h> +#include <sys/kernel.h> +#include <sys/proc.h> +#include <sys/sem.h> + +#include <sys/mount.h> +#include <sys/syscallargs.h> +#include <sys/syscallvar.h> + +#include <compat/netbsd32/netbsd32.h> +#include <compat/netbsd32/netbsd32_syscall.h> +#include <compat/netbsd32/netbsd32_syscallargs.h> +#include <compat/sys/shm.h> + +#if defined(COMPAT_10) + +#if defined(SYSVSEM) +int +compat_10_netbsd32_semsys(struct lwp *l, const struct compat_10_netbsd32_semsys_args *uap, register_t *retval) +{ + /* { + syscallarg(int) which; + syscallarg(int) a2; + syscallarg(int) a3; + syscallarg(int) a4; + syscallarg(int) a5; + } */ + struct compat_50_netbsd32___semctl14_args /* { + syscallarg(int) semid; + syscallarg(int) semnum; + syscallarg(int) cmd; + syscallarg(union semun *) arg; + } */ __semctl_args; + struct sys_semget_args /* { + syscallarg(key_t) key; + syscallarg(int) nsems; + syscallarg(int) semflg; + } */ semget_args; + struct sys_semop_args /* { + syscallarg(int) semid; + syscallarg(struct sembuf *) sops; + syscallarg(u_int) nsops; + } */ semop_args; + struct sys_semconfig_args /* { + syscallarg(int) flag; + } */ semconfig_args; + int a5; + + switch (SCARG(uap, which)) { + case 0: /* __semctl() */ + SCARG(&__semctl_args, semid) = SCARG(uap, a2); + SCARG(&__semctl_args, semnum) = SCARG(uap, a3); + SCARG(&__semctl_args, cmd) = SCARG(uap, a4); + a5 = SCARG(uap, a5); + return do_netbsd32___semctl14(l, &__semctl_args, retval, &a5); + + case 1: /* semget() */ + SCARG(&semget_args, key) = SCARG(uap, a2); + SCARG(&semget_args, nsems) = SCARG(uap, a3); + SCARG(&semget_args, semflg) = SCARG(uap, a4); + return (sys_semget(l, &semget_args, retval)); + + case 2: /* semop() */ + SCARG(&semop_args, semid) = SCARG(uap, a2); + SCARG(&semop_args, sops) = NETBSD32IPTR64(SCARG(uap, a3)); + SCARG(&semop_args, nsops) = SCARG(uap, a4); + return (sys_semop(l, &semop_args, retval)); + + case 3: /* semconfig() */ + SCARG(&semconfig_args, flag) = SCARG(uap, a2); + return (sys_semconfig(l, &semconfig_args, retval)); + + default: + return (EINVAL); + } +} +#endif + +#if defined(SYSVSHM) +int +compat_10_netbsd32_shmsys(struct lwp *l, const struct compat_10_netbsd32_shmsys_args *uap, register_t *retval) +{ + /* { + syscallarg(int) which; + syscallarg(int) a2; + syscallarg(int) a3; + syscallarg(int) a4; + } */ + struct sys_shmat_args /* { + syscallarg(int) shmid; + syscallarg(void *) shmaddr; + syscallarg(int) shmflg; + } */ shmat_args; + struct compat_14_sys_shmctl_args /* { + syscallarg(int) shmid; + syscallarg(int) cmd; + syscallarg(struct shmid_ds50 *) buf; + } */ shmctl_args; + struct sys_shmdt_args /* { + syscallarg(void *) shmaddr; + } */ shmdt_args; + struct sys_shmget_args /* { + syscallarg(key_t) key; + syscallarg(int) size; + syscallarg(int) shmflg; + } */ shmget_args; + + switch (SCARG(uap, which)) { + case 0: /* shmat() */ + SCARG(&shmat_args, shmid) = SCARG(uap, a2); + SCARG(&shmat_args, shmaddr) = NETBSD32IPTR64(SCARG(uap, a3)); + SCARG(&shmat_args, shmflg) = SCARG(uap, a4); + return (sys_shmat(l, &shmat_args, retval)); + + case 1: /* shmctl() */ + SCARG(&shmctl_args, shmid) = SCARG(uap, a2); + SCARG(&shmctl_args, cmd) = SCARG(uap, a3); + SCARG(&shmctl_args, buf) = NETBSD32IPTR64(SCARG(uap, a4)); + return (compat_14_sys_shmctl(l, &shmctl_args, retval)); + + case 2: /* shmdt() */ + SCARG(&shmdt_args, shmaddr) = NETBSD32IPTR64(SCARG(uap, a2)); + return (sys_shmdt(l, &shmdt_args, retval)); + + case 3: /* shmget() */ + SCARG(&shmget_args, key) = SCARG(uap, a2); + SCARG(&shmget_args, size) = SCARG(uap, a3); + SCARG(&shmget_args, shmflg) = SCARG(uap, a4); + return (sys_shmget(l, &shmget_args, retval)); + + default: + return (EINVAL); + } +} +#endif + +#if defined(SYSVMSG) +int +compat_10_netbsd32_msgsys(struct lwp *l, const struct compat_10_netbsd32_msgsys_args *uap, register_t *retval) +{ + /* { + syscallarg(int) which; + syscallarg(int) a2; + syscallarg(int) a3; + syscallarg(int) a4; + syscallarg(int) a5; + syscallarg(int) a6; + } */ + struct compat_14_sys_msgctl_args /* { + syscallarg(int) msqid; + syscallarg(int) cmd; + syscallarg(struct msqid_ds *) buf; + } */ msgctl_args; + struct sys_msgget_args /* { + syscallarg(key_t) key; + syscallarg(int) msgflg; + } */ msgget_args; + struct sys_msgsnd_args /* { + syscallarg(int) msqid; + syscallarg(void *) msgp; + syscallarg(size_t) msgsz; + syscallarg(int) msgflg; + } */ msgsnd_args; + struct sys_msgrcv_args /* { + syscallarg(int) msqid; + syscallarg(void *) msgp; + syscallarg(size_t) msgsz; + syscallarg(long) msgtyp; + syscallarg(int) msgflg; + } */ msgrcv_args; + + switch (SCARG(uap, which)) { + case 0: /* msgctl()*/ + SCARG(&msgctl_args, msqid) = SCARG(uap, a2); + SCARG(&msgctl_args, cmd) = SCARG(uap, a3); + SCARG(&msgctl_args, buf) = NETBSD32IPTR64(SCARG(uap, a4)); + return (compat_14_sys_msgctl(l, &msgctl_args, retval)); + + case 1: /* msgget() */ + SCARG(&msgget_args, key) = SCARG(uap, a2); + SCARG(&msgget_args, msgflg) = SCARG(uap, a3); + return (sys_msgget(l, &msgget_args, retval)); + + case 2: /* msgsnd() */ + SCARG(&msgsnd_args, msqid) = SCARG(uap, a2); + SCARG(&msgsnd_args, msgp) = NETBSD32IPTR64(SCARG(uap, a3)); + SCARG(&msgsnd_args, msgsz) = SCARG(uap, a4); + SCARG(&msgsnd_args, msgflg) = SCARG(uap, a5); + return (sys_msgsnd(l, &msgsnd_args, retval)); + + case 3: /* msgrcv() */ + SCARG(&msgrcv_args, msqid) = SCARG(uap, a2); + SCARG(&msgrcv_args, msgp) = NETBSD32IPTR64(SCARG(uap, a3)); + SCARG(&msgrcv_args, msgsz) = SCARG(uap, a4); + SCARG(&msgrcv_args, msgtyp) = SCARG(uap, a5); + SCARG(&msgrcv_args, msgflg) = SCARG(uap, a6); + return (sys_msgrcv(l, &msgrcv_args, retval)); + + default: + return (EINVAL); + } +} +#endif + +#define _PKG_ENTRY(name) \ + { NETBSD32_SYS_ ## name, 0, (sy_call_t *)name } + +#define _PKG_ENTRY2(code, name) \ + { NETBSD32_SYS_ ## code, 0, (sy_call_t *)name } + +static const struct syscall_package compat_sysvipc_10_syscalls[] = { +#if defined(SYSVSEM) + _PKG_ENTRY2(compat_10_osemsys, compat_10_netbsd32_semsys), +#endif +#if defined(SYSVSHM) + _PKG_ENTRY2(compat_10_oshmsys, compat_10_netbsd32_shmsys), +#endif +#if defined(SYSVMSG) + _PKG_ENTRY2(compat_10_omsgsys, compat_10_netbsd32_msgsys), +#endif + { 0, 0, NULL } +}; + +#define REQ1 "sysv_ipc,compat_sysv_10," +#define REQ2 "compat_netbsd32,compat_netbsd32_sysvipc," +#define REQ3 "compat_netbsd32_sysvipc_14,compat_netbsd32_sysvipc_50" + +MODULE(MODULE_CLASS_EXEC, compat_netbsd32_sysvipc_10, REQ1 REQ2 REQ3 ); + +static int +compat_netbsd32_sysvipc_10_modcmd(modcmd_t cmd, void *arg) +{ + + switch (cmd) { + case MODULE_CMD_INIT: + return syscall_establish(&emul_netbsd32, + compat_sysvipc_10_syscalls); + + case MODULE_CMD_FINI: + return syscall_disestablish(&emul_netbsd32, + compat_sysvipc_10_syscalls); + + default: + return ENOTTY; + } +} + +#endif /* COMPAT_10 */ Index: src/sys/compat/netbsd32/netbsd32_compat_14_sysv.c diff -u /dev/null src/sys/compat/netbsd32/netbsd32_compat_14_sysv.c:1.1.2.1 --- /dev/null Wed Sep 12 04:35:23 2018 +++ src/sys/compat/netbsd32/netbsd32_compat_14_sysv.c Wed Sep 12 04:35:22 2018 @@ -0,0 +1,367 @@ +/* $NetBSD: netbsd32_compat_14_sysv.c,v 1.1.2.1 2018/09/12 04:35:22 pgoyette Exp $ */ + +/* + * Copyright (c) 1999 Eduardo E. Horvath + * All rights reserved. + * + * 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. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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: netbsd32_compat_14_sysv.c,v 1.1.2.1 2018/09/12 04:35:22 pgoyette Exp $"); + +#ifdef _KERNEL_OPT +#include "opt_sysv.h" +#include "opt_compat_netbsd.h" +#endif + +#include <sys/param.h> +#include <sys/ipc.h> +#include <sys/systm.h> +#include <sys/module.h> +#include <sys/signal.h> +#include <sys/proc.h> +#include <sys/mount.h> +#include <sys/msg.h> +#include <sys/sem.h> +#include <sys/shm.h> + +#include <sys/syscallargs.h> +#include <sys/syscallvar.h> + +#include <compat/netbsd32/netbsd32.h> +#include <compat/netbsd32/netbsd32_syscall.h> +#include <compat/netbsd32/netbsd32_syscallargs.h> +#include <compat/sys/siginfo.h> +#include <compat/sys/shm.h> + +#if defined(COMPAT_14) + +#if defined(SYSVMSG) +static inline void +netbsd32_ipc_perm14_to_native(struct netbsd32_ipc_perm14 *operm, struct ipc_perm *perm) +{ + +#define CVT(x) perm->x = operm->x + CVT(uid); + CVT(gid); + CVT(cuid); + CVT(cgid); + CVT(mode); +#undef CVT +} + +static inline void +native_to_netbsd32_ipc_perm14(struct ipc_perm *perm, struct netbsd32_ipc_perm14 *operm) +{ + +#define CVT(x) operm->x = perm->x + CVT(uid); + CVT(gid); + CVT(cuid); + CVT(cgid); + CVT(mode); +#undef CVT + + /* + * Not part of the API, but some programs might look at it. + */ + operm->seq = perm->_seq; + operm->key = (key_t)perm->_key; +} + +static inline void +netbsd32_msqid_ds14_to_native(struct netbsd32_msqid_ds14 *omsqbuf, struct msqid_ds *msqbuf) +{ + + netbsd32_ipc_perm14_to_native(&omsqbuf->msg_perm, &msqbuf->msg_perm); + +#define CVT(x) msqbuf->x = omsqbuf->x + CVT(msg_qnum); + CVT(msg_qbytes); + CVT(msg_lspid); + CVT(msg_lrpid); + CVT(msg_stime); + CVT(msg_rtime); + CVT(msg_ctime); +#undef CVT +} + +static inline void +native_to_netbsd32_msqid_ds14(struct msqid_ds *msqbuf, struct netbsd32_msqid_ds14 *omsqbuf) +{ + + native_to_netbsd32_ipc_perm14(&msqbuf->msg_perm, &omsqbuf->msg_perm); + +#define CVT(x) omsqbuf->x = msqbuf->x + CVT(msg_qnum); + CVT(msg_qbytes); + CVT(msg_lspid); + CVT(msg_lrpid); + CVT(msg_stime); + CVT(msg_rtime); + CVT(msg_ctime); +#undef CVT + + /* + * Not part of the API, but some programs might look at it. + */ + omsqbuf->msg_cbytes = msqbuf->_msg_cbytes; +} +#endif + +#if defined(SYSVSEM) +static inline void +netbsd32_semid_ds14_to_native(struct netbsd32_semid_ds14 *osembuf, struct semid_ds *sembuf) +{ + + netbsd32_ipc_perm14_to_native(&osembuf->sem_perm, &sembuf->sem_perm); + +#define CVT(x) sembuf->x = osembuf->x + CVT(sem_nsems); + CVT(sem_otime); + CVT(sem_ctime); +#undef CVT +} + +static inline void +native_to_netbsd32_semid_ds14(struct semid_ds *sembuf, struct netbsd32_semid_ds14 *osembuf) +{ + + native_to_netbsd32_ipc_perm14(&sembuf->sem_perm, &osembuf->sem_perm); + +#define CVT(x) osembuf->x = sembuf->x + CVT(sem_nsems); + CVT(sem_otime); + CVT(sem_ctime); +#undef CVT +} + +static inline void +netbsd32_shmid_ds14_to_native(struct netbsd32_shmid_ds14 *oshmbuf, struct shmid_ds *shmbuf) +{ + + netbsd32_ipc_perm14_to_native(&oshmbuf->shm_perm, &shmbuf->shm_perm); + +#define CVT(x) shmbuf->x = oshmbuf->x + CVT(shm_segsz); + CVT(shm_lpid); + CVT(shm_cpid); + CVT(shm_nattch); + CVT(shm_atime); + CVT(shm_dtime); + CVT(shm_ctime); +#undef CVT +} + +static inline void +native_to_netbsd32_shmid_ds14(struct shmid_ds *shmbuf, struct netbsd32_shmid_ds14 *oshmbuf) +{ + + native_to_netbsd32_ipc_perm14(&shmbuf->shm_perm, &oshmbuf->shm_perm); + +#define CVT(x) oshmbuf->x = shmbuf->x + CVT(shm_segsz); + CVT(shm_lpid); + CVT(shm_cpid); + CVT(shm_nattch); + CVT(shm_atime); + CVT(shm_dtime); + CVT(shm_ctime); +#undef CVT +} + +/* + * the compat_14 system calls + */ +int +compat_14_netbsd32_msgctl(struct lwp *l, const struct compat_14_netbsd32_msgctl_args *uap, register_t *retval) +{ + /* { + syscallarg(int) msqid; + syscallarg(int) cmd; + syscallarg(struct msqid_ds14 *) buf; + } */ + struct msqid_ds msqbuf; + struct netbsd32_msqid_ds14 omsqbuf; + int cmd, error; + + cmd = SCARG(uap, cmd); + + if (cmd == IPC_SET) { + error = copyin(SCARG_P32(uap, buf), + &omsqbuf, sizeof(omsqbuf)); + if (error) + return (error); + netbsd32_msqid_ds14_to_native(&omsqbuf, &msqbuf); + } + + error = msgctl1(l, SCARG(uap, msqid), cmd, + (cmd == IPC_SET || cmd == IPC_STAT) ? &msqbuf : NULL); + + if (error == 0 && cmd == IPC_STAT) { + native_to_netbsd32_msqid_ds14(&msqbuf, &omsqbuf); + error = copyout(&omsqbuf, + SCARG_P32(uap, buf), sizeof(omsqbuf)); + } + + return (error); +} +#endif + +#if defined(SYSVSEM) +int +compat_14_netbsd32___semctl(struct lwp *l, const struct compat_14_netbsd32___semctl_args *uap, register_t *retval) +{ + /* { + syscallarg(int) semid; + syscallarg(int) semnum; + syscallarg(int) cmd; + syscallarg(union __semun *) arg; + } */ + union __semun arg; + struct semid_ds sembuf; + struct netbsd32_semid_ds14 osembuf; + int cmd, error; + void *pass_arg = NULL; + + cmd = SCARG(uap, cmd); + + switch (cmd) { + case IPC_SET: + case IPC_STAT: + pass_arg = &sembuf; + break; + + case GETALL: + case SETVAL: + case SETALL: + pass_arg = &arg; + break; + } + + if (pass_arg != NULL) { + error = copyin(NETBSD32IPTR64(SCARG(uap, arg)), &arg, + sizeof(arg)); + if (error) + return (error); + if (cmd == IPC_SET) { + error = copyin(arg.buf, &osembuf, sizeof(osembuf)); + if (error) + return (error); + netbsd32_semid_ds14_to_native(&osembuf, &sembuf); + } + } + + error = semctl1(l, SCARG(uap, semid), SCARG(uap, semnum), cmd, + pass_arg, retval); + + if (error == 0 && cmd == IPC_STAT) { + native_to_netbsd32_semid_ds14(&sembuf, &osembuf); + error = copyout(&osembuf, arg.buf, sizeof(osembuf)); + } + + return (error); +} +#endif + +#if defined(SYSVSHM) +int +compat_14_netbsd32_shmctl(struct lwp *l, const struct compat_14_netbsd32_shmctl_args *uap, register_t *retval) +{ + /* { + syscallarg(int) shmid; + syscallarg(int) cmd; + syscallarg(struct netbsd32_shmid_ds14 *) buf; + } */ + struct shmid_ds shmbuf; + struct netbsd32_shmid_ds14 oshmbuf; + int cmd, error; + + cmd = SCARG(uap, cmd); + + if (cmd == IPC_SET) { + error = copyin(SCARG_P32(uap, buf), &oshmbuf, sizeof(oshmbuf)); + if (error) + return (error); + netbsd32_shmid_ds14_to_native(&oshmbuf, &shmbuf); + } + + error = shmctl1(l, SCARG(uap, shmid), cmd, + (cmd == IPC_SET || cmd == IPC_STAT) ? &shmbuf : NULL); + + if (error == 0 && cmd == IPC_STAT) { + native_to_netbsd32_shmid_ds14(&shmbuf, &oshmbuf); + error = copyout(&oshmbuf, SCARG_P32(uap, buf), sizeof(oshmbuf)); + } + + return (error); +} +#endif + +#define REQ1 "sysv_ipc,compat_sysv_14," +#define REQ2 "compat_netbsd32,compat_netbsd32_sysvipc," +#define REQ3 "compat_netbsd32_sysvipc_50" + +#define _PKG_ENTRY(name) \ + { NETBSD32_SYS_ ## name, 0, (sy_call_t *)name } + +static const struct syscall_package compat_sysvipc_14_syscalls[] = { +#if defined(SYSVSEM) + _PKG_ENTRY(compat_14_netbsd32___semctl), +#endif +#if defined(SYSVSHM) + _PKG_ENTRY(compat_14_netbsd32_shmctl), +#endif +#if defined(SYSVMSG) + _PKG_ENTRY(compat_14_netbsd32_msgctl), +#endif + { 0, 0, NULL } +}; + +#define REQ1 "sysv_ipc,compat_sysv_14," +#define REQ2 "compat_netbsd32,compat_netbsd32_sysvipc," +#define REQ3 "compat_netbsd32_sysvipc_50" + +MODULE(MODULE_CLASS_EXEC, compat_netbsd32_sysvipc_14, REQ1 REQ2 REQ3 ); + +static int +compat_netbsd32_sysvipc_14_modcmd(modcmd_t cmd, void *arg) +{ + + switch (cmd) { + case MODULE_CMD_INIT: + return syscall_establish(&emul_netbsd32, + compat_sysvipc_14_syscalls); + + case MODULE_CMD_FINI: + return syscall_disestablish(&emul_netbsd32, + compat_sysvipc_14_syscalls); + + default: + return ENOTTY; + } +} + +#endif /* COMPAT_14 */