kmodprobe: post-remove module deps with 0 refcnt

This commit is contained in:
Dave Reisner 2011-12-31 18:02:45 -05:00
parent d98880ad5c
commit 0e9bd2d1ca
2 changed files with 12 additions and 3 deletions

2
TODO
View File

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

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