From: Dave Reisner Date: Tue, 31 Jan 2012 01:57:36 +0000 (-0500) Subject: modprobe: properly handle errors from init_module X-Git-Tag: v5~24 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=297a3182e487818508f718a04349ec07630346a1;p=thirdparty%2Fkmod.git modprobe: properly handle errors from init_module Effectively catch and the zero and non-zero cases and error out appropriately. Note that -EEXIST will only ever be returned when KMOD_PROBE_STOP_ON_ALREADY_LOADED is set as a probe_insert_module flag. --- diff --git a/tools/kmod-modprobe.c b/tools/kmod-modprobe.c index 764b8bf2..94500cf6 100644 --- a/tools/kmod-modprobe.c +++ b/tools/kmod-modprobe.c @@ -590,10 +590,21 @@ static int insmod(struct kmod_ctx *ctx, const char *alias, extra_options, NULL, NULL, show); } - if (err == KMOD_PROBE_STOP_ON_ALREADY_LOADED) { - ERR("Module %s already in kernel.\n", - kmod_module_get_name(mod)); - err = -EEXIST; + if (err >= 0) + /* ignore flag return values such as a mod being blacklisted */ + err = 0; + else { + switch (err) { + case -EEXIST: + ERR("could not insert '%s': Module already in kernel\n", + kmod_module_get_name(mod)); + break; + default: + ERR("could not insert '%s': %s\n", + kmod_module_get_name(mod), + strerror(-err)); + break; + } } kmod_module_unref(mod);