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.
This commit is contained in:
Dave Reisner 2012-01-30 20:57:36 -05:00 committed by Lucas De Marchi
parent 7aed46088e
commit 297a3182e4

View File

@ -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);