*/
#ifndef lint
static const char rcsid[] =
- "$Id: kmodload.c,v 1.10 2001/08/02 20:57:01 lindak Exp $";
+ "$Id: kmodload.c,v 1.14 2002/04/15 20:28:30 lindak Exp $";
#endif /* not lint */
#include <stdlib.h>
#include <CoreFoundation/CoreFoundation.h>
#include "kld_patch.h"
+#include "vers_rsrc.h"
#define KMOD_ERROR_USAGE 1
#define KMOD_ERROR_PERMS 2
kmodsyms = !strcmp(progname, kKmodsymsName);
+ fprintf(stderr, "%s is deprecated; use kextload(8) instead\n", progname);
+ sleep(5);
+
// XXX things to add:
// -p data string to send as outofband data on start
// -P data file to send as outofband data on start
}
map_and_patch(kernel, dependencies, module_path);
- if (debugdumpfile) kld_file_debug_dump(module_path, debugdumpfile);
// Tell the kld linker where to get its load address from
kld_address_func(linkedit_address);
rld_header = link_module(module_path, gdbfile);
module_info = update_kmod_info(rld_header);
+ if (debugdumpfile)
+ kld_file_debug_dump(module_path, debugdumpfile);
+
if (kmodsyms) return 0;
// we need the priv port to load modules into the kernel
k = loaded_modules;
while (k) {
if (!strcmp(k->name, file_kinfo->name)) {
- if (strcmp(k->version, file_kinfo->version)) {
+ UInt32 kernel_kmod_version;
+ UInt32 file_kmod_version;
+
+ if (!VERS_parse_string(k->version, &kernel_kmod_version)) {
+ e_printf("can't parse version string \"%s\" in kernel kmod",
+ k->version);
+ abort_load(KMOD_ERROR_LOADING,
+ "can't parse kernel kmod version string \"%s\"", k->version);
+ }
+
+ if (!VERS_parse_string(file_kinfo->version, & file_kmod_version)) {
+ e_printf("can't parse version string \"%s\" in kmod file %s",
+ file_kinfo->version, *dependency);
+ abort_load(KMOD_ERROR_LOADING,
+ "can't parse version string \"%s\" in kmod file %s",
+ file_kinfo->version, *dependency);
+ }
+
+ if (kernel_kmod_version != file_kmod_version) {
e_printf("loaded kernel module '%s' version differs.", *dependency);
abort_load(KMOD_ERROR_LOADING,
"loaded version '%s', file version '%s'.",
static void e_printf(const char *fmt, ...)
{
va_list ap;
+ char msg[1024];
va_start(ap, fmt);
- kld_error_vprintf(fmt, ap);
+ vsnprintf(msg, sizeof(msg), fmt, ap);
va_end(ap);
+
+ fprintf(stderr, "%s: %s\n", progname, msg);
}
static void v_printf(const char *fmt, ...)
static void abort_load(int exitcode, const char *fmt, ...)
{
if (fmt) {
- va_list ap;
-
- va_start(ap, fmt);
- kld_error_vprintf(fmt, ap);
- va_end(ap);
+ va_list ap;
+ char msg[1024];
+
+ va_start(ap, fmt);
+ vsnprintf(msg, sizeof(msg), fmt, ap);
+ va_end(ap);
+
+ fprintf(stderr, "%s: %s\n", progname, msg);
}
if (!faked_kernel_load_address
__private_extern__ void
kld_error_vprintf(const char *fmt, va_list ap)
{
- char msg[1024];
-
- vsnprintf(msg, sizeof(msg), fmt, ap);
- fprintf(stderr, "%s: %s", progname, msg);
-
+ vfprintf(stderr, fmt, ap);
fflush(stderr);
}