Return -errno instead of the value returned by init_module(). We need to
differentiate between the several errors that might occur, e.g. "module
already loaded", access denied, etc.
* Insert a module in Linux kernel. It opens the file pointed by @mod,
* mmap'ing it and passing to kernel.
*
- * Returns: 0 on success or < 0 on failure.
+ * Returns: 0 on success or < 0 on failure. If module is already loaded it
+ * returns -EEXIST.
*/
KMOD_EXPORT int kmod_module_insert_module(struct kmod_module *mod,
unsigned int flags,
}
err = init_module(mem, size, args);
- if (err < 0)
- ERR(mod->ctx, "Failed to insert module '%s'\n", path);
+ if (err < 0) {
+ err = -errno;
+ INFO(mod->ctx, "Failed to insert module '%s': %m\n", path);
+ }
if (elf != NULL)
kmod_elf_unref(elf);