]> git.ipfire.org Git - thirdparty/kmod.git/commitdiff
libkmod: always pass O_NONBLOCK to kernel
authorLucas De Marchi <lucas.demarchi@intel.com>
Fri, 20 Sep 2013 06:30:07 +0000 (01:30 -0500)
committerLucas De Marchi <lucas.demarchi@intel.com>
Fri, 20 Sep 2013 06:37:24 +0000 (01:37 -0500)
Not passsing O_NONBLOCK to delete_module() is deprecated since kmod 11
and is being removed from the kernel. Force this flag in libkmod.

NEWS
libkmod/libkmod-module.c
libkmod/libkmod.h

diff --git a/NEWS b/NEWS
index 8260183f5e337cd21260ee734e1fa2c486516043..e028cff533592c383bebf8fb61d3b2b619236c3c 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -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
index 3874194189c8a1a141deed73e92d735121c4d256..3adbb69d6a7b1074df3ca609b5ad465c88914618 100644 (file)
@@ -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) {
index 3397f87e43fb8d7327828851ba8535ecda3456fa..a7ea221609273a70bc3cbe6ef046e4d038dd773c 100644 (file)
@@ -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 */