From 4744ebcef48b2400d76ce5a2de735d8e74ebfe52 Mon Sep 17 00:00:00 2001 From: Lucas De Marchi Date: Thu, 15 Mar 2012 00:14:35 -0300 Subject: [PATCH] modprobe: don't check if module builtin to decide if it's builtin More or less confusing message, but if module is builtin in the live system, it doesn't mean it's builtin in the target kernel. Instead we now check if module has a path. It don't have a path only if it's builtin in the target or if it doesn't exist at all. The latter should not be a problem since this code is being called from inside the library. Anyway, put an assert to make sure we get bug reports if any case slipped in here. --- tools/kmod-modprobe.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/tools/kmod-modprobe.c b/tools/kmod-modprobe.c index 55f37956..3ab2a1ca 100644 --- a/tools/kmod-modprobe.c +++ b/tools/kmod-modprobe.c @@ -17,6 +17,7 @@ * along with this program. If not, see . */ +#include #include #include #include @@ -538,13 +539,21 @@ static int handle_failed_lookup(struct kmod_ctx *ctx, const char *alias) static void print_action(struct kmod_module *m, bool install, const char *options) { - if (install) + const char *path; + + if (install) { printf("install %s %s\n", kmod_module_get_install_commands(m), options); - else - kmod_module_get_initstate(m) == KMOD_MODULE_BUILTIN - ? printf("builtin %s\n", kmod_module_get_name(m)) - : printf("insmod %s %s\n", kmod_module_get_path(m), options); + return; + } + + path = kmod_module_get_path(m); + + if (path == NULL) { + assert(kmod_module_get_initstate(m) == KMOD_MODULE_BUILTIN); + printf("builtin %s\n", kmod_module_get_name(m)); + } else + printf("insmod %s %s\n", kmod_module_get_path(m), options); } static int insmod(struct kmod_ctx *ctx, const char *alias, -- 2.47.2