- Put in place module compatibility check against __NetBSD_Version__,
as discussed on tech-kern. - Remove unused module_jettison().
This commit is contained in:
parent
eeabda7de2
commit
4c57df4a3c
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: init_main.c,v 1.357 2008/05/28 13:35:32 ad Exp $ */
|
||||
/* $NetBSD: init_main.c,v 1.358 2008/05/31 20:14:38 ad Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2008 The NetBSD Foundation, Inc.
|
||||
@ -97,7 +97,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: init_main.c,v 1.357 2008/05/28 13:35:32 ad Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: init_main.c,v 1.358 2008/05/31 20:14:38 ad Exp $");
|
||||
|
||||
#include "opt_ipsec.h"
|
||||
#include "opt_ntp.h"
|
||||
@ -583,7 +583,6 @@ main(void)
|
||||
* storage to the VM system.
|
||||
*/
|
||||
module_init_class(MODULE_CLASS_ANY);
|
||||
module_jettison();
|
||||
|
||||
/*
|
||||
* Finalize configuration now that all real devices have been
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: kern_module.c,v 1.20 2008/05/20 19:20:38 ad Exp $ */
|
||||
/* $NetBSD: kern_module.c,v 1.21 2008/05/31 20:14: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.20 2008/05/20 19:20:38 ad Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: kern_module.c,v 1.21 2008/05/31 20:14:38 ad Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
@ -162,15 +162,23 @@ module_init_class(modclass_t class)
|
||||
}
|
||||
|
||||
/*
|
||||
* module_jettison:
|
||||
* module_compatible:
|
||||
*
|
||||
* Return memory used by pre-loaded modules to the freelist.
|
||||
* Return true if the two supplied kernel versions are said to
|
||||
* have the same binary interface for kernel code. The entire
|
||||
* version is signficant for the development tree (-current),
|
||||
* major and minor versions are significant for official
|
||||
* releases of the system.
|
||||
*/
|
||||
void
|
||||
module_jettison(void)
|
||||
static bool
|
||||
module_compatible(int v1, int v2)
|
||||
{
|
||||
|
||||
/* XXX nothing yet */
|
||||
#if __NetBSD_Version__ / 1000000 % 100 == 99 /* -current */
|
||||
return v1 == v2;
|
||||
#else /* release */
|
||||
return abs(v1 - v2) < 10000;
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
@ -480,6 +488,11 @@ module_do_load(const char *filename, bool isdep, int flags,
|
||||
module_error("module name too long");
|
||||
goto fail;
|
||||
}
|
||||
if (!module_compatible(mi->mi_version, __NetBSD_Version__)) {
|
||||
error = EPROGMISMATCH;
|
||||
module_error("module built for different version of system");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
/*
|
||||
* If a specific kind of module was requested, ensure that we have
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: module.h,v 1.7 2008/05/20 19:20:38 ad Exp $ */
|
||||
/* $NetBSD: module.h,v 1.8 2008/05/31 20:14:38 ad Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2008 The NetBSD Foundation, Inc.
|
||||
@ -63,7 +63,7 @@ typedef enum modcmd {
|
||||
|
||||
/* Module header structure. */
|
||||
typedef struct modinfo {
|
||||
u_int mi_release;
|
||||
u_int mi_version;
|
||||
modclass_t mi_class;
|
||||
int (*mi_modcmd)(modcmd_t, void *);
|
||||
const char *mi_name;
|
||||
@ -96,7 +96,7 @@ typedef struct module {
|
||||
#define MODULE(class, name, required) \
|
||||
static int name##_modcmd(modcmd_t, void *); \
|
||||
static const modinfo_t name##_modinfo = { \
|
||||
.mi_release = __NetBSD_Version__, \
|
||||
.mi_version = __NetBSD_Version__, \
|
||||
.mi_class = (class), \
|
||||
.mi_modcmd = name##_modcmd, \
|
||||
.mi_name = #name, \
|
||||
@ -115,7 +115,6 @@ void module_init(void);
|
||||
void module_init_md(void);
|
||||
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, bool);
|
||||
int module_unload(const char *);
|
||||
|
Loading…
Reference in New Issue
Block a user