summaryrefslogtreecommitdiff
path: root/testing/kmod/0004-modprobe-remove-0-refcnt-deps.patch
diff options
context:
space:
mode:
Diffstat (limited to 'testing/kmod/0004-modprobe-remove-0-refcnt-deps.patch')
-rw-r--r--testing/kmod/0004-modprobe-remove-0-refcnt-deps.patch52
1 files changed, 52 insertions, 0 deletions
diff --git a/testing/kmod/0004-modprobe-remove-0-refcnt-deps.patch b/testing/kmod/0004-modprobe-remove-0-refcnt-deps.patch
new file mode 100644
index 000000000..a76b609b8
--- /dev/null
+++ b/testing/kmod/0004-modprobe-remove-0-refcnt-deps.patch
@@ -0,0 +1,52 @@
+From f169a0c3737b8ac69499240fca8314a2bd67a0a1 Mon Sep 17 00:00:00 2001
+From: Dave Reisner <dreisner@archlinux.org>
+Date: Mon, 30 Jan 2012 23:39:30 -0500
+Subject: [PATCH 4/8] modprobe: remove 0 refcnt deps
+
+---
+ tools/kmod-modprobe.c | 15 +++++++++++++--
+ 1 files changed, 13 insertions(+), 2 deletions(-)
+
+diff --git a/tools/kmod-modprobe.c b/tools/kmod-modprobe.c
+index c882856..bd991a5 100644
+--- a/tools/kmod-modprobe.c
++++ b/tools/kmod-modprobe.c
+@@ -381,7 +381,7 @@ static int rmmod_do_deps_list(struct kmod_list *list, bool stop_on_errors)
+ static int rmmod_do_module(struct kmod_module *mod, bool do_dependencies)
+ {
+ const char *modname = kmod_module_get_name(mod);
+- struct kmod_list *pre = NULL, *post = NULL;
++ struct kmod_list *pre = NULL, *post = NULL, *deps, *itr;
+ const char *cmd = NULL;
+ int err;
+
+@@ -422,7 +422,7 @@ static int rmmod_do_module(struct kmod_module *mod, bool do_dependencies)
+ rmmod_do_deps_list(post, false);
+
+ if (do_dependencies && remove_dependencies) {
+- struct kmod_list *deps = kmod_module_get_dependencies(mod);
++ deps = kmod_module_get_dependencies(mod);
+
+ err = rmmod_do_deps_list(deps, true);
+ if (err < 0)
+@@ -451,6 +451,17 @@ static int rmmod_do_module(struct kmod_module *mod, bool do_dependencies)
+
+ rmmod_do_deps_list(pre, false);
+
++ deps = kmod_module_get_dependencies(mod);
++ if (deps != NULL) {
++ kmod_list_foreach_reverse(itr, deps) {
++ struct kmod_module *dep = kmod_module_get_module(itr);
++ if (kmod_module_get_refcnt(dep) == 0)
++ rmmod_do_remove_module(dep);
++ kmod_module_unref(dep);
++ }
++ kmod_module_unref_list(deps);
++ }
++
+ error:
+ kmod_module_unref_list(pre);
+ kmod_module_unref_list(post);
+--
+1.7.9
+