Modules with parameters
Modules with parameters Everybody knows that modules can take parameters, either via /sys/modules/<module>/parameters or via cmdline to the kernel, but how are these parameters created?
Parameters without callbacks The Linux kernel provides the module_param() macro. The syntax is:
module_param(name, type, perm) Which will simply create the module parameter and expose it as an entry in /sys/modules/<module>/parameters.
Code example int debug_flag; module_param(debug_flag, bool, S_IRUSR | S_IWUSR | S_IRGRP) MODULE_PARM_DESC(debug_flag, "Set to 1 if debug should be enabled, 0 otherwise"); MODULE_PARM_DESC() is a short description of the parameter.
Posted by Marcus Folkesson on Tuesday, June 27, 2017