aboutsummaryrefslogtreecommitdiff
path: root/modutils/modutils-24.c
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2009-10-25 04:35:22 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2009-10-25 04:35:22 +0100
commit77c066ea5cf4b1ee606a81e48388ff0b1d019134 (patch)
treeb51b001a013a4be3a2ad09fdc22cfdccf29bdbaf /modutils/modutils-24.c
parent30f3c1d5fdf8999491a01cb3fe8be8a40da52a75 (diff)
downloadbusybox-77c066ea5cf4b1ee606a81e48388ff0b1d019134.tar.gz
modutils: add FEATURE_INSMOD_TRY_MMAP option
function old new delta try_to_mmap_module - 121 +121 bb_init_module_24 4514 4578 +64 bb_init_module 119 173 +54 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 2/0 up/down: 239/0) Total: 239 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'modutils/modutils-24.c')
-rw-r--r--modutils/modutils-24.c25
1 files changed, 18 insertions, 7 deletions
diff --git a/modutils/modutils-24.c b/modutils/modutils-24.c
index e5ff54d29..a878e740c 100644
--- a/modutils/modutils-24.c
+++ b/modutils/modutils-24.c
@@ -3783,12 +3783,20 @@ int FAST_FUNC bb_init_module_24(const char *m_filename, const char *options)
int m_has_modinfo;
#endif
char *image;
- size_t image_size = 64 * 1024 * 1024;
-
- /* Load module into memory and unzip if compressed */
- image = xmalloc_open_zipped_read_close(m_filename, &image_size);
- if (!image)
- return EXIT_FAILURE;
+ size_t image_size;
+ bool mmaped;
+
+ image_size = INT_MAX - 4095;
+ mmaped = 0;
+ image = try_to_mmap_module(m_filename, &image_size);
+ if (image) {
+ mmaped = 1;
+ } else {
+ /* Load module into memory and unzip if compressed */
+ image = xmalloc_open_zipped_read_close(m_filename, &image_size);
+ if (!image)
+ return EXIT_FAILURE;
+ }
m_name = xstrdup(bb_basename(m_filename));
/* "module.o[.gz]" -> "module" */
@@ -3901,7 +3909,10 @@ int FAST_FUNC bb_init_module_24(const char *m_filename, const char *options)
exit_status = EXIT_SUCCESS;
out:
- free(image);
+ if (mmaped)
+ munmap(image, image_size);
+ else
+ free(image);
free(m_name);
return exit_status;