Module parameter permission

你说的曾经没有我的故事 提交于 2019-12-11 00:57:11

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/14355114/module-parameter-permission

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!