Bug#192232: patch for getting modconf work for 2.4/2.6 kernels
Hello,
I made a new patch against modconf 0.2.44 to get
Orientated upon the patch of the pervious sender (thanks a lot) I tried
to do a few things more:
- Detect what kernel version is running and set the apropriate suffix
(.o or .ko) to get it work for all kernel-versions
(the new function modul_suffix in modules/util)
- In Kernel Version 2.6 all the modules in /proc/modules have no minus
signs in the name (module names and the name out of /proc/modules
differ)
But in Kernel Version 2.4.x the names are the same.
So I had to use the function mkmodulevarname in the function
module_is_installed.
- changed all occurrences of the suffix .o / *.o to $modsuffix / $modend
Things still TODO:
The file /etc/modules.conf should not be used for 2.6.x (or not ??)
Instead /etc/modprobe.conf
Can I help further with some modconf changes ?
(I only know a little bash and perl but no C)
If yes please mail.
Thanks
Thomas Braun
diff -Nur modconf-0.2.44/mkdescr.pl modconf-0.2.44_patched/mkdescr.pl
--- modconf-0.2.44/mkdescr.pl Fri Feb 8 23:10:35 2002
+++ modconf-0.2.44_patched/mkdescr.pl Wed Dec 3 03:03:59 2003
@@ -23,7 +23,7 @@
elsif (m,^ Load command:,) {
$state="loadcommand";
}
- elsif (m, */sbin/modprobe (.*)\.o( (.*)|)$,) {
+ elsif (m, */sbin/modprobe (.*)\.k?o( (.*)|)$,) {
if ($state eq "modprobe") {
if ( $count == 0 ) {
print " $module $params\n \n";
diff -Nur modconf-0.2.44/modconf modconf-0.2.44_patched/modconf
--- modconf-0.2.44/modconf Sun Jan 27 22:43:36 2002
+++ modconf-0.2.44_patched/modconf Wed Dec 3 16:33:48 2003
@@ -114,7 +114,7 @@
echo '" " " " \' >> $TempFile
for directory in $dir_descrs; do
- if [ ! -d $Dir_Prefix/$directory -a $Source = mounted ]; then
+ if [ ! -d $Dir_Prefix/$directory -a $Source = mounted ]; then
continue;
fi
@@ -196,6 +196,7 @@
return 1
fi
+modul_suffix
check_dirs
check_modules
check_modules_conf
@@ -211,15 +212,15 @@
dir_descrs=""
for i in $(get_modules_dirs $Dir_Prefix); do
if [ -d $Dir_Prefix/$i -a \
- -f $(first $Dir_Prefix/$i/*.o) ]; then
- if [ -n "$Exclude_Section" ] &&
+ -f $(first $Dir_Prefix/$i/$modend) ]; then
+ if [ -n "$Exclude_Section" ] &&
in_list $i $Exclude_Section ; then
true
else
dir_descrs="$dir_descrs $i"
fi
fi
- done
+ done
fi
s=$(second $Restrict_Section)
diff -Nur modconf-0.2.44/modules/util modconf-0.2.44_patched/modules/util
--- modconf-0.2.44/modules/util Sun Feb 3 18:50:06 2002
+++ modconf-0.2.44_patched/modules/util Wed Dec 3 17:18:53 2003
@@ -26,13 +26,23 @@
}
mkmodulevarname () {
- echo $1 | $sed 's/[-+,]/_/g'
+ echo $* | $sed 's/[-+,]/_/g'
+}
+
+modul_suffix () {
+
+local kverbase=$(echo $(uname -r) | cut -f2 -d.)
+ case $kverbase in
+ 2|3|4) modsuffix=".o" ;;
+ 5|6|*) modsuffix=".ko" ;;
+ esac
+modend=\*$modsuffix
}
basemodulename () {
local module=$1
- # strip off .o suffix
- module=${module%.o}
+ # strip off the apropriate suffix
+ module=${module%$modsuffix}
# strip off path prefix
module=${module##*/}
echo $module
@@ -50,14 +60,14 @@
build_lists () {
if [ -f /proc/modules ]; then
- installed_module_list="$(sed -e 's/\([^ ]\)[ ].*/\1/' < /proc/modules)"
+ installed_module_list="$(cut -f1 "-d " /proc/modules)"
fi
return 0;
}
build_chandev_list () {
kver=`uname -r`
- chandev_module_list="$(for file in `find /lib/modules/$kver -name "*.o"`; do grep -q "chandev_register" $file; if [ $? -eq 0 ]; then basemodulename $file; fi; done | sort -u)"
+ chandev_module_list="$(for file in `find /lib/modules/$kver -name $modend`; do grep -q "chandev_register" $file; if [ $? -eq 0 ]; then basemodulename $file; fi; done | sort -u)"
return 0;
}
@@ -75,7 +85,8 @@
}
module_is_installed () {
- in_list $1 "$installed_module_list"
+ local module=$1
+ in_list $(mkmodulevarname $module) $(mkmodulevarname $installed_module_list)
return $?
}
@@ -130,11 +141,11 @@
if [ "$Source" = "floppy" ]; then
eval "list=$`echo dir_content_$directory`"
else
- list="$Dir_Prefix/$directory/*.o"
+ list=$Dir_Prefix/$directory/$modend
fi
for i in $list; do
- # Strip directory and .o suffix
+ # Strip directory and suffix
local module=$(basemodulename $i)
if [ "$module" != '*' ]; then
@@ -193,7 +204,7 @@
esac
done
else
- result=$(basemodulename $Dir_Prefix/$directory/$result.o)
+ result=$(basemodulename $Dir_Prefix/$directory/$result$modsuffix)
fi
edit_module "$result"
@@ -337,7 +348,7 @@
if [ ! -f /floppy/modules.tgz ]; then
write_it_down "$msg_tgz_does_not_exist"
fi
- (cd /; zcat < /floppy/modules.tgz | $extract \*/$module.o)
+ (cd /; zcat < /floppy/modules.tgz | $extract \*/$module$modsuffix)
file="/lib/modules/*/*/$module.o"
echo "$msg_done"
depmod -a
Reply to: