Lsmod actually reads and analyzes the/proc/modules File
cat /proc/modules
Information about the loaded modules in the kernel exists in/sys/modules. /sys/module is a sysfs directory level that contains information about the currently loaded modules. /proc/moudles is an old-style version of a single file with that information. the entry contains the module name, memory usage of each module, and usage count. in addition, the string is appended to the end of each line to specify the flag. This module is currently active.
Linux Kernel module program structure
1) load the function (generally required)
When the kernel module is loaded through insmod or modprobe, the module's loading function is automatically executed by the kernel.
Static int _ init initialization_function (void) {/* initialization Code */} module_init (initialization_function );
2) uninstall the function (generally required)
When the module is uninstalled through rmmod or modprobe-R.
Static int _ init cleanup_function (void) {/* release code */} module_exit (cleanup_function );
3) module license statement (required)
If the license is not declared, the kernel is contaminated when the module is loaded.
MODULE_LICENSE("GPL");
Optional license: "GPL", "GPL V2", "GPL and additional rights", "dual BSD/GPL ",
"Dual MPL/GPL", "proprietary ".
4) module parameters (optional)
module_param(parm, parm_type, module_flags);
If the permission permits, you can view the module parameters under/sys/modules/module_name/parameters.
5) module export symbol (optional)
Export_symbol (symbol name); export_symbol_gpl (symbol name );
6) module author and other information (optional)
MODULE_AUTHOR(author);MODULE_DESCRIPTION(description);MODULE_VERSION(version_string);MODULE_DEVICE_TABLE(table_info);MODULE_ALIAS(alternate_name);