Although we define these variables in the global namespace, why do we need to explicitly specify the permissions for every variable declared. Or is my way of thinking completely wrong?
int number = 100;
module_param(number, int , 0); // module_param(variable_name, variable_type , permissions);
What does '0' in permission attribute actually mean?
This permission flags value controls who can access the representation of the module parameter in sysfs. If perm is set to 0, there is no sysfs entry at all; otherwise, it appears under /sys/module with the given set of permissions.
Use S_IRUGO for a parameter that can be read by the world but cannot be changed;
S_IRUGO|S_IWUSR allows root to change the parameter. Note that if a parameter is changed by sysfs, the value of that parameter as seen by your module changes, but your module is not notified in any other way. You should probably not make module parameters writable, unless you are prepared to detect the change and react accordingly.
The only use of a parameter with perm = 0 will have is that you can set it at module load time, and that's it.
You need to explicitly specify the permissions for every variable if you want to override the default permissions which is 0 I think.
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