[BusyBox] [PATCH] Fix kernel module autoloading (kmod)

jt at hpl.hp.com jt at hpl.hp.com
Tue Feb 15 01:24:32 UTC 2005


	Hi,

	Kernel modules autoloading doesn't work with BusyBox and
kernel 2.6.X. This feature is useful to load modules on-demand, to
minimise kernel memory footprint and power consumption. Anyway, the
fix was pretty tiny and safe.
	Patch is attached. I made the patch for busybox-1.00 but I've
verified that it applies smoothly to the 13-feb-05 snapshot.
	Have fun...

	Jean
-------------- next part --------------
diff -u -p modutils-old/insmod.c modutils/insmod.c
--- modutils-old/insmod.c	2004-09-02 16:03:25.000000000 -0700
+++ modutils/insmod.c	2005-02-14 14:03:02.000000000 -0800
@@ -3664,12 +3664,6 @@ extern int insmod_main( int argc, char *
 				case 'k':			/* module loaded by kerneld, auto-cleanable */
 					flag_autoclean = 1;
 					break;
-				case 's':			/* log to syslog */
-					/* log to syslog -- not supported              */
-					/* but kernel needs this for request_module(), */
-					/* as this calls: modprobe -k -s -- <module>   */
-					/* so silently ignore this flag                */
-					break;
 				case 'v':			/* verbose output */
 					flag_verbose = 1;
 					break;
diff -u -p modutils-old/modprobe.c modutils/modprobe.c
--- modutils-old/modprobe.c	2004-09-24 02:18:55.000000000 -0700
+++ modutils/modprobe.c	2005-02-14 14:04:54.000000000 -0800
@@ -400,15 +400,26 @@ static int mod_process ( struct mod_list
 		*lcmd = '\0';
 		if ( do_insert ) {
 			if (already_loaded (list->m_name) != 1)
+#ifdef CONFIG_FEATURE_2_6_MODULES
+				/* insmod_ng_main doesn't take command line
+				 * options. This would make kmod module
+				 * autoload fails. - Jean II */
+				snprintf ( lcmd, sizeof( lcmd ) - 1, "insmod %s %s",
+						list-> m_path, list-> m_options ?
+						list-> m_options : "" );
+#else
+				/* "-s" flag not supported. Jean II */
 				snprintf ( lcmd, sizeof( lcmd ) - 1, "insmod %s %s %s %s %s",
-						do_syslog ? "-s" : "", autoclean ? "-k" : "",
+						autoclean ? "-k" : "",
 						quiet ? "-q" : "", list-> m_path, list-> m_options ?
 						list-> m_options : "" );
+#endif
 		} else {
 			/* modutils uses short name for removal */
 			if (already_loaded (list->m_name) != 0)
-				snprintf ( lcmd, sizeof( lcmd ) - 1, "rmmod %s %s",
-						do_syslog ? "-s" : "", list-> m_name );
+				/* "-s" flag not supported. Jean II */
+				snprintf ( lcmd, sizeof( lcmd ) - 1, "rmmod %s",
+						list-> m_name );
 		}
 
 		if (*lcmd) {
diff -u -p modutils-old/rmmod.c modutils/rmmod.c
--- modutils-old/rmmod.c	2004-07-20 11:36:51.000000000 -0700
+++ modutils/rmmod.c	2005-02-14 13:55:18.000000000 -0800
@@ -65,7 +65,7 @@ extern int rmmod_main(int argc, char **a
 #endif
 
 	/* Parse command line. */
-	while ((n = getopt(argc, argv, "a")) != EOF) {
+	while ((n = getopt(argc, argv, "afw")) != EOF) {
 		switch (n) {
 			case 'w':       // --wait
 				flags &= ~O_NONBLOCK;


More information about the busybox mailing list