|
|
c49cfb |
From 52a0ba82e1ad180f9f91920db70a758fac49466a Mon Sep 17 00:00:00 2001
|
|
|
c49cfb |
From: Yauheni Kaliuta <yauheni.kaliuta@redhat.com>
|
|
|
c49cfb |
Date: Thu, 31 Oct 2019 20:12:53 +0200
|
|
|
c49cfb |
Subject: [PATCH] modprobe: ignore builtin module on recursive removing
|
|
|
c49cfb |
|
|
|
c49cfb |
If there are built-in dependencies and any of them is built-in in
|
|
|
c49cfb |
the kernel, modprobe -r fails with
|
|
|
c49cfb |
|
|
|
c49cfb |
modprobe: FATAL: Module module_name is builtin.
|
|
|
c49cfb |
|
|
|
c49cfb |
It makes sense to ignore such dependencies for the case when
|
|
|
c49cfb |
removing is called for non-top level module.
|
|
|
c49cfb |
|
|
|
c49cfb |
Example: cifs module, it declares bunch of softdeps and the first
|
|
|
c49cfb |
one fails on some kernel configs:
|
|
|
c49cfb |
|
|
|
c49cfb |
modprobe: FATAL: Module gcm is builtin.
|
|
|
c49cfb |
|
|
|
c49cfb |
Signed-off-by: Yauheni Kaliuta <yauheni.kaliuta@redhat.com>
|
|
|
c49cfb |
---
|
|
|
c49cfb |
tools/modprobe.c | 18 ++++++++++++------
|
|
|
c49cfb |
1 file changed, 12 insertions(+), 6 deletions(-)
|
|
|
c49cfb |
|
|
|
c49cfb |
diff --git a/tools/modprobe.c b/tools/modprobe.c
|
|
|
c49cfb |
index a9e2331567af..44cd15c2bf57 100644
|
|
|
c49cfb |
--- a/tools/modprobe.c
|
|
|
c49cfb |
+++ b/tools/modprobe.c
|
|
|
c49cfb |
@@ -353,7 +353,8 @@ static int rmmod_do_remove_module(struct kmod_module *mod)
|
|
|
c49cfb |
return err;
|
|
|
c49cfb |
}
|
|
|
c49cfb |
|
|
|
c49cfb |
-static int rmmod_do_module(struct kmod_module *mod, bool do_dependencies);
|
|
|
c49cfb |
+static int rmmod_do_module(struct kmod_module *mod, bool do_dependencies,
|
|
|
c49cfb |
+ bool ignore_builtin);
|
|
|
c49cfb |
|
|
|
c49cfb |
static int rmmod_do_deps_list(struct kmod_list *list, bool stop_on_errors)
|
|
|
c49cfb |
{
|
|
|
c49cfb |
@@ -361,7 +362,7 @@ static int rmmod_do_deps_list(struct kmod_list *list, bool stop_on_errors)
|
|
|
c49cfb |
|
|
|
c49cfb |
kmod_list_foreach_reverse(l, list) {
|
|
|
c49cfb |
struct kmod_module *m = kmod_module_get_module(l);
|
|
|
c49cfb |
- int r = rmmod_do_module(m, false);
|
|
|
c49cfb |
+ int r = rmmod_do_module(m, false, true);
|
|
|
c49cfb |
kmod_module_unref(m);
|
|
|
c49cfb |
|
|
|
c49cfb |
if (r < 0 && stop_on_errors)
|
|
|
c49cfb |
@@ -371,7 +372,8 @@ static int rmmod_do_deps_list(struct kmod_list *list, bool stop_on_errors)
|
|
|
c49cfb |
return 0;
|
|
|
c49cfb |
}
|
|
|
c49cfb |
|
|
|
c49cfb |
-static int rmmod_do_module(struct kmod_module *mod, bool do_dependencies)
|
|
|
c49cfb |
+static int rmmod_do_module(struct kmod_module *mod, bool do_dependencies,
|
|
|
c49cfb |
+ bool ignore_builtin)
|
|
|
c49cfb |
{
|
|
|
c49cfb |
const char *modname = kmod_module_get_name(mod);
|
|
|
c49cfb |
struct kmod_list *pre = NULL, *post = NULL;
|
|
|
c49cfb |
@@ -401,8 +403,12 @@ static int rmmod_do_module(struct kmod_module *mod, bool do_dependencies)
|
|
|
c49cfb |
}
|
|
|
c49cfb |
goto error;
|
|
|
c49cfb |
} else if (state == KMOD_MODULE_BUILTIN) {
|
|
|
c49cfb |
- LOG("Module %s is builtin.\n", modname);
|
|
|
c49cfb |
- err = -ENOENT;
|
|
|
c49cfb |
+ if (ignore_builtin) {
|
|
|
c49cfb |
+ err = 0;
|
|
|
c49cfb |
+ } else {
|
|
|
c49cfb |
+ LOG("Module %s is builtin.\n", modname);
|
|
|
c49cfb |
+ err = -ENOENT;
|
|
|
c49cfb |
+ }
|
|
|
c49cfb |
goto error;
|
|
|
c49cfb |
}
|
|
|
c49cfb |
}
|
|
|
c49cfb |
@@ -462,7 +468,7 @@ static int rmmod(struct kmod_ctx *ctx, const char *alias)
|
|
|
c49cfb |
|
|
|
c49cfb |
kmod_list_foreach(l, list) {
|
|
|
c49cfb |
struct kmod_module *mod = kmod_module_get_module(l);
|
|
|
c49cfb |
- err = rmmod_do_module(mod, true);
|
|
|
c49cfb |
+ err = rmmod_do_module(mod, true, false);
|
|
|
c49cfb |
kmod_module_unref(mod);
|
|
|
c49cfb |
if (err < 0)
|
|
|
c49cfb |
break;
|
|
|
c49cfb |
--
|
|
|
c49cfb |
2.24.0
|
|
|
c49cfb |
|