Make kobj_stat() return ENOSYS instead of panicking ("not modular")
on non-MODULAR kernels. Make a few kobj_stat() callers check for a non-zero return code and deal gracefully.
This commit is contained in:
parent
77578bbc3a
commit
61fa5bb9be
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: kern_module.c,v 1.48 2009/06/09 20:35:02 jnemeth Exp $ */
|
||||
/* $NetBSD: kern_module.c,v 1.49 2009/06/17 21:04:25 dyoung 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.48 2009/06/09 20:35:02 jnemeth Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: kern_module.c,v 1.49 2009/06/17 21:04:25 dyoung Exp $");
|
||||
|
||||
#ifdef _KERNEL_OPT
|
||||
#include "opt_ddb.h"
|
||||
|
@ -1072,7 +1072,8 @@ module_whatis(uintptr_t addr, void (*pr)(const char *, ...))
|
|||
if (mod->mod_kobj == NULL) {
|
||||
continue;
|
||||
}
|
||||
kobj_stat(mod->mod_kobj, &maddr, &msize);
|
||||
if (kobj_stat(mod->mod_kobj, &maddr, &msize) != 0)
|
||||
continue;
|
||||
if (addr < maddr || addr >= maddr + msize) {
|
||||
continue;
|
||||
}
|
||||
|
@ -1112,12 +1113,11 @@ module_print_list(void (*pr)(const char *, ...))
|
|||
src = "unknown";
|
||||
break;
|
||||
}
|
||||
if (mod->mod_kobj != NULL) {
|
||||
kobj_stat(mod->mod_kobj, &maddr, &msize);
|
||||
} else {
|
||||
if (mod->mod_kobj == NULL) {
|
||||
maddr = 0;
|
||||
msize = 0;
|
||||
}
|
||||
} else if (kobj_stat(mod->mod_kobj, &maddr, &msize) != 0)
|
||||
continue;
|
||||
(*pr)("%16s %16lx %8ld %8s\n", mod->mod_info->mi_name,
|
||||
(long)maddr, (long)msize, src);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: subr_kobj.c,v 1.38 2009/05/26 08:34:23 jnemeth Exp $ */
|
||||
/* $NetBSD: subr_kobj.c,v 1.39 2009/06/17 21:04:25 dyoung 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.38 2009/05/26 08:34:23 jnemeth Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: subr_kobj.c,v 1.39 2009/06/17 21:04:25 dyoung Exp $");
|
||||
|
||||
#include "opt_modular.h"
|
||||
|
||||
|
@ -622,7 +622,7 @@ kobj_unload(kobj_t ko)
|
|||
*
|
||||
* Return size and load address of an object.
|
||||
*/
|
||||
void
|
||||
int
|
||||
kobj_stat(kobj_t ko, vaddr_t *address, size_t *size)
|
||||
{
|
||||
|
||||
|
@ -632,6 +632,7 @@ kobj_stat(kobj_t ko, vaddr_t *address, size_t *size)
|
|||
if (size != NULL) {
|
||||
*size = ko->ko_size;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1126,11 +1127,11 @@ kobj_unload(kobj_t ko)
|
|||
panic("not modular");
|
||||
}
|
||||
|
||||
void
|
||||
int
|
||||
kobj_stat(kobj_t ko, vaddr_t *base, size_t *size)
|
||||
{
|
||||
|
||||
panic("not modular");
|
||||
return ENOSYS;
|
||||
}
|
||||
|
||||
int
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: kobj.h,v 1.11 2009/05/26 08:34:22 jnemeth Exp $ */
|
||||
/* $NetBSD: kobj.h,v 1.12 2009/06/17 21:04:25 dyoung Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2008 The NetBSD Foundation, Inc.
|
||||
|
@ -36,7 +36,7 @@ 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);
|
||||
void kobj_stat(kobj_t, vaddr_t *, size_t *);
|
||||
int kobj_stat(kobj_t, vaddr_t *, size_t *);
|
||||
int kobj_find_section(kobj_t, const char *, void **, size_t *);
|
||||
|
||||
/* MI-MD interface. */
|
||||
|
|
Loading…
Reference in New Issue