[BusyBox-cvs] CVS update of busybox/modutils (Config.in modprobe.c)

Erik Andersen andersen at codepoet.org
Tue Jun 22 10:43:09 UTC 2004


    Date: Tuesday, June 22, 2004 @ 04:43:09
  Author: andersen
    Path: /var/cvs/busybox/modutils

Modified: Config.in (1.11 -> 1.12) modprobe.c (1.31 -> 1.32)

Patrick Huesmann writes:

    Hi,

    There was some problem with busybox modprobe. For details see
    http://www.busybox.net/lists/busybox/2004-May/011507.html

    I made a patch against busybox-1.00-pre10 to fix that one.

This is a slight variant of Patrick's patch with a slightly
cleaner implementation of mod_strcmp()
 -Erik


Index: busybox/modutils/Config.in
diff -u busybox/modutils/Config.in:1.11 busybox/modutils/Config.in:1.12
--- busybox/modutils/Config.in:1.11	Mon Mar 15 01:28:47 2004
+++ busybox/modutils/Config.in	Tue Jun 22 04:43:09 2004
@@ -21,16 +21,16 @@
 config CONFIG_FEATURE_2_4_MODULES
 	bool "  Support version 2.1.x to 2.4.x Linux kernels"
 	default y
-	depends on CONFIG_INSMOD
+	depends on CONFIG_INSMOD && !CONFIG_FEATURE_2_6_MODULES
 	help
-	  Support module loading for newer (post 2.1) Linux kernels.
+	  Support module loading for 2.2.x and 2.4.x Linux kernels.
 
 config CONFIG_FEATURE_2_6_MODULES
 	bool "  Support version 2.6.x Linux kernels"
 	default n
-	depends on CONFIG_INSMOD
+	depends on CONFIG_INSMOD && !CONFIG_FEATURE_2_4_MODULES
 	help
-	  Support module loading for newer (post 2.1) Linux kernels.
+	  Support module loading for 2.6.x Linux kernels.
 
 config CONFIG_FEATURE_INSMOD_VERSION_CHECKING
 	bool "  Module version checking"
Index: busybox/modutils/modprobe.c
diff -u busybox/modutils/modprobe.c:1.31 busybox/modutils/modprobe.c:1.32
--- busybox/modutils/modprobe.c:1.31	Tue Apr  6 06:06:03 2004
+++ busybox/modutils/modprobe.c	Tue Jun 22 04:43:09 2004
@@ -182,7 +182,7 @@
 					if (( *(col-2) == '.' ) && ( *(col-1) == 'o' ))
 						ext = 2;
 
-				mod = bb_xstrndup ( mods, col - mods - ext );
+				mod = bb_xstrndup ( buffer, col - buffer );
 
 				if ( !current ) {
 					first = current = (struct dep_t *) xmalloc ( sizeof ( struct dep_t ));
@@ -354,6 +354,28 @@
 	return first;
 }
 
+/* check if /lib/modules/bar/foo.ko belongs to module foo */
+/* return 1 = found, 0 = not found                        */
+static int mod_strcmp ( const char *mod_path, const char *mod_name )
+{
+#if defined(CONFIG_FEATURE_2_6_MODULES)
+#define MODULE_EXTENSION	".ko"
+#define MOD_EXTENSION_LEN	3
+#else
+#define MODULE_EXTENSION	".o"
+#define MOD_EXTENSION_LEN	2
+#endif
+	if ((strstr (mod_path, mod_name) ==
+				(mod_path + strlen(mod_path) -
+				 strlen(mod_name) - MOD_EXTENSION_LEN))
+			&& (!strcmp(mod_path + strlen(mod_path) -
+					MOD_EXTENSION_LEN, MODULE_EXTENSION)))
+	{
+      return 1;
+	}
+  return 0;
+}
+
 /* return 1 = loaded, 0 = not loaded, -1 = can't tell */
 static int already_loaded (const char *name)
 {
@@ -370,7 +392,7 @@
 		p = strchr (buffer, ' ');
 		if (p) {
 			*p = 0;
-			if (strcmp (name, buffer) == 0) {
+			if (mod_strcmp (name, buffer)) {
 				close (fd);
 				return 1;
 			}
@@ -434,7 +456,8 @@
 
 	// check dependencies
 	for ( dt = depend; dt; dt = dt-> m_next ) {
-		if ( strcmp ( dt-> m_module, mod ) == 0 ) {
+		if ( mod_strcmp ( dt-> m_module, mod )) {
+			mod = dt-> m_module;
 			opt = dt-> m_options;
 			break;
 		}



More information about the busybox-cvs mailing list