If autoloading a module, don't consider the current working directory.
This commit is contained in:
parent
88435c0e48
commit
61270d54f1
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: kern_module.c,v 1.19 2008/05/20 19:16:07 ad Exp $ */
|
||||
/* $NetBSD: kern_module.c,v 1.20 2008/05/20 19:20:38 ad Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2008 The NetBSD Foundation, Inc.
|
||||
|
@ -33,7 +33,7 @@
|
|||
#include "opt_modular.h"
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: kern_module.c,v 1.19 2008/05/20 19:16:07 ad Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: kern_module.c,v 1.20 2008/05/20 19:20:38 ad Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
|
@ -66,7 +66,7 @@ __link_set_add_rodata(modules, module_dummy);
|
|||
|
||||
static module_t *module_lookup(const char *);
|
||||
static int module_do_load(const char *, bool, int, prop_dictionary_t,
|
||||
module_t **, modclass_t class);
|
||||
module_t **, modclass_t class, bool);
|
||||
static int module_do_unload(const char *);
|
||||
static void module_error(const char *, ...);
|
||||
static int module_do_builtin(const char *, module_t **);
|
||||
|
@ -154,7 +154,7 @@ module_init_class(modclass_t class)
|
|||
class != mi->mi_class)
|
||||
continue;
|
||||
module_do_load(mi->mi_name, false, 0, NULL, NULL,
|
||||
class);
|
||||
class, true);
|
||||
break;
|
||||
}
|
||||
} while (mod != NULL);
|
||||
|
@ -180,7 +180,7 @@ module_jettison(void)
|
|||
*/
|
||||
int
|
||||
module_load(const char *filename, int flags, prop_dictionary_t props,
|
||||
modclass_t class)
|
||||
modclass_t class, bool autoload)
|
||||
{
|
||||
int error;
|
||||
|
||||
|
@ -192,7 +192,8 @@ module_load(const char *filename, int flags, prop_dictionary_t props,
|
|||
}
|
||||
|
||||
mutex_enter(&module_lock);
|
||||
error = module_do_load(filename, false, flags, props, NULL, class);
|
||||
error = module_do_load(filename, false, flags, props, NULL, class,
|
||||
autoload);
|
||||
mutex_exit(&module_lock);
|
||||
|
||||
return error;
|
||||
|
@ -406,7 +407,8 @@ module_do_builtin(const char *name, module_t **modp)
|
|||
*/
|
||||
static int
|
||||
module_do_load(const char *filename, bool isdep, int flags,
|
||||
prop_dictionary_t props, module_t **modp, modclass_t class)
|
||||
prop_dictionary_t props, module_t **modp, modclass_t class,
|
||||
bool autoload)
|
||||
{
|
||||
static TAILQ_HEAD(,module) pending = TAILQ_HEAD_INITIALIZER(pending);
|
||||
static int depth;
|
||||
|
@ -453,7 +455,8 @@ module_do_load(const char *filename, bool isdep, int flags,
|
|||
depth--;
|
||||
return ENOMEM;
|
||||
}
|
||||
error = kobj_load_file(&mod->mod_kobj, filename, module_base);
|
||||
error = kobj_load_file(&mod->mod_kobj, filename, module_base,
|
||||
autoload);
|
||||
if (error != 0) {
|
||||
kmem_free(mod, sizeof(*mod));
|
||||
depth--;
|
||||
|
@ -553,7 +556,7 @@ module_do_load(const char *filename, bool isdep, int flags,
|
|||
}
|
||||
error = module_do_load(buf, true, flags, NULL,
|
||||
&mod->mod_required[mod->mod_nrequired++],
|
||||
MODULE_CLASS_ANY);
|
||||
MODULE_CLASS_ANY, true);
|
||||
if (error != 0 && error != EEXIST)
|
||||
goto fail;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: kern_runq.c,v 1.5 2008/05/19 17:06:02 ad Exp $ */
|
||||
/* $NetBSD: kern_runq.c,v 1.6 2008/05/20 19:20:38 ad Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2007, 2008 Mindaugas Rasiukevicius <rmind at NetBSD org>
|
||||
|
@ -27,7 +27,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: kern_runq.c,v 1.5 2008/05/19 17:06:02 ad Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: kern_runq.c,v 1.6 2008/05/20 19:20:38 ad Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/kernel.h>
|
||||
|
@ -417,33 +417,11 @@ sched_catchlwp(void)
|
|||
runqueue_t *ci_rq;
|
||||
struct lwp *l;
|
||||
|
||||
if (curci == ci)
|
||||
if (curci == ci || !mutex_tryenter(ci->ci_schedstate.spc_mutex))
|
||||
return NULL;
|
||||
|
||||
/* Lockless check */
|
||||
spc = &ci->ci_schedstate;
|
||||
ci_rq = spc->spc_sched_info;
|
||||
if (ci_rq->r_mcount < min_catch)
|
||||
return NULL;
|
||||
|
||||
/*
|
||||
* Double-lock the runqueues.
|
||||
*/
|
||||
if (curci < ci) {
|
||||
spc_lock(ci);
|
||||
} else if (!mutex_tryenter(ci->ci_schedstate.spc_mutex)) {
|
||||
const runqueue_t *cur_rq = curci->ci_schedstate.spc_sched_info;
|
||||
|
||||
spc_unlock(curci);
|
||||
spc_lock(ci);
|
||||
spc_lock(curci);
|
||||
|
||||
if (cur_rq->r_count) {
|
||||
spc_unlock(ci);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if (ci_rq->r_mcount < min_catch) {
|
||||
spc_unlock(ci);
|
||||
return NULL;
|
||||
|
@ -599,8 +577,6 @@ sched_nextlwp(void)
|
|||
/* Reset the counter, and call the balancer */
|
||||
ci_rq->r_avgcount = 0;
|
||||
sched_balance(ci);
|
||||
|
||||
/* The re-locking will be done inside */
|
||||
return sched_catchlwp();
|
||||
}
|
||||
#else
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: subr_kobj.c,v 1.20 2008/05/20 16:18:51 martin Exp $ */
|
||||
/* $NetBSD: subr_kobj.c,v 1.21 2008/05/20 19:20:38 ad Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2008 The NetBSD Foundation, Inc.
|
||||
|
@ -62,7 +62,7 @@
|
|||
#include "opt_modular.h"
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: subr_kobj.c,v 1.20 2008/05/20 16:18:51 martin Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: subr_kobj.c,v 1.21 2008/05/20 19:20:38 ad Exp $");
|
||||
|
||||
#define ELFSIZE ARCH_ELFSIZE
|
||||
|
||||
|
@ -159,7 +159,8 @@ extern struct vm_map *lkm_map;
|
|||
* Load an object located in the file system.
|
||||
*/
|
||||
int
|
||||
kobj_load_file(kobj_t *kop, const char *filename, const char *base)
|
||||
kobj_load_file(kobj_t *kop, const char *filename, const char *base,
|
||||
bool autoload)
|
||||
{
|
||||
struct nameidata nd;
|
||||
kauth_cred_t cred;
|
||||
|
@ -174,7 +175,7 @@ kobj_load_file(kobj_t *kop, const char *filename, const char *base)
|
|||
return ENOMEM;
|
||||
}
|
||||
|
||||
if (curproc == &proc0) {
|
||||
if (autoload) {
|
||||
error = ENOENT;
|
||||
} else {
|
||||
NDINIT(&nd, LOOKUP, FOLLOW, UIO_SYSSPACE, filename);
|
||||
|
@ -1107,7 +1108,7 @@ kobj_free(kobj_t ko, void *base, size_t size)
|
|||
#else /* MODULAR */
|
||||
|
||||
int
|
||||
kobj_load_file(kobj_t *kop, const char *name, const char *base)
|
||||
kobj_load_file(kobj_t *kop, const char *name, const char *base, bool autoload)
|
||||
{
|
||||
|
||||
return ENOSYS;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: sys_module.c,v 1.6 2008/05/20 17:24:56 ad Exp $ */
|
||||
/* $NetBSD: sys_module.c,v 1.7 2008/05/20 19:20:38 ad 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.6 2008/05/20 17:24:56 ad Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: sys_module.c,v 1.7 2008/05/20 19:20:38 ad Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
|
@ -82,7 +82,7 @@ handle_modctl_load(void *arg)
|
|||
goto out3;
|
||||
}
|
||||
|
||||
error = module_load(path, ml->ml_flags, dict, MODULE_CLASS_ANY);
|
||||
error = module_load(path, ml->ml_flags, dict, MODULE_CLASS_ANY, false);
|
||||
|
||||
prop_object_release(dict);
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: vfs_syscalls.c,v 1.361 2008/05/20 17:28:59 ad Exp $ */
|
||||
/* $NetBSD: vfs_syscalls.c,v 1.362 2008/05/20 19:20:38 ad Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2008 The NetBSD Foundation, Inc.
|
||||
|
@ -63,7 +63,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: vfs_syscalls.c,v 1.361 2008/05/20 17:28:59 ad Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: vfs_syscalls.c,v 1.362 2008/05/20 19:20:38 ad Exp $");
|
||||
|
||||
#include "opt_compat_netbsd.h"
|
||||
#include "opt_compat_43.h"
|
||||
|
@ -289,7 +289,7 @@ mount_get_vfsops(const char *fstype, struct vfsops **vfsops)
|
|||
return 0;
|
||||
|
||||
/* If we can autoload a vfs module, try again */
|
||||
if (module_load(fstype, 0, NULL, MODULE_CLASS_VFS) != 0)
|
||||
if (module_load(fstype, 0, NULL, MODULE_CLASS_VFS, true) != 0)
|
||||
return ENODEV;
|
||||
|
||||
if ((*vfsops = vfs_getopsbyname(fstypename)) != NULL)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: kobj.h,v 1.8 2008/05/20 14:11:55 ad Exp $ */
|
||||
/* $NetBSD: kobj.h,v 1.9 2008/05/20 19:20:38 ad Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2008 The NetBSD Foundation, Inc.
|
||||
|
@ -32,7 +32,7 @@
|
|||
typedef struct kobj *kobj_t;
|
||||
|
||||
/* External interface. */
|
||||
int kobj_load_file(kobj_t *, const char *, const char *);
|
||||
int kobj_load_file(kobj_t *, const char *, const char *, bool);
|
||||
int kobj_load_mem(kobj_t *, void *, ssize_t);
|
||||
int kobj_affix(kobj_t, const char *);
|
||||
void kobj_unload(kobj_t);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: module.h,v 1.6 2008/05/20 17:24:56 ad Exp $ */
|
||||
/* $NetBSD: module.h,v 1.7 2008/05/20 19:20:38 ad Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2008 The NetBSD Foundation, Inc.
|
||||
|
@ -117,7 +117,7 @@ void module_init_class(modclass_t);
|
|||
int module_prime(void *, size_t);
|
||||
void module_jettison(void);
|
||||
|
||||
int module_load(const char *, int, prop_dictionary_t, modclass_t);
|
||||
int module_load(const char *, int, prop_dictionary_t, modclass_t, bool);
|
||||
int module_unload(const char *);
|
||||
int module_hold(const char *);
|
||||
void module_rele(const char *);
|
||||
|
|
Loading…
Reference in New Issue