Patchwork [1/6] modutils-initscripts: improve modutils.sh

login
register
mail settings
Submitter Laurentiu Palcu
Date Jan. 17, 2013, 2:58 p.m.
Message ID <4408d9bb3008bf4f6f8575e1088bbaadd924e422.1358432402.git.laurentiu.palcu@intel.com>
Download mbox | patch
Permalink /patch/42807/
State Accepted
Commit 36a64307274c5940332ceb139d2b4eff33663e29
Headers show

Comments

Laurentiu Palcu - Jan. 17, 2013, 2:58 p.m.
modutils.sh reads /etc/modules to load the listed modules at boot time.
/etc/modules is generated by update-modules which scans
/etc/modules-load.d directory. However, update-modules became obsolete
because the files it generates are not used by modprobe anymore.

Hence, change modutils.sh to scan also /etc/modules-load.d/*.conf and
load the modules listed there.

Basically, the behavior is this:
 * if /etc/modules exists, load those modules;
 * if the directory /etc/modules-load.d exists, load the modules listed
   in the .conf files but ignore those already loaded (from
   /etc/modules);

[YOCTO #3598]

Signed-off-by: Laurentiu Palcu <laurentiu.palcu@intel.com>
---
 .../modutils-initscripts/files/modutils.sh         |   34 ++++++++++++++------
 1 file changed, 25 insertions(+), 9 deletions(-)

Patch

diff --git a/meta/recipes-kernel/modutils-initscripts/files/modutils.sh b/meta/recipes-kernel/modutils-initscripts/files/modutils.sh
index 9049bbb..a78adf5 100755
--- a/meta/recipes-kernel/modutils-initscripts/files/modutils.sh
+++ b/meta/recipes-kernel/modutils-initscripts/files/modutils.sh
@@ -13,7 +13,7 @@ 
 
 LOAD_MODULE=modprobe
 [ -f /proc/modules ] || exit 0
-[ -f /etc/modules ] || exit 0
+[ -f /etc/modules ] || [ -d /etc/modules-load.d ] || exit 0
 [ -e /sbin/modprobe ] || LOAD_MODULE=insmod
 
 if [ ! -f /lib/modules/`uname -r`/modules.dep ]; then
@@ -21,15 +21,31 @@  if [ ! -f /lib/modules/`uname -r`/modules.dep ]; then
 	depmod -Ae
 fi
 
+loaded_modules=" "
+
+process_file() {
+	file=$1
+
+	(cat $file; echo; ) |
+	while read module args
+	do
+		case "$module" in
+			\#*|"") continue ;;
+		esac
+		[ -n "$(echo $loaded_modules | grep " $module ")" ] && continue
+		[ "$VERBOSE" != no ] && echo -n "$module "
+		eval "$LOAD_MODULE $module $args >/dev/null 2>&1"
+		loaded_modules="${loaded_modules}${module} "
+	done
+}
+
 [ "$VERBOSE" != no ] && echo -n "Loading modules: "
-(cat /etc/modules; echo; ) |
-while read module args
-do
-	case "$module" in
-		\#*|"") continue ;;
-	esac
-	[ "$VERBOSE" != no ] && echo -n "$module "
-	eval "$LOAD_MODULE $module $args >/dev/null 2>&1"
+[ -f /etc/modules ] && process_file /etc/modules
+
+[ -d /etc/modules-load.d ] || exit 0
+
+for f in /etc/modules-load.d/*.conf; do
+	process_file $f
 done
 [ "$VERBOSE" != no ] && echo