Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/compat/netbsd32 Implement modctl, sigqueinfo and mq_*
details: https://anonhg.NetBSD.org/src/rev/787a18608903
branches: trunk
changeset: 338973:787a18608903
user: martin <martin%NetBSD.org@localhost>
date: Sat Jun 20 19:58:40 2015 +0000
description:
Implement modctl, sigqueinfo and mq_*
diffstat:
sys/compat/netbsd32/files.netbsd32 | 4 +-
sys/compat/netbsd32/netbsd32.h | 21 +-
sys/compat/netbsd32/netbsd32_conv.h | 22 ++-
sys/compat/netbsd32/netbsd32_module.c | 172 +++++++++++++++++
sys/compat/netbsd32/netbsd32_mqueue.c | 328 ++++++++++++++++++++++++++++++++++
sys/compat/netbsd32/netbsd32_signal.c | 74 ++++---
6 files changed, 586 insertions(+), 35 deletions(-)
diffs (truncated from 745 to 300 lines):
diff -r dd9785393e65 -r 787a18608903 sys/compat/netbsd32/files.netbsd32
--- a/sys/compat/netbsd32/files.netbsd32 Sat Jun 20 19:56:24 2015 +0000
+++ b/sys/compat/netbsd32/files.netbsd32 Sat Jun 20 19:58:40 2015 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: files.netbsd32,v 1.34 2014/11/17 01:01:57 uebayasi Exp $
+# $NetBSD: files.netbsd32,v 1.35 2015/06/20 19:58:40 martin Exp $
#
# config file description for machine-independent netbsd32 compat code.
# included by ports that need it.
@@ -17,7 +17,9 @@
file compat/netbsd32/netbsd32_ioctl.c compat_netbsd32
file compat/netbsd32/netbsd32_ipc.c compat_netbsd32
file compat/netbsd32/netbsd32_lwp.c compat_netbsd32
+file compat/netbsd32/netbsd32_module.c compat_netbsd32
file compat/netbsd32/netbsd32_mod.c compat_netbsd32
+file compat/netbsd32/netbsd32_mqueue.c compat_netbsd32
file compat/netbsd32/netbsd32_select.c compat_netbsd32
file compat/netbsd32/netbsd32_sem.c compat_netbsd32
file compat/netbsd32/netbsd32_signal.c compat_netbsd32
diff -r dd9785393e65 -r 787a18608903 sys/compat/netbsd32/netbsd32.h
--- a/sys/compat/netbsd32/netbsd32.h Sat Jun 20 19:56:24 2015 +0000
+++ b/sys/compat/netbsd32/netbsd32.h Sat Jun 20 19:58:40 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: netbsd32.h,v 1.103 2014/10/05 20:17:28 christos Exp $ */
+/* $NetBSD: netbsd32.h,v 1.104 2015/06/20 19:58:40 martin Exp $ */
/*
* Copyright (c) 1998, 2001, 2008 Matthew R. Green
@@ -143,6 +143,7 @@
typedef netbsd32_pointer_t netbsd32_charpp;
typedef netbsd32_pointer_t netbsd32_size_tp;
typedef netbsd32_pointer_t netbsd32_intp;
+typedef netbsd32_pointer_t netbsd32_uintp;
typedef netbsd32_pointer_t netbsd32_longp;
typedef netbsd32_pointer_t netbsd32_caddrp;
typedef netbsd32_pointer_t netbsd32_caddr;
@@ -1000,6 +1001,21 @@
netbsd32_posix_spawn_file_actions_entryp fae;
};
+struct netbsd32_modctl_load {
+ netbsd32_charp ml_filename;
+ int ml_flags;
+ netbsd32_charp ml_props;
+ netbsd32_size_t ml_propslen;
+};
+
+struct netbsd32_mq_attr {
+ netbsd32_long mq_flags;
+ netbsd32_long mq_maxmsg;
+ netbsd32_long mq_msgsize;
+ netbsd32_long mq_curmsgs;
+};
+typedef netbsd32_pointer_t netbsd32_mq_attrp_t;
+
#if 0
int netbsd32_kevent(struct lwp *, void *, register_t *);
#endif
@@ -1039,7 +1055,8 @@
void netbsd32_adjust_limits(struct proc *);
void netbsd32_si_to_si32(siginfo32_t *, const siginfo_t *);
-void netbsd32_si32_to_si(siginfo_t *, const siginfo32_t *);
+void netbsd32_ksi32_to_ksi(struct _ksiginfo *si, const struct __ksiginfo32 *si32);
+
void startlwp32(void *);
struct compat_50_netbsd32___semctl14_args;
diff -r dd9785393e65 -r 787a18608903 sys/compat/netbsd32/netbsd32_conv.h
--- a/sys/compat/netbsd32/netbsd32_conv.h Sat Jun 20 19:56:24 2015 +0000
+++ b/sys/compat/netbsd32/netbsd32_conv.h Sat Jun 20 19:58:40 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: netbsd32_conv.h,v 1.28 2014/03/18 18:20:41 riastradh Exp $ */
+/* $NetBSD: netbsd32_conv.h,v 1.29 2015/06/20 19:58:40 martin Exp $ */
/*
* Copyright (c) 1998, 2001 Matthew R. Green
@@ -786,4 +786,24 @@
sizeof(struct netbsd32_plistref));
}
+static __inline void
+netbsd32_to_mq_attr(const struct netbsd32_mq_attr *a32,
+ struct mq_attr *attr)
+{
+ attr->mq_flags = a32->mq_flags;
+ attr->mq_maxmsg = a32->mq_maxmsg;
+ attr->mq_msgsize = a32->mq_msgsize;
+ attr->mq_curmsgs = a32->mq_curmsgs;
+}
+
+static __inline void
+netbsd32_from_mq_attr(const struct mq_attr *attr,
+ struct netbsd32_mq_attr *a32)
+{
+ a32->mq_flags = attr->mq_flags;
+ a32->mq_maxmsg = attr->mq_maxmsg;
+ a32->mq_msgsize = attr->mq_msgsize;
+ a32->mq_curmsgs = attr->mq_curmsgs;
+}
+
#endif /* _COMPAT_NETBSD32_NETBSD32_CONV_H_ */
diff -r dd9785393e65 -r 787a18608903 sys/compat/netbsd32/netbsd32_module.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/compat/netbsd32/netbsd32_module.c Sat Jun 20 19:58:40 2015 +0000
@@ -0,0 +1,172 @@
+/* $NetBSD: netbsd32_module.c,v 1.1 2015/06/20 19:58:40 martin 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_module.c,v 1.1 2015/06/20 19:58:40 martin Exp $");
+
+#include <sys/param.h>
+#include <sys/dirent.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>
+
+int
+netbsd32_modctl(struct lwp *lwp, const struct netbsd32_modctl_args *uap,
+ register_t *result)
+{
+ /* {
+ syscallarg(int) cmd;
+ syscallarg(netbsd32_voidp) arg;
+ } */
+ char buf[MAXMODNAME];
+ size_t mslen;
+ module_t *mod;
+ modinfo_t *mi;
+ modstat_t *ms, *mso;
+ vaddr_t addr;
+ size_t size;
+ struct netbsd32_iovec iov;
+ struct netbsd32_modctl_load ml;
+ int error;
+ void *arg;
+#ifdef MODULAR
+ uintptr_t loadtype;
+#endif
+
+ arg = SCARG_P32(uap, arg);
+
+ switch (SCARG(uap, cmd)) {
+ case MODCTL_LOAD:
+ error = copyin(arg, &ml, sizeof(ml));
+ if (error != 0)
+ break;
+ error = handle_modctl_load(NETBSD32PTR64(ml.ml_filename),
+ ml.ml_flags, NETBSD32PTR64(ml.ml_props), ml.ml_propslen);
+ break;
+
+ case MODCTL_UNLOAD:
+ error = copyinstr(arg, buf, sizeof(buf), NULL);
+ if (error == 0) {
+ error = module_unload(buf);
+ }
+ break;
+
+ case MODCTL_STAT:
+ error = copyin(arg, &iov, sizeof(iov));
+ if (error != 0) {
+ break;
+ }
+ kernconfig_lock();
+ mslen = (module_count+module_builtinlist+1) * sizeof(modstat_t);
+ mso = kmem_zalloc(mslen, KM_SLEEP);
+ if (mso == NULL) {
+ kernconfig_unlock();
+ return ENOMEM;
+ }
+ ms = mso;
+ TAILQ_FOREACH(mod, &module_list, mod_chain) {
+ mi = mod->mod_info;
+ strlcpy(ms->ms_name, mi->mi_name, sizeof(ms->ms_name));
+ if (mi->mi_required != NULL) {
+ strlcpy(ms->ms_required, mi->mi_required,
+ sizeof(ms->ms_required));
+ }
+ if (mod->mod_kobj != NULL) {
+ kobj_stat(mod->mod_kobj, &addr, &size);
+ ms->ms_addr = addr;
+ ms->ms_size = size;
+ }
+ ms->ms_class = mi->mi_class;
+ ms->ms_refcnt = mod->mod_refcnt;
+ ms->ms_source = mod->mod_source;
+ ms++;
+ }
+ TAILQ_FOREACH(mod, &module_builtins, mod_chain) {
+ mi = mod->mod_info;
+ strlcpy(ms->ms_name, mi->mi_name, sizeof(ms->ms_name));
+ if (mi->mi_required != NULL) {
+ strlcpy(ms->ms_required, mi->mi_required,
+ sizeof(ms->ms_required));
+ }
+ if (mod->mod_kobj != NULL) {
+ kobj_stat(mod->mod_kobj, &addr, &size);
+ ms->ms_addr = addr;
+ ms->ms_size = size;
+ }
+ ms->ms_class = mi->mi_class;
+ ms->ms_refcnt = -1;
+ KASSERT(mod->mod_source == MODULE_SOURCE_KERNEL);
+ ms->ms_source = mod->mod_source;
+ ms++;
+ }
+ kernconfig_unlock();
+ error = copyout(mso, NETBSD32PTR64(iov.iov_base),
+ min(mslen - sizeof(modstat_t), iov.iov_len));
+ kmem_free(mso, mslen);
+ if (error == 0) {
+ iov.iov_len = mslen - sizeof(modstat_t);
+ error = copyout(&iov, arg, sizeof(iov));
+ }
+ break;
+
+ case MODCTL_EXISTS:
+#ifndef MODULAR
+ error = ENOSYS;
+#else
+ loadtype = (uintptr_t)arg;
+ switch (loadtype) { /* 0 = modload, 1 = autoload */
+ case 0: /* FALLTHROUGH */
+ case 1:
+ error = kauth_authorize_system(kauth_cred_get(),
+ KAUTH_SYSTEM_MODULE, 0,
+ (void *)(uintptr_t)MODCTL_LOAD,
+ (void *)loadtype, NULL);
+ break;
+
+ default:
+ error = EINVAL;
+ break;
+ }
+#endif
+ break;
+
+ default:
+ error = EINVAL;
+ break;
+ }
+
+ return error;
+}
+
+
diff -r dd9785393e65 -r 787a18608903 sys/compat/netbsd32/netbsd32_mqueue.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/compat/netbsd32/netbsd32_mqueue.c Sat Jun 20 19:58:40 2015 +0000
@@ -0,0 +1,328 @@
+/* $NetBSD: netbsd32_mqueue.c,v 1.1 2015/06/20 19:58:40 martin 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
Home |
Main Index |
Thread Index |
Old Index