Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/pgoyette-compat]: src/sys More work on splitting the compat_netbsd32 module
details: https://anonhg.NetBSD.org/src/rev/3b963c7554b7
branches: pgoyette-compat
changeset: 830642:3b963c7554b7
user: pgoyette <pgoyette%NetBSD.org@localhost>
date: Mon Sep 10 22:50:51 2018 +0000
description:
More work on splitting the compat_netbsd32 module
diffstat:
sys/compat/netbsd32/netbsd32_compat_20.c | 10 +-
sys/compat/netbsd32/netbsd32_compat_50.c | 81 ++++++++++++-
sys/compat/netbsd32/netbsd32_compat_60.c | 32 ++++-
sys/compat/netbsd32/netbsd32_compat_80.c | 201 +++++++++++++++++++++++++++++++
sys/compat/netbsd32/netbsd32_mod.c | 7 +-
sys/compat/netbsd32/netbsd32_module.c | 123 ++----------------
sys/compat/netbsd32/syscalls.master | 166 +++++++++++++++----------
sys/modules/compat_netbsd32/Makefile | 4 +-
sys/modules/compat_netbsd32_50/Makefile | 13 ++
sys/modules/compat_netbsd32_60/Makefile | 13 ++
sys/modules/compat_netbsd32_80/Makefile | 13 ++
sys/sys/module.h | 7 +-
12 files changed, 481 insertions(+), 189 deletions(-)
diffs (truncated from 1186 to 300 lines):
diff -r 7ba536dec98c -r 3b963c7554b7 sys/compat/netbsd32/netbsd32_compat_20.c
--- a/sys/compat/netbsd32/netbsd32_compat_20.c Mon Sep 10 10:59:50 2018 +0000
+++ b/sys/compat/netbsd32/netbsd32_compat_20.c Mon Sep 10 22:50:51 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: netbsd32_compat_20.c,v 1.36.10.2 2018/09/10 10:49:09 pgoyette Exp $ */
+/* $NetBSD: netbsd32_compat_20.c,v 1.36.10.3 2018/09/10 22:50:51 pgoyette Exp $ */
/*
* Copyright (c) 1998, 2001 Matthew R. Green
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: netbsd32_compat_20.c,v 1.36.10.2 2018/09/10 10:49:09 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: netbsd32_compat_20.c,v 1.36.10.3 2018/09/10 22:50:51 pgoyette Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -220,6 +220,12 @@
}
static struct syscall_package compat_netbsd32_20_syscalls[] = {
+ { NETBSD32_SYS_statfs, 0,
+ (sy_call_t *)compat_20_netbsd32_statfs },
+ { NETBSD32_SYS_fstatfs, 0,
+ (sy_call_t *)compat_20_netbsd32_fstatfs },
+ { NETBSD32_SYS_fhstatfs, 0,
+ (sy_call_t *)compat_20_netbsd32_fhstatfs },
{ NETBSD32_SYS_getfsstat, 0,
(sy_call_t *)compat_20_netbsd32_getfsstat },
{ 0, 0, NULL }
diff -r 7ba536dec98c -r 3b963c7554b7 sys/compat/netbsd32/netbsd32_compat_50.c
--- a/sys/compat/netbsd32/netbsd32_compat_50.c Mon Sep 10 10:59:50 2018 +0000
+++ b/sys/compat/netbsd32/netbsd32_compat_50.c Mon Sep 10 22:50:51 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: netbsd32_compat_50.c,v 1.32 2015/12/03 10:38:21 pgoyette Exp $ */
+/* $NetBSD: netbsd32_compat_50.c,v 1.32.16.1 2018/09/10 22:50:51 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.c,v 1.32 2015/12/03 10:38:21 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: netbsd32_compat_50.c,v 1.32.16.1 2018/09/10 22:50:51 pgoyette Exp $");
#if defined(_KERNEL_OPT)
#include "opt_compat_netbsd.h"
@@ -44,6 +44,7 @@
#include <sys/param.h>
#include <sys/systm.h>
+#include <sys/module.h>
#include <sys/mount.h>
#include <sys/socket.h>
#include <sys/socketvar.h>
@@ -65,6 +66,7 @@
#include <sys/vfs_syscalls.h>
#include <compat/netbsd32/netbsd32.h>
+#include <compat/netbsd32/netbsd32_syscallvar.h>
#include <compat/netbsd32/netbsd32_syscallargs.h>
#include <compat/netbsd32/netbsd32_conv.h>
#include <compat/sys/mount.h>
@@ -924,4 +926,79 @@
return (compat_50_sys_quotactl(l, &ua, retval));
}
+static struct syscall_package compat_netbsd32_50_syscalls[] = {
+ { NETBSD32_SYS_mknod, 0,
+ (sy_call_t *)compat_50_netbsd32_mknod },
+ { NETBSD32_SYS_select, 0,
+ (sy_call_t *)compat_50_netbsd32_select },
+ { NETBSD32_SYS_gettimeofday, 0,
+ (sy_call_t *)compat_50_netbsd32_gettimeofday },
+ { NETBSD32_SYS_settimeofday, 0,
+ (sy_call_t *)compat_50_netbsd32_settimeofday },
+ { NETBSD32_SYS_utimes, 0,
+ (sy_call_t *)compat_50_netbsd32_utimes },
+ { NETBSD32_SYS_futimes, 0,
+ (sy_call_t *)compat_50_netbsd32_futimes },
+ { NETBSD32_SYS_adjtime, 0,
+ (sy_call_t *)compat_50_netbsd32_adjtime },
+ { NETBSD32_SYS_clock_gettime, 0,
+ (sy_call_t *)compat_50_netbsd32_clock_gettime },
+ { NETBSD32_SYS_clock_settime, 0,
+ (sy_call_t *)compat_50_netbsd32_clock_settime },
+ { NETBSD32_SYS_clock_getres, 0,
+ (sy_call_t *)compat_50_netbsd32_clock_getres },
+ { NETBSD32_SYS_timer_settime, 0,
+ (sy_call_t *)compat_50_netbsd32_timer_settime },
+ { NETBSD32_SYS_timer_gettime, 0,
+ (sy_call_t *)compat_50_netbsd32_timer_gettime },
+ { NETBSD32_SYS_nanosleep, 0,
+ (sy_call_t *)compat_50_netbsd32_nanosleep },
+ { NETBSD32_SYS_sigtimedwait, 0,
+ (sy_call_t *)compat_50_netbsd32___sigtimedwait },
+ { NETBSD32_SYS_lutimes, 0,
+ (sy_call_t *)compat_50_netbsd32_lutimes },
+ { NETBSD32_SYS__lwp_park, 0,
+ (sy_call_t *)compat_50_netbsd32__lwp_park },
+ { NETBSD32_SYS_kevent, 0,
+ (sy_call_t *)compat_50_netbsd32_kevent },
+ { NETBSD32_SYS_pselect, 0,
+ (sy_call_t *)compat_50_netbsd32_pselect },
+ { NETBSD32_SYS_pollts, 0,
+ (sy_call_t *)compat_50_netbsd32_pollts },
+ { NETBSD32_SYS___stat30, 0,
+ (sy_call_t *)compat_50_netbsd32___stat30 },
+ { NETBSD32_SYS___lstat30, 0,
+ (sy_call_t *)compat_50_netbsd32___lstat30 },
+ { NETBSD32_SYS___fstat30, 0,
+ (sy_call_t *)compat_50_netbsd32___fstat30 },
+ { NETBSD32_SYS___fhstat40, 0,
+ (sy_call_t *)compat_50_netbsd32___fhstat40 },
+ { NETBSD32_SYS_wait4, 0,
+ (sy_call_t *)compat_50_netbsd32_wait4 },
+ { NETBSD32_SYS_getrusage, 0,
+ (sy_call_t *)compat_50_netbsd32_getrusage },
+ { NETBSD32_SYS_setitimer, 0,
+ (sy_call_t *)compat_50_netbsd32_setitimer },
+ { NETBSD32_SYS_quotactl, 0,
+ (sy_call_t *)compat_50_netbsd32_quotactl },
+ { 0, 0, NULL }
+};
+
+MODULE(MODULE_CLASS_EXEC, compat_netbsd32_50, "compat_netbsd32,compat_50");
+
+static int
+compat_netbsd32_50_modcmd(modcmd_t cmd, void *arg)
+{
+
+ switch (cmd) {
+ MODULE_CMD_INIT:
+ return syscall_establish(NULL, compat_netbsd32_50_syscalls);
+
+ MODULE_CMD_FINI:
+ return syscall_disestablish(NULL, compat_netbsd32_50_syscalls);
+
+ default:
+ return ENOTTY;
+ }
+}
#endif /* COMPAT_50 */
diff -r 7ba536dec98c -r 3b963c7554b7 sys/compat/netbsd32/netbsd32_compat_60.c
--- a/sys/compat/netbsd32/netbsd32_compat_60.c Mon Sep 10 10:59:50 2018 +0000
+++ b/sys/compat/netbsd32/netbsd32_compat_60.c Mon Sep 10 22:50:51 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: netbsd32_compat_60.c,v 1.3 2017/12/06 04:12:25 christos Exp $ */
+/* $NetBSD: netbsd32_compat_60.c,v 1.3.2.1 2018/09/10 22:50:51 pgoyette Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -36,21 +36,22 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: netbsd32_compat_60.c,v 1.3 2017/12/06 04:12:25 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: netbsd32_compat_60.c,v 1.3.2.1 2018/09/10 22:50:51 pgoyette Exp $");
#include <sys/param.h>
#include <sys/systm.h>
+#include <sys/module.h>
#include <sys/time.h>
#include <sys/dirent.h>
#include <sys/lwp.h>
#include <sys/syscallargs.h>
#include <compat/netbsd32/netbsd32.h>
+#include <compat/netbsd32/netbsd32_syscallvar.h>
#include <compat/netbsd32/netbsd32_syscallargs.h>
#include <compat/netbsd32/netbsd32_conv.h>
-
int
compat_60_netbsd32__lwp_park(struct lwp *l,
const struct compat_60_netbsd32__lwp_park_args *uap, register_t *retval)
@@ -85,3 +86,28 @@
return lwp_park(CLOCK_REALTIME, TIMER_ABSTIME, tsp,
SCARG_P32(uap, hint));
}
+
+static struct syscall_package compat_netbsd32_60_syscalls[] = {
+ { NETBSD32_SYS__lwp_park, 0,
+ (sy_call_t *)compat_60_netbsd32__lwp_park },
+ { 0, 0, NULL }
+};
+
+
+MODULE(MODULE_CLASS_EXEC, compat_netbsd32_60, "compat_netbsd,compat_60");
+
+static int
+compat_netbsd32_60_modcmd(modcmd_t CMD, void *arg)
+{
+
+ switch (cmd) {
+ case MODULE_CMD_INIT:
+ return syscall_establish(NULL, compat_netbsd32_60_syscalls);
+
+ case MODULE_CMD_FINI:
+ return syscall_disestablish(NULL, compat_netbsd32_60_syscalls);
+
+ default:
+ return ENOTTY;
+ }
+}
diff -r 7ba536dec98c -r 3b963c7554b7 sys/compat/netbsd32/netbsd32_compat_80.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/compat/netbsd32/netbsd32_compat_80.c Mon Sep 10 22:50:51 2018 +0000
@@ -0,0 +1,201 @@
+/* $NetBSD: netbsd32_compat_80.c,v 1.1.2.1 2018/09/10 22:50:51 pgoyette Exp $ */
+
+/*-
+ * Copyright (c) 2008 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software developed for The NetBSD Foundation.
+ *
+ * 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: netbsd32_compat_80.c,v 1.1.2.1 2018/09/10 22:50:51 pgoyette Exp $");
+
+#include <sys/param.h>
+#include <sys/dirent.h>
+#include <sys/kauth.h>
+#include <sys/module.h>
+#include <sys/kobj.h>
+
+#include <compat/netbsd32/netbsd32.h>
+#include <compat/netbsd32/netbsd32_syscall.h>
+#include <compat/netbsd32/netbsd32_syscallargs.h>
+#include <compat/netbsd32/netbsd32_conv.h>
+
+#ifdef COMPAT_80
+static int
+modctl32_handle_ostat(int cmd, struct netbsd32_iovec *iov, void *arg)
+{
+ omodstat_t *oms, *omso;
+ modinfo_t *mi;
+ module_t *mod;
+ vaddr_t addr;
+ size_t size;
+ size_t omslen;
+ size_t used;
+ int error;
+ int omscnt;
+ bool stataddr;
+ const char *suffix = "...";
+
+ if (cmd != MODCTL_OSTAT)
+ return EINVAL;
+
+ /* If not privileged, don't expose kernel addresses. */
+ error = kauth_authorize_system(kauth_cred_get(), KAUTH_SYSTEM_MODULE,
+ 0, (void *)(uintptr_t)MODCTL_STAT, NULL, NULL);
+ stataddr = (error == 0);
+
+ kernconfig_lock();
+ omscnt = 0;
+ TAILQ_FOREACH(mod, &module_list, mod_chain) {
+ omscnt++;
+ mi = mod->mod_info;
+ }
+ TAILQ_FOREACH(mod, &module_builtins, mod_chain) {
+ omscnt++;
+ mi = mod->mod_info;
+ }
+ omslen = omscnt * sizeof(omodstat_t);
+ omso = kmem_zalloc(omslen, KM_SLEEP);
+ oms = omso;
+ TAILQ_FOREACH(mod, &module_list, mod_chain) {
+ mi = mod->mod_info;
+ strlcpy(oms->oms_name, mi->mi_name, sizeof(oms->oms_name));
+ if (mi->mi_required != NULL) {
+ used = strlcpy(oms->oms_required, mi->mi_required,
+ sizeof(oms->oms_required));
+ if (used >= sizeof(oms->oms_required)) {
Home |
Main Index |
Thread Index |
Old Index