Load and unload operations

Modules can be deployed through special tools that are part of an application package called modutils, of which insmod and rmmod are widely used. insmod is used to deploy the module into kernel address space and rmmod is used for unloading a live module. These tools initiate load/unload operations by invoking appropriate system calls:

int finit_module(int fd, const char *param_values, int flags);int delete_module(const char *name, int flags);

Here, finit_module() is invoked (by insmod) with the file descriptor of the specified module binary file (.ko) and other relevant arguments. This function steps into kernel mode by invoking the underlying system call:

SYSCALL_DEFINE3(finit_module, int, fd, const char __user ...

Get Mastering Linux Kernel Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.