diff options
author | Lucas De Marchi <lucas.demarchi@intel.com> | 2013-09-20 01:30:07 -0500 |
---|---|---|
committer | Lucas De Marchi <lucas.demarchi@intel.com> | 2013-09-20 01:37:24 -0500 |
commit | 7ab8804448377fb6b8854f2dd288608db01bb43b (patch) | |
tree | b45f97fbe7f859aa4072988b9cb4df485e736724 | |
parent | 82fc7d986cdc60aeb34224f59a92a04e2d514da9 (diff) | |
download | kmod-7ab8804448377fb6b8854f2dd288608db01bb43b.tar.gz |
libkmod: always pass O_NONBLOCK to kernel
Not passsing O_NONBLOCK to delete_module() is deprecated since kmod 11
and is being removed from the kernel. Force this flag in libkmod.
-rw-r--r-- | NEWS | 10 | ||||
-rw-r--r-- | libkmod/libkmod-module.c | 15 | ||||
-rw-r--r-- | libkmod/libkmod.h | 2 |
3 files changed, 16 insertions, 11 deletions
@@ -1,3 +1,11 @@ +kmod 16 +======= + +- New features: + - Remove option from libkmod to allow waiting on module removal if + the module is being used. It's dangerous since it can block the + caller indefinitely. + kmod 15 ======= @@ -82,7 +90,7 @@ kmod 11 benefits. - Hide --wait option on rmmod. This feature is being targeted for removal from kernel. rmmod still accepts this option, but it's hidden - now: man page and usage() says nothing about it and if it's used, + now: man page and usage() say nothing about it and if it's used, user will get a 10s sleep. This way we can check and help if anyone is using this feature. - Refactor message logging on all tools, giving proper prefix, routing diff --git a/libkmod/libkmod-module.c b/libkmod/libkmod-module.c index 3874194..3adbb69 100644 --- a/libkmod/libkmod-module.c +++ b/libkmod/libkmod-module.c @@ -738,15 +738,11 @@ extern long delete_module(const char *name, unsigned int flags); /** * kmod_module_remove_module: * @mod: kmod module - * @flags: flags to pass to Linux kernel when removing the module, valid flags are + * @flags: flags to pass to Linux kernel when removing the module. The only valid flag is * KMOD_REMOVE_FORCE: force remove module regardless if it's still in * use by a kernel subsystem or other process; - * KMOD_REMOVE_NOWAIT: return immediately. It will fail if the module - * is in using and KMOD_REMOVE_FORCE is not specified. - * If this module is in use by any kernel subsystem or process, not using - * this flag will cause the call to block indefinitely, until the module - * is not in use anymore. Always use this flag, it's deprecated not using - * it and the default behavior might change in future to always set it. + * KMOD_REMOVE_NOWAIT is always enforced, causing us to pass O_NONBLOCK to + * delete_module(2). * * Remove a module from Linux kernel. * @@ -760,8 +756,9 @@ KMOD_EXPORT int kmod_module_remove_module(struct kmod_module *mod, if (mod == NULL) return -ENOENT; - /* Filter out other flags */ - flags &= (KMOD_REMOVE_FORCE | KMOD_REMOVE_NOWAIT); + /* Filter out other flags and force ONONBLOCK */ + flags &= KMOD_REMOVE_FORCE; + flags |= KMOD_REMOVE_NOWAIT; err = delete_module(mod->name, flags); if (err != 0) { diff --git a/libkmod/libkmod.h b/libkmod/libkmod.h index 3397f87..a7ea221 100644 --- a/libkmod/libkmod.h +++ b/libkmod/libkmod.h @@ -140,7 +140,7 @@ struct kmod_module *kmod_module_get_module(const struct kmod_list *entry); /* Removal flags */ enum kmod_remove { KMOD_REMOVE_FORCE = O_TRUNC, - KMOD_REMOVE_NOWAIT = O_NONBLOCK, + KMOD_REMOVE_NOWAIT = O_NONBLOCK, /* always set */ }; /* Insertion flags */ |