diff options
author | Josh Boyer <jwboyer@redhat.com> | 2013-03-15 13:43:40 -0400 |
---|---|---|
committer | Lucas De Marchi <lucas.de.marchi@gmail.com> | 2013-03-18 11:16:50 -0300 |
commit | d53abca3bef50c2e0983821347d5da37e0ec3478 (patch) | |
tree | 8f62bb47f245c9e7990d36990deb6363ae741ecc | |
parent | c3e8d269466ab02e4c4a928f9f5af222f1138725 (diff) | |
download | kmod-d53abca3bef50c2e0983821347d5da37e0ec3478.tar.gz |
rmmod: Teach rmmod about builtin modules
Currently modprobe -r will fail if a module is built in and report that it
is built in. rmmod calls the same function to determine state but doesn't
handle the KMOD_MODULE_BUILTIN return code. This leads to confusing errors
like this:
libkmod: kmod_module_get_holders: could not open '/sys/module/loop/holders': No such file or directory
Error: Module loop is in use
Fix this so that it actually reports the correct problem to the user.
-rw-r--r-- | tools/rmmod.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/tools/rmmod.c b/tools/rmmod.c index 7f2c2f6..bf5a408 100644 --- a/tools/rmmod.c +++ b/tools/rmmod.c @@ -62,8 +62,14 @@ static void help(void) static int check_module_inuse(struct kmod_module *mod) { struct kmod_list *holders; + int state; - if (kmod_module_get_initstate(mod) == -ENOENT) { + state = kmod_module_get_initstate(mod); + + if (state == KMOD_MODULE_BUILTIN) { + ERR("Module %s is builtin.\n", kmod_module_get_name(mod)); + return -ENOENT; + } else if (state < 0) { ERR("Module %s is not currently loaded\n", kmod_module_get_name(mod)); return -ENOENT; |