X-Git-Url: https://git.saurik.com/apple/system_cmds.git/blobdiff_plain/1c51fdde6f257ffe2a1b92d1a783dab947211e95..c03df0e9b5e00ac087fc7c53f812f6d1dd92f2a8:/kmodload.tproj/kmodload.c diff --git a/kmodload.tproj/kmodload.c b/kmodload.tproj/kmodload.c index 4108282..7d817b6 100644 --- a/kmodload.tproj/kmodload.c +++ b/kmodload.tproj/kmodload.c @@ -51,7 +51,7 @@ */ #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 @@ -75,6 +75,7 @@ static const char rcsid[] = #include #include "kld_patch.h" +#include "vers_rsrc.h" #define KMOD_ERROR_USAGE 1 #define KMOD_ERROR_PERMS 2 @@ -174,6 +175,9 @@ main(int argc, char** argv) 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 @@ -290,7 +294,6 @@ main(int argc, char** argv) } 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); @@ -310,6 +313,9 @@ main(int argc, char** argv) 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 @@ -430,7 +436,25 @@ link_base(const char *base, 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'.", @@ -675,10 +699,13 @@ start_module(kmod_t id) 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, ...) @@ -698,11 +725,14 @@ 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 @@ -721,10 +751,6 @@ static void abort_load(int exitcode, const char *fmt, ...) __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); }