On Wednesday 12 November 2008 23:14, Harald Küthe wrote:
> >/ Hello list,
> />/
> />/ it looks like we need this patch again but now for modutils-24.c:
> />/
> http://busybox.net/cgi-bin/viewcvs.cgi/trunk/busybox/modutils/insmod.c?rev=23277&r1=23271&r2=23277
>
> <http://busybox.net/cgi-bin/viewcvs.cgi/trunk/busybox/modutils/insmod.c?rev=23277&r1=23271&r2=23277>
>
> /Well, this was not all we need about the insmod vector-alloc issue.
> I backported the needed parts of the 1.12.2 insmod.c into modutils-24.c
> both for the vector changes as well as for the module searching.
>
> See attached patch, it works for me but it is only roughly tested.
> Please review!
I applied trivial parts of it, thanks.
Can you explain the rest?
It is in attached patch. Seems to be a bit big,
I'd like to have the explanation what this change does.
--
vda
--- modutils-24.c.orig 2008-10-30 08:41:28.000000000 +0100
+++ modutils-24.c 2008-11-12 22:55:28.000000000 +0100
@@ -748,9 +748,35 @@
static int n_ext_modules;
static int n_ext_modules_used;
+static char *m_filename;
+static char *m_fullName;
+
+
/*======================================================================*/
+static int FAST_FUNC check_module_name_match(const char *filename,
+ struct stat *statbuf UNUSED_PARAM,
+ void *userdata, int depth UNUSED_PARAM)
+{
+ char *fullname = (char *) userdata;
+ char *tmp;
+
+ if (fullname[0] == '\0')
+ return FALSE;
+
+ tmp = bb_get_last_path_component_nostrip(filename);
+ if (strcmp(tmp, fullname) == 0) {
+ /* Stop searching if we find a match */
+ m_filename = xstrdup(filename);
+ return FALSE;
+ }
+ return TRUE;
+}
+
+
+/*======================================================================*/
+
static struct obj_file *arch_new_file(void)
{
struct arch_file *f;
@@ -3796,7 +3832,7 @@
}
#endif
-int FAST_FUNC bb_init_module_24(const char *m_filename, const char *options UNUSED_PARAM)
+int FAST_FUNC bb_init_module_24(const char *arg1, const char *options UNUSED_PARAM)
{
int k_crcs;
unsigned long m_size;
@@ -3805,20 +3841,96 @@
struct utsname uts;
int exit_status = EXIT_FAILURE;
int m_has_modinfo;
- char *m_name;
+ char *m_name = NULL;
+ char *m_fullName = NULL;
#if ENABLE_FEATURE_INSMOD_VERSION_CHECKING
char m_strversion[STRVERSIONLEN];
int m_version, m_crcs;
#endif
FILE *fp;
+int len;
+char *tmp;
+int k_version = 0;
+struct stat st;
+
+ /* Grab the module name */
+ tmp = xstrdup(arg1);
+ len = strlen(arg1);
+
+ if (uname(&uts) == 0) {
+ if (uts.release[0] == '2') {
+ k_version = uts.release[2] - '0';
+ }
+ }
+
+ if (len > 2 && tmp[len - 2] == '.' && tmp[len - 1] == 'o') {
+ len -= 2;
+ tmp[len] = '\0';
+ }
+
+ m_fullName = xasprintf("%s.o", tmp);
+
+ if (!m_name) {
+ m_name = tmp;
+ }
+
+ /* Get a filedesc for the module. Check that we have a complete path */
+ if (stat(arg1, &st) < 0 || !S_ISREG(st.st_mode)
+ || (fp = fopen_for_read(arg1)) == NULL
+ ) {
+ /* Hmm. Could not open it. First search under /lib/modules/`uname -r`,
+ * but do not error out yet if we fail to find it... */
+ if (k_version) { /* uname succeedd */
+ char *module_dir;
+ char *tmdn;
+
+ tmdn = concat_path_file(CONFIG_DEFAULT_MODULES_DIR, uts.release);
+ /* Jump through hoops in case /lib/modules/`uname -r`
+ * is a symlink. We do not want recursive_action to
+ * follow symlinks, but we do want to follow the
+ * /lib/modules/`uname -r` dir, So resolve it ourselves
+ * if it is a link... */
+ module_dir = xmalloc_readlink(tmdn);
+ if (!module_dir)
+ module_dir = xstrdup(tmdn);
+ recursive_action(module_dir, ACTION_RECURSE,
+ check_module_name_match, NULL, m_fullName, 0);
+ free(module_dir);
+ free(tmdn);
+ }
+
+ /* Check if we have found anything yet */
+ if (!m_filename || ((fp = fopen_for_read(m_filename)) == NULL)) {
+ int r;
+ char *module_dir;
+
+ free(m_filename);
+ m_filename = NULL;
+ module_dir = xmalloc_readlink(CONFIG_DEFAULT_MODULES_DIR);
+ if (!module_dir)
+ module_dir = xstrdup(CONFIG_DEFAULT_MODULES_DIR);
+ /* No module found under /lib/modules/`uname -r`, this
+ * time cast the net a bit wider. Search /lib/modules/ */
+ r = recursive_action(module_dir, ACTION_RECURSE,
+ check_module_name_match, NULL, m_fullName, 0);
+ if (r)
+ bb_error_msg_and_die("%s: module not found", m_fullName);
+ free(module_dir);
+ if (m_filename == NULL
+ || ((fp = fopen_for_read(m_filename)) == NULL)
+ ) {
+ bb_error_msg_and_die("%s: module not found", m_fullName);
+ }
+ }
+ } else
+ m_filename = xstrdup(arg1);
+
+
+
+
+
- uname(&uts);
- fp = fopen_for_read(m_filename);
- if (fp == NULL)
- return EXIT_FAILURE;
- m_name = xstrdup(bb_basename(m_filename));
- *strrchr(m_name, '.') = 0;
f = obj_load(fp, LOADBITS);
@@ -3830,6 +3942,8 @@
#if ENABLE_FEATURE_INSMOD_VERSION_CHECKING
/* Version correspondence? */
if (!flag_quiet) {
+ if (uname(&uts_info) < 0)
+ uts_info.release[0] = '\0';
if (m_has_modinfo) {
m_version = new_get_module_version(f, m_strversion);
if (m_version == -1) {
_______________________________________________
busybox mailing list
[email protected]
http://busybox.net/cgi-bin/mailman/listinfo/busybox