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 namedbar
:cat /proc/cmdline
. Example output:BOOT_IMAGE=/vmlinuz root=/dev/sda1 foo.bar=some-value
insmod
ormodprobe
:modprobe foo bar=some-value
.bar
for modulefoo
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 asacpi.debug_level
for the kernel command line or as the/sys/module/acpi/parameters/debug_level
sysfs entry.