I'm new to kernel programming. When I was going through module_param
, I was confused by the permission value 0. It was explained that it won't get an entry in sysfs, while the others like S_IRUGO
would get an entry. I couldn't understand the concept.
What does the perm value 0 indicate?
When do we need a sysfs entry? What is the need for that?
Kindly guide me. Thanks in advance.
You can module parameters in some ways to a kernel module. Assuming a kernel module foo
with a parameter named bar
:
- Using the kernel command line which can be provided in your bootloader configuration. To see the command line for the current boot, run
cat /proc/cmdline
. Example output: BOOT_IMAGE=/vmlinuz root=/dev/sda1 foo.bar=some-value
- While loading a kernel module using
insmod
or modprobe
: modprobe foo bar=some-value
.
- When a module is loaded, you can usually see find the parameter
bar
for module foo
at /sys/module/foo/parameters/bar
.
A permission value of 0
prevents the sysfs entry from being created (third bullet above). An example usage in the kernel code is to allow for enabling debug without exposing this parameter in sysfs.
An example of a readable/writable module parameter is acpi
. It allows you to dynamically set the debugging information that should be generated. Available as acpi.debug_level
for the kernel command line or as the /sys/module/acpi/parameters/debug_level
sysfs entry.