1. Install module-init-Tools
Module-init-tools content
Installed program:Depmod, insmod, insmod. Static, lsmod (link to insmod), modinfo, modprobe (link to insmod), rmmod (link to insmod) Brief Description
| Depmod |
Create a dependency file that can load the kernel module. Use modprobe to automatically load the module. |
| Insmod |
Load modules to the running kernel |
| Insmod. Static |
Static compilation version of insmod |
| Lsmod |
Displays information about the currently loaded kernel modules. |
| Modinfo |
Check the target file associated with the kernel module and print all information that can be obtained. |
| Modprobe |
Use the dependency File Created by depmod to automatically load relevant modules |
| Rmmod |
Detach a module from the current Kernel |
2. You need to upgrade modutils.
# Rpm-e -- nodeps modutils (Force uninstall the original modutilsrpm package)
# Rpm-IVH modutils-2.4.21-23.src.rpm (install the source code package to the/usr/src/redflag/directory [my computer system is Red Flag Linux])
1: modutils warning: User KAOS does not exist-using root
Warning: group OCs does not exist-using root
######################################## ### [100%]
Warning: User KAOS does not exist-using root
Warning: group OCs does not exist-using root
# Cd/usr/src/RedHat/specs (go to the standard file directory)
So far, everything went well!
# Rpmbuild -- BB modutils. SPEC (generate a binary RPM package)
After the command is executed, the problem starts ......
Error:
Error: Legacy syntax is unsupported: Copyright
Error: Line 5: Unknown Tag: Copyright: GPL
Check the information online and check the 5th lines in modutils. spec.
Copyright: Change GPL to license: GPL
OK. The RPM file has been compiled and an error will be reported soon.
In file encoded ded from obj_kallsyms.c: 26:
../Include/util. h: 42: Warning: Built-in function 'log' declared as non-function
Obj_kallsyms.c: In function 'obj32 _ kallsyms ':
Obj_kallsyms.c: 204: Error: lvalue required as left operand of assignment
Obj_kallsyms.c: 279: Error: lvalue required as left operand of assignment
Make [1]: *** [obj_kallsyms.o] Error 1
Make [1]: Leaving directory '/usr/src/redflag/build/modutils-2.4.27/obj'
Make: *** [all] Error 2
Modify the obj_kallsyms.c file as follows:
Set
A_hdr = (struct kallsyms_header *) OSEC-> contents =
Xmalloc (OSEC-> header. sh_size );
Change
OSEC-> contents = xmalloc (OSEC-> header. sh_size );
A_hdr = (struct kallsyms_header *) OSEC-> contents;
Set
A_hdr = (struct kallsyms_header *) OSEC-> contents =
Xrealloc (a_hdr, a_hdr-> total_size );
Change
OSEC-> contents = xrealloc (a_hdr, a_hdr-> total_size );
A_hdr = (struct kallsyms_header *) OSEC-> contents;
Then compress the changes back to ../sources/modutils-2.4.27.tar.gz in the package
You cannot save the changes. Therefore, you must decompress the changes and compress them to overwrite them,
In this case, we will not repeat it. Then proceed.
Error:
In file encoded ded from insmod. C: 79:
../Include/util. h: 42: Warning: Built-in function 'log' declared as non-function
Insmod. C: In function 'add _ symbols_from ':
Insmod. C: 278: Error: lvalue required as left operand of assignment
Make [1]: *** [insmod. O] Error 1
Make [1]: Leaving directory '/usr/src/redflag/build/modutils-2.4.27/insmod'
Make: *** [all] Error 2
Error: Bad exit status from/var/tmp/rpm-tmp.36012 (% build)
Set the 278th line of the insmod. c file
(Char *) S-> name) + = 8;
Change
S-> name = (void *) (long) (s-> name) + 8 );
Continue compilation,
Continue to report the following error:
In file encoded ded from genksyms. C: 32:
../Include/util. h: 42: Warning: Built-in function 'log' declared as non-function
Genksyms. C: 48: Error: static declaration of 'errors' follows non-static Declaration
../Include/util. h: 43: Error: previous declaration of 'errors' was here
Make [1]: *** [genksyms. O] Error 1
Make [1]: Leaving directory '/usr/src/redflag/build/modutils-2.4.27/genksyms'
Make: *** [all] Error 2
Error: Bad exit status from/var/tmp/rpm-tmp.97956 (% build)
Returns the statement in line 2 of genksyms. C.
Static int errors;
Remove static,
Continue to report the following error:
In file encoded ded from depmod. C: 44:
../Include/util. h: 42: Warning: Built-in function 'log' declared as non-function
Depmod. C: In function 'addksyms ':
Depmod. C: 1136: Error: lvalue required as left operand of assignment
Make [1]: *** [depmod. O] Error 1
Make [1]: Leaving directory '/usr/src/redflag/build/modutils-2.4.27/depmod'
Make: *** [all] Error 2
Error: Bad exit status from/var/tmp/rpm-tmp.36319 (% build)
Set depmod. C's 1,136th rows
(Char *) ksym-> name) + = 8;
Change
Ksym-> name = (void *) (long) (ksym-> name) + 8 );
Continue ......
Requires (rpmlib): rpmlib (compressedfilenames) <= 3.0.4-1 rpmlib (payloadfileshaveprefix) <= 4.0-1
Requires:/bin/sh libc. so.6 libc. so.6 (glibc_2.0) libc. so.6 (glibc_2.1) libc. so.6 (glibc_2.1.3) libc. so.6 (glibc_2.3)
Checking for unpackaged file (s):/usr/lib/RPM/check-files/var/tmp/modutils-Root
Warning: installed (but unpackaged) file (s) found:
/Sbin/kallsyms. Static
/Sbin/ksyms. Static
/Sbin/lsmod. Static
/Sbin/modprobe. Static
/Sbin/rmmod. Static
Wrote:/usr/src/redflags/RPMS/i386/modutils-2.4.27-1.i386.rpm
Executing (% clean):/bin/sh-E/var/tmp/rpm-tmp.85202
+ Umask 022
+ CD/usr/src/redflag/build
+ CD modutils-2.4.27
+ RM-RF/var/tmp/modutils-Root
+ Exit 0
OK. It's so tired !!!
# CD ../RPMS/i386 (transfer to the location of the generated binary RPM package)
# Rpm-IVH modutils *. rpm
Preparing... ######################################## ### [100%]
File/usr/share/man/Man2/delete_module.2.gz from install of modutils-2.4.27-1 conflicts with file from package man-pages-2.21-4
File/usr/share/man/Man2/init_module.2.gz from install of modutils-2.4.27-1 conflicts with file from package man-pages-2.21-4
File/sbin/depmod from install of modutils-2.4.27-1 conflicts with file from package module-init-tools-3.2-0.pre9.2.2.2
File/sbin/insmod from install of modutils-2.4.27-1 conflicts with file from package module-init-tools-3.2-0.pre9.2.2.2
File/sbin/insmod. Static From install of modutils-2.4.27-1 conflicts with file from package module-init-tools-3.2-0.pre9.2.2.2
File/sbin/lsmod from install of modutils-2.4.27-1 conflicts with file from package module-init-tools-3.2-0.pre9.2.2.2
File/sbin/modinfo from install of modutils-2.4.27-1 conflicts with file from package module-init-tools-3.2-0.pre9.2.2.2
File/sbin/modprobe from install of modutils-2.4.27-1 conflicts with file from package module-init-tools-3.2-0.pre9.2.2.2
File/sbin/rmmod from install of modutils-2.4.27-1 conflicts with file from package module-init-tools-3.2-0.pre9.2.2.2
File/usr/share/man/man8/depmod.8.gz from install of modutils-2.4.27-1 conflicts with file from package module-init-tools-3.2-0.pre9.2.2.2
File/usr/share/man/man8/insmod.8.gz from install of modutils-2.4.27-1 conflicts with file from package module-init-tools-3.2-0.pre9.2.2.2
File/usr/share/man/man8/lsmod.8.gz from install of modutils-2.4.27-1 conflicts with file from package module-init-tools-3.2-0.pre9.2.2.2
File/usr/share/man/man8/modinfo.8.gz from install of modutils-2.4.27-1 conflicts with file from package module-init-tools-3.2-0.pre9.2.2.2
File/usr/share/man/man8/modprobe.8.gz from install of modutils-2.4.27-1 conflicts with file from package module-init-tools-3.2-0.pre9.2.2.2
File/usr/share/man/man8/rmmod.8.gz from install of modutils-2.4.27-1 conflicts with file from package module-init-tools-3.2-0.pre9.2.2.2
The RPM generated before installation. The above prompt shows that there are some conflicts between the existing settings on my computer and the RPM package, probably because the kernel version of the computer itself is very high, there is something inconsistent with the modultils-2.4. I don't know whether it will affect the later kernel compilation. Let's talk about it later. Originally want to find modultils-2.6, which knows even WWW, kernel.org website can not find, the easy to use to see the latest modultils-2.4.27
3. Finally, you can use/sbin/insmod and/sbin/rmmod to load and uninstall the driver to the kernel.
[Root @ localhost simple] # ll/sbin/insmod/sbin/rmmod
-Rwxr-XR-x 1 Root 4924/sbin/insmod
-Rwxr-XR-x 1 Root 8264/sbin/rmmod
Treat insmod and rmmod as separate executable files.