Is there anyway to do "insmod" and "rmmod" from C/C++ code? Other than running system(...), is there a Kernel API that will allow me to do this?
To unload a kernel module, we use the rmmod (remove module) command.
modprobe command is used to add and remove module from the kernel.
Loadable kernel modules in Linux are loaded (and unloaded) by the modprobe command. They are located in /lib/modules or /usr/lib/modules and have had the extension . ko ("kernel object") since version 2.6 (previous versions used the .o extension).
The lsmod command is used to display the status of modules in the Linux kernel. It results in a list of loaded modules. lsmod is a trivial program which nicely formats the contents of the /proc/modules , showing what kernel modules are currently loaded.
Have you looked at the module-init-tools source?
In addition to viewing the source for insmod
and module-init-tools you could strace
and ltrace
a run of insmod
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With