summaryrefslogtreecommitdiff
path: root/libkmod/libkmod-module.c
diff options
context:
space:
mode:
authorLucas De Marchi <lucas.de.marchi@gmail.com>2023-06-01 15:39:57 -0700
committerLucas De Marchi <lucas.de.marchi@gmail.com>2023-06-09 10:45:51 -0700
commit7a86f1292051e990507ea48888864ff19626a206 (patch)
tree14059b9d89a9c4497c3b1a58068059299970756a /libkmod/libkmod-module.c
parent9c262fdb1c798fd87d91e8c669acbec4d632024b (diff)
downloadkmod-7a86f1292051e990507ea48888864ff19626a206.tar.gz
kmod-7a86f1292051e990507ea48888864ff19626a206.tar.bz2
kmod-7a86f1292051e990507ea48888864ff19626a206.zip
libkmod: Do not inititialize file->memory on open
Add a separate function to load the file contents when it's needed. When it's not needed on the path of loading modules via finit_module(), there is no need to mmap the file. This will help support loading modules with the in-kernel compression support. This is done differently than the lazy initialization for kmod_file_get_elf() because on the contents case there is also the file->size to be updated. It would be a weird API to return the pointer and have the size changed as a side-effect. Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
Diffstat (limited to 'libkmod/libkmod-module.c')
-rw-r--r--libkmod/libkmod-module.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/libkmod/libkmod-module.c b/libkmod/libkmod-module.c
index 7736b7e..f352fe1 100644
--- a/libkmod/libkmod-module.c
+++ b/libkmod/libkmod-module.c
@@ -917,6 +917,8 @@ KMOD_EXPORT int kmod_module_insert_module(struct kmod_module *mod,
goto init_finished;
}
+ kmod_file_load_contents(mod->file);
+
if (flags & (KMOD_INSERT_FORCE_VERMAGIC | KMOD_INSERT_FORCE_MODVERSION)) {
elf = kmod_file_get_elf(mod->file);
if (elf == NULL) {