svn commit: trunk/busybox/modutils

landley at busybox.net landley at busybox.net
Thu Jul 20 17:36:19 UTC 2006


Author: landley
Date: 2006-07-20 10:36:18 -0700 (Thu, 20 Jul 2006)
New Revision: 15734

Log:
Patch from Yann Morin to fix bug 941, underscores in module aliases.


Modified:
   trunk/busybox/modutils/Config.in
   trunk/busybox/modutils/modprobe.c


Changeset:
Modified: trunk/busybox/modutils/Config.in
===================================================================
--- trunk/busybox/modutils/Config.in	2006-07-20 04:47:50 UTC (rev 15733)
+++ trunk/busybox/modutils/Config.in	2006-07-20 17:36:18 UTC (rev 15734)
@@ -91,7 +91,8 @@
 	  module options from the configuration file. See option below.
 
 config CONFIG_FEATURE_MODPROBE_MULTIPLE_OPTIONS
-	bool "Multiple options parsing"
+	bool
+	prompt "Multiple options parsing" if CONFIG_NITPICK
 	default y
 	depends on CONFIG_MODPROBE
 	help
@@ -106,6 +107,16 @@
 	  Saying Y here is not a bad idea if you're not that short
 	  on storage capacity.
 
+config CONFIG_FEATURE_MODPROBE_FANCY_ALIAS
+	bool
+	prompt "Fancy alias parsing" if CONFIG_NITPICK
+	default y
+	depends on CONFIG_MODPROBE && CONFIG_FEATURE_2_6_MODULES
+	help
+	  Say 'y' here to enable parsing of aliases with underscore/dash
+	  mismatch between module name and file name, along with bus-specific
+	  aliases (such as pci:... or usb:... aliases).
+
 comment "Options common to multiple modutils"
 	depends on CONFIG_INSMOD || CONFIG_RMMOD || CONFIG_MODPROBE || CONFIG_LSMOD
 

Modified: trunk/busybox/modutils/modprobe.c
===================================================================
--- trunk/busybox/modutils/modprobe.c	2006-07-20 04:47:50 UTC (rev 15733)
+++ trunk/busybox/modutils/modprobe.c	2006-07-20 17:36:18 UTC (rev 15734)
@@ -713,6 +713,37 @@
 }
 
 /*
+ * Check the matching between a pattern and a module name.
+ * We need this as *_* is equivalent to *-*, even in pattern matching.
+ */
+static int check_pattern( const char* pat_src, const char* mod_src ) {
+	int ret;
+
+	if (ENABLE_FEATURE_MODPROBE_FANCY_ALIAS) {
+		char* pat;
+		char* mod;
+		char* p;
+
+		pat = bb_xstrdup (pat_src);
+		mod = bb_xstrdup (mod_src);
+
+		for (p = pat; (p = strchr(p, '-')); *p++ = '_' );
+		for (p = mod; (p = strchr(p, '-')); *p++ = '_' );
+
+		ret = fnmatch ( pat, mod, 0 );
+
+		if (ENABLE_FEATURE_CLEAN_UP) {
+			free (pat);
+			free (mod);
+		}
+
+		return ret;
+	} else {
+		return fnmatch ( pat_src, mod_src, 0 );
+	}
+}
+
+/*
  * Builds the dependency list (aka stack) of a module.
  * head: the highest module in the stack (last to insmod, first to rmmod)
  * tail: the lowest module in the stack (first to insmod, last to rmmod)
@@ -730,7 +761,7 @@
 	 * Of course if the name in the dependency rule is a plain string,
 	 * then we consider it a pattern, and matching will still work. */
 	for ( dt = depend; dt; dt = dt-> m_next ) {
-		if ( fnmatch ( dt-> m_name, mod, 0 ) == 0) {
+		if ( check_pattern ( dt-> m_name, mod ) == 0) {
 			break;
 		}
 	}
@@ -746,7 +777,7 @@
 			struct dep_t *adt;
 
 			for ( adt = depend; adt; adt = adt-> m_next ) {
-				if ( strcmp ( adt-> m_name, dt-> m_deparr [0] ) == 0 )
+				if ( check_pattern ( adt-> m_name, dt-> m_deparr [0] ) == 0 )
 					break;
 			}
 			if ( adt ) {




More information about the busybox-cvs mailing list