The following script
edits the kernel version information of a module to match the running
kernel. Note that this does not update the module code to fix any actual
kernel API discrepancies, but simply masquerades the module as having
been compiled under a different version. This allows the module's insertion
without warnings using a plain insmod call, but by no means guarantees
the module's functioning.
The script is given below, but is also available for download at http://walbran.org/sean/linux/stodolsk/fixscript
Note that the script must be made executable by something like
chmod +x fixscript.
The script:
#! /bin/bash
# To make this file executable: chmod +x fixscript
# This is a very slight edit of the ltfixscript contributed to
# the Linmodems Newslist
# From - Sun Jul 23 04:27:38 2000
# From: "Mark Spieth" <mark at digivation.com.au>
# To: <discuss@linmodems.org>
# Subject: ltmodem symbols and version fixed
# Date: Sun, 23 Jul 2000 12:39:44 +1000
# Organization: Digivation Pty Ltd
echo "Fixscript V1.21"
if [ -z "$1" -o -z "$2" ]; then
cat <<END
This script changes version number tags of binary
kernel modules to match the version of the currently
running kernel. It also renames any symbol that the
current kernel cannot resolve into their equivalent
resolvable symbols.
For inserting binary modules into kernels, the fixed
module can be inserted with:
insmod module
which is used in automated kernel module management,
rather than forcing module loading with:
insmod -f module
which is necessary when kernel and module versions
are not matched.
WARNING! This change is purely cosmetic, and the use
of version matched binaries whenever possible is
strongly advised. It may crash your kernel due to
inconsistencies in data structures between the kernel
as it stands and the headers used to originally compile
the module being fixed. No guarantees are given or implied
under any circumstances.
GNU objcopy version 2.9.5 or later is required;
this is provided as part of the binary utilities
packages such as the Debian binutils.deb
USAGE: fixscript input-file output-file
END
exit 1
fi
MI=/tmp/modinfo
DI=/tmp/depinfo
#new kernel version modinfo section
echo -ne "kernel_version="`uname -r`"\0" > $MI
#build the objcopy command
CMD="objcopy"
#for i in `depmod -e $1 | grep -vE "^$1:"` ; do
depmod -e $1 2>$DI
AWKSTR=\$2
for i in `awk "{print $AWKSTR}" $DI | grep _R` ; do
echo doing $i
i1=`echo $i | awk '{
gsub(/_R[0-9a-fA-F]+/,"");
printf("%s", $1);
}'`
echo "i1=" $i1
echo " trunc=\"$i1\""
searchstr=$i1"_R"
echo "searchstr=" $searchstr
new=`cat /proc/ksyms | grep $searchstr | awk "{print $AWKSTR}"`
echo " new=$new"
CMD="$CMD --redefine-sym=$i=$new"
done
#replace the modinfo section with the new one
CMD="$CMD --remove-section=.modinfo --add-section=.modinfo=$MI"
CMD="$CMD $*"
#run the command
echo "CMD:" $CMD
$CMD
#remove the section file
rm -f $MI
rm -f $DI
The Lucent driver installation script defaults to having the module loaded upon boot, by appending the line
insmod -f ltmodemto the end of the initialization script
/etc/rc.d/rc.local. If
you have, i.e., an ESS modem, you could replace "ltmodem" with "esscom"
above to have your module automatically loaded on boot. Note, however,
that the initialization scripts differ with different Linux distributions,
so you will need to find, modify, or create the appropriate script(s) for your
particular setup.
However, many users prefer to run "lean kernels" which only have the auxiliary modules inserted when necessary. Below are examples of scripts for starting and stopping an online session using a Lucent winmodem with the ltmodem.o driver. It can be applied to many other drivers by simply replacing "ltmodem" with "YourModemDriver".
Modemup:
#!/bin/sh # This script inserts the kernel modules supporting # WinModems using the Lucent ltmodem.o module. # Save as /usr/local/bin/Modemup, then # chmod a+x /usr/local/bin/Modemup # to make it executable. # Since insmod & rmmmod require root permission, permission for an # ordinary User must be given under secure-su or sudo. # # the ltmodem.o driver must be within /lib/modules/kernl-version/misc # # When kernel-source-2.?.?? code becomes available for ltmodem.o , # forced "-f" insertion should be removed from the following line: /sbin/insmod -f ltmodem # and the complaint about version mis-match will also then disappear. insmod slhc # is needed to support ppp insmod ppp # if you are using a ppp.o which is not version matched with the kernel # insmod -f ppp # may be necessary instead echo Loaded kernel modules are: lsmod # An automatic start of the ppp connection is specified # by entering the command that starts your online session such as: # wvdial, pon, ppp-on, kppp or # Whatever ## End Modemup
Modown:
#! /bin/sh # /usr/local/bin/Modown ends a pppd session and does cleanup. # Save as /usr/local/bin/Modown, then # chmod a+x /usr/local/bin/Modown # Starting pppd session related modules are: # ppp_deflate 39108 1 (autoclean) # bsd_comp 3664 0 (autoclean) # ppp 19916 2 (autoclean) [ppp_deflate bsd_comp] # slhc 4200 1 (autoclean) [ppp] # ltmodem 452936 1 # NOTE THAT ltmodem did NOT acquire autoclean status echo " " echo Terminating ppp0 with poff poff sleep 1 # is a pause to let the poff process to terminate, after which /sbin/rmmod ltmodem # removes ltmodem.o module echo " " echo Removed module ltmodem # /sbin/lsmod # echo " " # echo A pause before removing modules ppp_deflate bsd_comp, then ppp slhc sleep 1 /sbin/rmmod ppp_deflate bsd_comp /sbin/rmmod ppp slhc /sbin/lsmod # but doesn't remove the sound related modules called up. Thus echo " " echo Removing sound related module called by LTmodem, soundcore echo " " if not otherwise in use. /sbin/rmmod soundcore echo Remaining modules in kernel-`uname -r` are: /sbin/lsmod # displays remaining modules echo " " ## End Modown
Example PPP scripts configured for a Debian installation by pppconfig are:
/etc/ppp/peers/provider:
# This optionfile was generated by pppconfig 2.0.5. hide-password noauth connect "/usr/sbin/chat -v -f /etc/chatscripts/provider" debug /dev/ttyS14 # port used by the Lucent Winmodem 115200 defaultroute noipdefault user NameAtIP remotename provider ipparam provider
/etc/chatscripts/provider:
# This chatfile was generated by pppconfig 2.0.5. # Please do not delete any of the comments. Pppconfig needs them. # # ispauth PAP # abortstring ABORT BUSY ABORT 'NO CARRIER' ABORT VOICE ABORT 'NO DIALTONE' ABORT 'NO DIAL TONE' ABORT 'NO ANSWER' # modeminit '' ATZ OK ATQ0V1E1S0=0&C1&D2S11=55+FCLASS=0 # ispnumber OK-AT-OK ATDT3019178111 # ispconnect CONNECT \d\c # prelogin # ispname # isppassword # postlogin # end of pppconfig stuff
The following is quoted from one of the PCTel readme files. My interpretation of this is that you should do something like
insmod pctel.o country_sel=7(depending on your country code, below). If this works for you (or doesn't), please let me know at sean(at)walbran.org
Set and report country code.
This driver takes a module parameter to setup the correct country code
setting for various country's telephone networks and it also can report
back the country code been set.
Here are the two versions for country_code selection and reporting:
VERSION #1:
To set country code:
"country_sel_rep sel 7" will sets the country code to 7.
To query the driver for the currently set country code:
"country_sel_rep rep" returns the current country code as the exit code.
VERSION #2:
To set country code:
"country_sel 7" to set the country code to 7.
To query the driver for the currently set country code:
"country_rep" return the current country code as the exit code.
country_code country_name
1 USA
2 FRANCE
3 GERMANY
4 ITALY
5 SWEDEN
6 UK
7 JAPAN
8 AUSTRALIA
9 SPAIN
10 TAIWAN
11 SINGAPORE
12 KOREA
13 SWITZERLAND
14 NORWAY
15 NETHERLANDS
16 BELGIUM
17 CANADA
18 IRELAND
19 PORTUGAL
20 POLAND
21 HUNGARY
22 FINLAND
23 DENMARK
24 AUSTRIA
25 S.AFRICA
26 CTR21 COUNTRIES
27 CHINA
28 MALAYSIA
29 LUXUMBURG
30 GREECE
31 ICELAND
32 NEW ZEALAND
33 BRAZIL