Module parameters
(__ ksymtab), kernel string table (__ kstrtab), and kernel CRC table (__ kcrctab) sections, marking it to be globally accessible. Figure 1 shows a filtered snippet of the / proc/kallsyms kernel window, before and after loading the module our_glob_syms.ko, which has been compiled using the usual driver Makefile.
The following code shows the supporting header file ( our_glob_syms.h), to be included by modules using the exported symbols cool_cl and get_cool_cl: Being aware of passing command-line arguments to an application, it would be natural to ask if something similar can be done with a module—and the answer is, yes, it can. Parameters can be passed to a module while loading it, for instance, when using insmod. Interestingly enough, and in contrast to the command-line arguments to an application, these can be modified even later, through sysfs interactions.
The module parameters are set up using the following macro (defined in <linux/moduleparam.h>, included through <linux/module.h>): module_param(name, type, perm)
Here, name is the parameter name, type is the type of the parameter, and perm refers to the permissions of the sysfs file corresponding to this parameter. The supported type values are: byte, short, ushort, int, uint, long, ulong, charp ( character pointer), bool or invbool ( inverted Boolean). The following module code ( module_ param. c) demonstrates a module parameter: #include <linux/module.h> #include <linux/kernel.h> static int cfg_value = 3; module_param(cfg_value, int, 0764); static int __init mod_par_init(void) { PRINTK(KERN_INFO “Loaded with %d\n”, cfg_value); return 0;