6.10 Loading Device Drivers as Kernel Modules

Platform-specific differences are likely in the system administration commands and system calls that are used to administer device drivers.

Oracle Linux treats kernel modules and device drivers in the same way. Both kernel modules and device drivers can be added by using modprobe command, which is also used by the kernel module daemon kmod.

modprobe consults the module dependencies file /lib/modules/version/modules.dep to see if it must load any other modules before the requested module, and then runs insmod to load the prerequisite modules.

insmod uses the query_module() system call to retrieve the symbol table for a module and the create_module() system call to set up a module entry and reserve memory for the module before linking the module into the kernel and calling the init_module() system call to initialize the module.

If you use modprobe to delete a module, the command invokes the delete_module() system call.

Typically, kernel module compilation on Oracle Linux looks similar to the following command:

$ gcc -D__KERNEL__ -O2 -DMODULE -W -Wall -Wstrict-prototypes -Wmissing-prototypes \
  -isystem /lib/modules/`uname -r`/build/include -c flkm.c -o flkm