From 18f9ef4568ab184b909a9f1fe51408c26acbf31c Mon Sep 17 00:00:00 2001 From: lly Date: Sat, 26 Sep 2009 13:09:31 -0400 Subject: [PATCH] Busybox insmod fixes: modules with short names, return codes --- release/src/router/busybox/modutils/insmod.c | 10 ++++++---- release/src/router/busybox/modutils/modutils-24.c | 6 ++++-- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/release/src/router/busybox/modutils/insmod.c b/release/src/router/busybox/modutils/insmod.c index 69bb8d2789..43d2171db3 100644 --- a/release/src/router/busybox/modutils/insmod.c +++ b/release/src/router/busybox/modutils/insmod.c @@ -62,15 +62,17 @@ int insmod_main(int argc UNUSED_PARAM, char **argv) if (stat(filename, &st) < 0 || !S_ISREG(st.st_mode) || (fp = fopen_for_read(filename)) == NULL) { /* Hmm. Could not open it. Search /lib/modules/ */ - int r, len; + int r, pos; char *module_dir; - len = strlen(filename); + pos = strlen(filename) - 2; if (get_linux_version_code() < KERNEL_VERSION(2,6,0)) { - if (len >= 2 && strncmp(&filename[len - 2], ".o", 2) !=0) + if (pos < 0) pos = 0; + if (strncmp(&filename[pos], ".o", 2) !=0) filename = xasprintf("%s.o", filename); } else { - if (len >= 3 && strncmp(&filename[len - 3], ".ko", 3) !=0) + if (--pos < 0) pos = 0; + if (strncmp(&filename[pos], ".ko", 3) !=0) filename = xasprintf("%s.ko", filename); } diff --git a/release/src/router/busybox/modutils/modutils-24.c b/release/src/router/busybox/modutils/modutils-24.c index a16cb1bbe3..7ccdd2e915 100644 --- a/release/src/router/busybox/modutils/modutils-24.c +++ b/release/src/router/busybox/modutils/modutils-24.c @@ -3785,7 +3785,7 @@ int FAST_FUNC bb_init_module_24(const char *m_filename, const char *options) /* Load module into memory and unzip if compressed */ image = xmalloc_open_zipped_read_close(m_filename, &image_size); if (!image) - return EXIT_FAILURE; + return (-errno); m_name = xstrdup(bb_basename(m_filename)); /* "module.o[.gz]" -> "module" */ @@ -3815,8 +3815,10 @@ int FAST_FUNC bb_init_module_24(const char *m_filename, const char *options) "\twhile this kernel is version %s", flag_force_load ? "warning: " : "", m_name, m_strversion, uts.release); - if (!flag_force_load) + if (!flag_force_load) { + exit_status = ESRCH; goto out; + } } } #endif -- 2.11.4.GIT