]> git.ipfire.org Git - thirdparty/kmod.git/commitdiff
kmodprobe: post-remove module deps with 0 refcnt
authorDave Reisner <dreisner@archlinux.org>
Sat, 31 Dec 2011 23:02:45 +0000 (18:02 -0500)
committerDave Reisner <dreisner@archlinux.org>
Sat, 31 Dec 2011 23:21:00 +0000 (18:21 -0500)
TODO
tools/kmod-modprobe.c

diff --git a/TODO b/TODO
index c7d162c9da235cb5758d1929630cd2a1bf25dde7..69a0a0d378edfe667fa90f26660aac060edee2db 100644 (file)
--- a/TODO
+++ b/TODO
@@ -18,8 +18,6 @@ Features:
 
 * provide 1:1 compatibility with module-init-tools's modprobe
    - dump configuration
-   - 'modprobe -r' should remove modules which usecount became 0 because of
-     module's removal
 
 * Add kmod_validate(). It checks if all config files and indexes are still
   valid. We need to save the mtime of each config dir when starting up and when
index b8d79b0e4df9be720d92318297b26a7ab4168a45..2a649dda5b06e908d5f66651152a57c1c562d13d 100644 (file)
@@ -418,7 +418,7 @@ static int rmmod_do_dependencies(struct kmod_module *parent)
 static int rmmod_do(struct kmod_module *mod)
 {
        const char *modname = kmod_module_get_name(mod);
-       struct kmod_list *pre = NULL, *post = NULL;
+       struct kmod_list *pre = NULL, *post = NULL, *deps, *itr;
        int err;
 
        if (!ignore_commands) {
@@ -508,6 +508,17 @@ done:
                }
        }
 
+       deps = kmod_module_get_dependencies(mod);
+       if (deps) {
+               kmod_list_foreach(itr, deps) {
+                       struct kmod_module *dep = kmod_module_get_module(itr);
+                       if (kmod_module_get_refcnt(dep) == 0) {
+                               rmmod_do(dep);
+                       }
+               }
+               kmod_module_unref_list(deps);
+       }
+
 error:
        kmod_module_unref_list(pre);
        kmod_module_unref_list(post);