Module Name: src
Committed By: martin
Date: Fri Jun 19 14:24:00 UTC 2015
Modified Files:
src/sys/kern: sys_module.c
src/sys/sys: module.h
Log Message:
Make handle_modctl_load() usable from compat/netbsd32.
To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/sys/kern/sys_module.c
cvs rdiff -u -r1.36 -r1.37 src/sys/sys/module.h
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/kern/sys_module.c
diff -u src/sys/kern/sys_module.c:1.17 src/sys/kern/sys_module.c:1.18
--- src/sys/kern/sys_module.c:1.17 Thu Jul 10 21:13:52 2014
+++ src/sys/kern/sys_module.c Fri Jun 19 14:23:59 2015
@@ -1,4 +1,4 @@
-/* $NetBSD: sys_module.c,v 1.17 2014/07/10 21:13:52 christos Exp $ */
+/* $NetBSD: sys_module.c,v 1.18 2015/06/19 14:23:59 martin Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sys_module.c,v 1.17 2014/07/10 21:13:52 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sys_module.c,v 1.18 2015/06/19 14:23:59 martin Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -51,8 +51,9 @@ __KERNEL_RCSID(0, "$NetBSD: sys_module.c
*/
#define MAXPROPSLEN 4096
-static int
-handle_modctl_load(modctl_load_t *ml)
+int
+handle_modctl_load(const char *ml_filename, int ml_flags, const char *ml_props,
+ size_t ml_propslen)
{
char *path;
char *props;
@@ -60,22 +61,22 @@ handle_modctl_load(modctl_load_t *ml)
prop_dictionary_t dict;
size_t propslen = 0;
- if ((ml->ml_props != NULL && ml->ml_propslen == 0) ||
- (ml->ml_props == NULL && ml->ml_propslen > 0)) {
+ if ((ml_props != NULL && ml_propslen == 0) ||
+ (ml_props == NULL && ml_propslen > 0)) {
return EINVAL;
}
path = PNBUF_GET();
- error = copyinstr(ml->ml_filename, path, MAXPATHLEN, NULL);
+ error = copyinstr(ml_filename, path, MAXPATHLEN, NULL);
if (error != 0)
goto out1;
- if (ml->ml_props != NULL) {
- if (ml->ml_propslen > MAXPROPSLEN) {
+ if (ml_props != NULL) {
+ if (ml_propslen > MAXPROPSLEN) {
error = ENOMEM;
goto out1;
}
- propslen = ml->ml_propslen + 1;
+ propslen = ml_propslen + 1;
props = kmem_alloc(propslen, KM_SLEEP);
if (props == NULL) {
@@ -83,7 +84,7 @@ handle_modctl_load(modctl_load_t *ml)
goto out1;
}
- error = copyinstr(ml->ml_props, props, propslen, NULL);
+ error = copyinstr(ml_props, props, propslen, NULL);
if (error != 0)
goto out2;
@@ -97,7 +98,7 @@ handle_modctl_load(modctl_load_t *ml)
props = NULL;
}
- error = module_load(path, ml->ml_flags, dict, MODULE_CLASS_ANY);
+ error = module_load(path, ml_flags, dict, MODULE_CLASS_ANY);
if (dict != NULL) {
prop_object_release(dict);
@@ -142,7 +143,8 @@ sys_modctl(struct lwp *l, const struct s
error = copyin(arg, &ml, sizeof(ml));
if (error != 0)
break;
- error = handle_modctl_load(&ml);
+ error = handle_modctl_load(ml.ml_filename, ml.ml_flags,
+ ml.ml_props, ml.ml_propslen);
break;
case MODCTL_UNLOAD:
Index: src/sys/sys/module.h
diff -u src/sys/sys/module.h:1.36 src/sys/sys/module.h:1.37
--- src/sys/sys/module.h:1.36 Sat Mar 7 03:19:06 2015
+++ src/sys/sys/module.h Fri Jun 19 14:23:59 2015
@@ -1,4 +1,4 @@
-/* $NetBSD: module.h,v 1.36 2015/03/07 03:19:06 christos Exp $ */
+/* $NetBSD: module.h,v 1.37 2015/06/19 14:23:59 martin Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -228,4 +228,10 @@ typedef struct modstat {
int modctl(int, void *);
+#ifdef _KERNEL
+/* attention: pointers passed are userland pointers!,
+ see modctl_load_t */
+int handle_modctl_load(const char *, int, const char *, size_t);
+#endif
+
#endif /* !_SYS_MODULE_H_ */