svn commit: trunk/busybox/modutils

landley at busybox.net landley at busybox.net
Wed Jun 14 01:51:18 UTC 2006


Author: landley
Date: 2006-06-13 18:51:16 -0700 (Tue, 13 Jun 2006)
New Revision: 15382

Log:
Attempt at fixing bug 836, vaguely based on patch from somebody named
clausmuus, forwarded to me by Yann E. Morin.


Modified:
   trunk/busybox/modutils/modprobe.c


Changeset:
Modified: trunk/busybox/modutils/modprobe.c
===================================================================
--- trunk/busybox/modutils/modprobe.c	2006-06-14 01:27:01 UTC (rev 15381)
+++ trunk/busybox/modutils/modprobe.c	2006-06-14 01:51:16 UTC (rev 15382)
@@ -574,7 +574,7 @@
 /* return 1 = loaded, 0 = not loaded, -1 = can't tell */
 static int already_loaded (const char *name)
 {
-	int fd;
+	int fd, ret = 0;
 	char buffer[4096];
 
 	fd = open ("/proc/modules", O_RDONLY);
@@ -586,17 +586,28 @@
 
 		p = strchr (buffer, ' ');
 		if (p) {
+			const char *n;
+
+			// Truncate buffer at first space and check for matches, with
+			// the idiosyncrasy that _ and - are interchangeable because the
+			// 2.6 kernel does weird things.
+
 			*p = 0;
-			for( p = buffer; ENABLE_FEATURE_2_6_MODULES && *p; p++ ) {
-				*p = ((*p)=='-')?'_':*p;
+			for (p = buffer, n = name; ; p++, n++) {
+				if (*p != *n) {
+					if ((*p == '_' || *p == '-') && (*n == '_' || *n == '-'))
+						continue;
+					break;
+				}
+				// If we made it to the end, that's a match.
+				if (!*p) {
+					ret = 1;
+					goto done;
+				}
 			}
-			if (strcmp (name, buffer) == 0) {
-				close (fd);
-				return 1;
-			}
 		}
 	}
-
+done:
 	close (fd);
 	return 0;
 }
@@ -628,14 +639,16 @@
 		if ( do_insert ) {
 			if (already_loaded (list->m_name) != 1) {
 				argv[argc++] = "insmod";
-				if (do_syslog)
-					argv[argc++] = "-s";
-				if (autoclean)
-					argv[argc++] = "-k";
-				if (quiet)
-					argv[argc++] = "-q";
-				else if(verbose) /* verbose and quiet are mutually exclusive */
-					argv[argc++] = "-v";
+				if (ENABLE_FEATURE_2_4_MODULES) {
+					if (do_syslog)
+						argv[argc++] = "-s";
+					if (autoclean)
+						argv[argc++] = "-k";
+					if (quiet)
+						argv[argc++] = "-q";
+					else if(verbose) /* verbose and quiet are mutually exclusive */
+						argv[argc++] = "-v";
+				}
 				argv[argc++] = list-> m_path;
 				if( ENABLE_FEATURE_CLEAN_UP )
 					argc_malloc = argc;




More information about the busybox-cvs mailing list