From: Lucas De Marchi Date: Thu, 15 Mar 2012 03:14:35 +0000 (-0300) Subject: modprobe: don't check if module builtin to decide if it's builtin X-Git-Tag: v7~9 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=4744ebcef48b2400d76ce5a2de735d8e74ebfe52;p=thirdparty%2Fkmod.git 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. --- 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,