Jan Engelhardt
237161f1b6
- testsuite: Check the list of loaded modules after a test - testsuite: Add test for modprobe --force - testsuite: Do not provide finit_module(2) on older kernels - Add some tests for kernels without finit_module(2) - libkmod-module: Simplify kmod_module_insert_module() - libkmod: Implement filtering of unsupported modules (fate#316971) - modprobe: Implement --allow-unsupported-modules (fate#316971) - make the %check section fatal OBS-URL: https://build.opensuse.org/request/show/224726 OBS-URL: https://build.opensuse.org/package/show/Base:System/kmod?expand=0&rev=65
96 lines
2.6 KiB
Diff
96 lines
2.6 KiB
Diff
From 40926774b6153bfd7f0321b3226323958bc4d81d Mon Sep 17 00:00:00 2001
|
|
From: Michal Marek <mmarek@suse.cz>
|
|
Date: Thu, 27 Feb 2014 11:32:22 +0100
|
|
Subject: [PATCH 08/10] libkmod-module: Simplify kmod_module_insert_module()
|
|
|
|
Store the file and elf pointer in the kmod_module structure and have it
|
|
freed together with the module.
|
|
|
|
Patch-mainline: v17
|
|
Git-commit: c2f4d85a9adea895958fc85b9b87ce95a7dc7774
|
|
---
|
|
libkmod/libkmod-module.c | 27 ++++++++++-----------------
|
|
1 file changed, 10 insertions(+), 17 deletions(-)
|
|
|
|
diff --git a/libkmod/libkmod-module.c b/libkmod/libkmod-module.c
|
|
index 2f92e16..b94abd4 100644
|
|
--- a/libkmod/libkmod-module.c
|
|
+++ b/libkmod/libkmod-module.c
|
|
@@ -791,8 +791,7 @@ KMOD_EXPORT int kmod_module_insert_module(struct kmod_module *mod,
|
|
int err;
|
|
const void *mem;
|
|
off_t size;
|
|
- struct kmod_file *file;
|
|
- struct kmod_elf *elf = NULL;
|
|
+ struct kmod_elf *elf;
|
|
const char *path;
|
|
const char *args = options ? options : "";
|
|
|
|
@@ -805,13 +804,13 @@ KMOD_EXPORT int kmod_module_insert_module(struct kmod_module *mod,
|
|
return -ENOSYS;
|
|
}
|
|
|
|
- file = kmod_file_open(mod->ctx, path);
|
|
- if (file == NULL) {
|
|
+ mod->file = kmod_file_open(mod->ctx, path);
|
|
+ if (mod->file == NULL) {
|
|
err = -errno;
|
|
return err;
|
|
}
|
|
|
|
- if (kmod_file_get_direct(file)) {
|
|
+ if (kmod_file_get_direct(mod->file)) {
|
|
unsigned int kernel_flags = 0;
|
|
|
|
if (flags & KMOD_INSERT_FORCE_VERMAGIC)
|
|
@@ -819,19 +818,16 @@ KMOD_EXPORT int kmod_module_insert_module(struct kmod_module *mod,
|
|
if (flags & KMOD_INSERT_FORCE_MODVERSION)
|
|
kernel_flags |= MODULE_INIT_IGNORE_MODVERSIONS;
|
|
|
|
- err = finit_module(kmod_file_get_fd(file), args, kernel_flags);
|
|
+ err = finit_module(kmod_file_get_fd(mod->file), args, kernel_flags);
|
|
if (err == 0 || errno != ENOSYS)
|
|
goto init_finished;
|
|
}
|
|
|
|
- size = kmod_file_get_size(file);
|
|
- mem = kmod_file_get_contents(file);
|
|
-
|
|
if (flags & (KMOD_INSERT_FORCE_VERMAGIC | KMOD_INSERT_FORCE_MODVERSION)) {
|
|
- elf = kmod_elf_new(mem, size);
|
|
+ elf = kmod_file_get_elf(mod->file);
|
|
if (elf == NULL) {
|
|
err = -errno;
|
|
- goto elf_failed;
|
|
+ return err;
|
|
}
|
|
|
|
if (flags & KMOD_INSERT_FORCE_MODVERSION) {
|
|
@@ -847,7 +843,10 @@ KMOD_EXPORT int kmod_module_insert_module(struct kmod_module *mod,
|
|
}
|
|
|
|
mem = kmod_elf_get_memory(elf);
|
|
+ } else {
|
|
+ mem = kmod_file_get_contents(mod->file);
|
|
}
|
|
+ size = kmod_file_get_size(mod->file);
|
|
|
|
err = init_module(mem, size, args);
|
|
init_finished:
|
|
@@ -855,12 +854,6 @@ init_finished:
|
|
err = -errno;
|
|
INFO(mod->ctx, "Failed to insert module '%s': %m\n", path);
|
|
}
|
|
-
|
|
- if (elf != NULL)
|
|
- kmod_elf_unref(elf);
|
|
-elf_failed:
|
|
- kmod_file_unref(file);
|
|
-
|
|
return err;
|
|
}
|
|
|
|
--
|
|
1.8.4.5
|
|
|