Modules with parameters
Modules with parameters Everybody knows that modules can take parameters, either via /sys/modules/<module>/parameters, sysctl 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:
1module_param(name, type, perm) Which will simply create the module parameter and expose it as an entry in /sys/modules/<module>/parameters.
Code example 1int debug_flag; 2module_param(debug_flag, bool, S_IRUSR | S_IWUSR | S_IRGRP) 3MODULE_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