Move all namei flags handling into kobj_load_file().
When I originally wrote this, I was going for maximum flexibility. However, after a private discussion with dholland@, I see how this will cause problems with the future world order of namei whenever that might be. At the moment, I don't need the extra flexibility, but if something comes up this may have to be revisited.
This commit is contained in:
parent
09d5d44150
commit
d73b80a12b
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: kern_module.c,v 1.44 2009/05/25 22:33:00 jnemeth Exp $ */
|
||||
/* $NetBSD: kern_module.c,v 1.45 2009/05/26 08:34:23 jnemeth Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2008 The NetBSD Foundation, Inc.
|
||||
@ -34,7 +34,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: kern_module.c,v 1.44 2009/05/25 22:33:00 jnemeth Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: kern_module.c,v 1.45 2009/05/26 08:34:23 jnemeth Exp $");
|
||||
|
||||
#ifdef _KERNEL_OPT
|
||||
#include "opt_ddb.h"
|
||||
@ -563,6 +563,7 @@ module_do_load(const char *name, bool isdep, int flags,
|
||||
const char *s, *p;
|
||||
int error;
|
||||
size_t len;
|
||||
bool nochroot;
|
||||
|
||||
KASSERT(mutex_owned(&module_lock));
|
||||
|
||||
@ -620,14 +621,15 @@ module_do_load(const char *name, bool isdep, int flags,
|
||||
}
|
||||
path = PNBUF_GET();
|
||||
if (!autoload) {
|
||||
nochroot = false;
|
||||
snprintf(path, MAXPATHLEN, "%s", name);
|
||||
error = kobj_load_file(&mod->mod_kobj, path, FOLLOW);
|
||||
error = kobj_load_file(&mod->mod_kobj, path, nochroot);
|
||||
}
|
||||
if (autoload || (error == ENOENT)) {
|
||||
nochroot = true;
|
||||
snprintf(path, MAXPATHLEN, "%s/%s/%s.kmod",
|
||||
module_base, name, name);
|
||||
error = kobj_load_file(&mod->mod_kobj, path,
|
||||
FOLLOW | NOCHROOT);
|
||||
error = kobj_load_file(&mod->mod_kobj, path, nochroot);
|
||||
}
|
||||
if (error != 0) {
|
||||
kmem_free(mod, sizeof(*mod));
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: subr_kobj.c,v 1.37 2009/05/25 22:33:00 jnemeth Exp $ */
|
||||
/* $NetBSD: subr_kobj.c,v 1.38 2009/05/26 08:34:23 jnemeth Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2008 The NetBSD Foundation, Inc.
|
||||
@ -63,7 +63,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: subr_kobj.c,v 1.37 2009/05/25 22:33:00 jnemeth Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: subr_kobj.c,v 1.38 2009/05/26 08:34:23 jnemeth Exp $");
|
||||
|
||||
#include "opt_modular.h"
|
||||
|
||||
@ -103,7 +103,7 @@ extern struct vm_map *module_map;
|
||||
* Load an object located in the file system.
|
||||
*/
|
||||
int
|
||||
kobj_load_file(kobj_t *kop, const char *path, const uint32_t flags)
|
||||
kobj_load_file(kobj_t *kop, const char *path, const bool nochroot)
|
||||
{
|
||||
struct nameidata nd;
|
||||
kauth_cred_t cred;
|
||||
@ -117,7 +117,8 @@ kobj_load_file(kobj_t *kop, const char *path, const uint32_t flags)
|
||||
return ENOMEM;
|
||||
}
|
||||
|
||||
NDINIT(&nd, LOOKUP, flags, UIO_SYSSPACE, path);
|
||||
NDINIT(&nd, LOOKUP, FOLLOW | (nochroot ? NOCHROOT : 0),
|
||||
UIO_SYSSPACE, path);
|
||||
error = vn_open(&nd, FREAD, 0);
|
||||
|
||||
if (error != 0) {
|
||||
@ -1105,7 +1106,7 @@ kobj_free(kobj_t ko, void *base, size_t size)
|
||||
#else /* MODULAR */
|
||||
|
||||
int
|
||||
kobj_load_file(kobj_t *kop, const char *name, const uint32_t flags)
|
||||
kobj_load_file(kobj_t *kop, const char *name, const bool nochroot)
|
||||
{
|
||||
|
||||
return ENOSYS;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: kobj.h,v 1.10 2009/05/25 22:33:00 jnemeth Exp $ */
|
||||
/* $NetBSD: kobj.h,v 1.11 2009/05/26 08:34:22 jnemeth 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 uint32_t);
|
||||
int kobj_load_file(kobj_t *, const char *, const bool);
|
||||
int kobj_load_mem(kobj_t *, void *, ssize_t);
|
||||
int kobj_affix(kobj_t, const char *);
|
||||
void kobj_unload(kobj_t);
|
||||
|
Loading…
Reference in New Issue
Block a user