Kernel Modules

 < Day Day Up > 



We have already learned that a modular kernel makes the job of system programmers easy to provide drivers to the new devices or to update current drivers. In fact, every high-level component such as the file systems or device drivers can be implemented in modules. There are commands to ask the kernel what modules are already loaded, to load a module into the already running kernel, to unload a module from the running kernel, and to check dependencies between modules.

The lsmod command at the Linux command prompt displays all the modules that are currently loaded in the kernel.

[root@etslinux root]lsmod

The letters in bold indicate a typical boot prompt in the command line window. The boot prompt may be changed as we desire, and we will discuss this later in this chapter.

The typical output displayed is shown in Listing 2.3.

Listing 2.3

start example
 Module                  Size  Used by    Not tainted sd_mod                 13584   0  (autoclean) (unused) sb                      9236   1  (autoclean) sb_lib                 44750   0  (autoclean) [sb] uart401                 8420   0  (autoclean) [sb_lib] sound                  74388   1  (autoclean) [sb_lib uart401] soundcore               6532   5  (autoclean) [sb_lib sound] radeon                 93976  11  agpgart                43072   3  parport_pc             19108   1  (autoclean) lp                      8996   0  (autoclean) parport                37152   1  (autoclean) [parport_pc lp] autofs                 13348   0  (autoclean) (unused) 3c59x                  30640   1  ipt_REJECT              3736   6  (autoclean) iptable_filter          2412   1  (autoclean) ip_tables              14936   2  [ipt_REJECT iptable_filter] ide-scsi               10512   0  scsi_mod              107176   2  [sd_mod ide-scsi] ide-cd                 33608   0  cdrom                  33696   0  [ide-cd] mousedev                5524   1  keybdev                 2976   0  (unused) hid                    22244   0  (unused) input                   5888   0  [mousedev keybdev hid] usb-uhci               26188   0  (unused) usbcore                77024   1  [hid usb-uhci] ext3                   70368   6  jbd                    52212   6  [ext3]
end example

The listing shows the modules loaded, size of module, number of times the module is used, and the module that is using another specific module.

The insmod command is used to load a specific module into a running kernel. The syntax of the command is shown below.

 [root@etslinux root] insmod <module name> [root@etslinux root] insmod <parport>

The letters in bold indicate a typical boot prompt. The first line shows the general command format, and the second line shows a specific module name. In this example, the parport module is loaded from the parport.o module file. If the module is already loaded by the kernel, a message is displayed accordingly. For this command to be successful, it is necessary that the specific module should have been installed, usually by the package manager.

The rmmod command is used to unload a module from the running kernel, as shown here.

[root@etslinux root] rmmod <module name> [root@etslinux root] rmmod <parport> 

When trying to unload a module that is being used by another module, a message is displayed saying that the device or resource is busy. To unload such a module, first we have to unload the module that is using this module, and then we will be successful in unloading the modules. If modules are used in a hierarchical style, then we have to unload the module in the reverse order.

There are other commands, such as depmod, and modprobe, which may be used to define and create module dependency file and load the modules with the help of the module dependency file, respectively. More detail about these commands may be obtained from the respective manual pages.



 < Day Day Up > 



Linux Application Development For The Enterprise
Linux Application Development For The Enterprise (Charles River Media Programming)
ISBN: 1584502533
EAN: 2147483647
Year: 2002
Pages: 86

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net