]> git.ipfire.org Git - thirdparty/kmod.git/commitdiff
modprobe: flush stdout before dumping indexes
authorLucas De Marchi <lucas.demarchi@profusion.mobi>
Tue, 17 Jan 2012 12:05:02 +0000 (10:05 -0200)
committerLucas De Marchi <lucas.demarchi@profusion.mobi>
Tue, 17 Jan 2012 12:11:03 +0000 (10:11 -0200)
Index dump doesn't use stdio.h function and instead call write()
directly on STDOUT_FILENO file descriptor. Therefore we need to flush
stdio buffers before calling it, to be sure the configuration dump will
appear before index's.

libkmod/libkmod.c
tools/kmod-modprobe.c

index 800a1784ffeb916f49ea8ab0e52f1de377c3512f..91fdf7b6714a2883c879a0fc7f964c49f06ec638 100644 (file)
@@ -752,7 +752,9 @@ KMOD_EXPORT void kmod_unload_resources(struct kmod_ctx *ctx)
  * @type: index to dump
  * @fd: file descriptor to dump index to
  *
- * Dump index to file descriptor
+ * Dump index to file descriptor. Note that this function doesn't use stdio.h
+ * so call fflush() before calling this function to be sure data is written in
+ * order.
  *
  * Returns: 0 on success or < 0 otherwise.
  */
index 3e515066b1f0790811bb85c428a8165fee2cb8ed..9d612ddaf74042cf8862a447838e31966ee5c059 100644 (file)
@@ -247,6 +247,8 @@ static int show_config(struct kmod_ctx *ctx)
                kmod_config_iter_free_iter(iter);
        }
 
+       fflush(stdout);
+
        kmod_dump_index(ctx, KMOD_INDEX_MODULES_ALIAS, STDOUT_FILENO);
        kmod_dump_index(ctx, KMOD_INDEX_MODULES_SYMBOL, STDOUT_FILENO);