模块参数权限 [英] Module parameter permission

查看:68
本文介绍了模块参数权限的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是内核编程的新手.当我浏览module_param时,我对权限值0感到困惑.有人解释说,它不会在sysfs中获得输入,而其他类似S_IRUGO的则会获得输入.我不明白这个概念.

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.

烫发值0表示什么? 什么时候需要sysfs条目?有什么需要?

What does the perm value 0 indicate? When do we need a sysfs entry? What is the need for that?

请指导我.预先感谢.

推荐答案

您可以通过某些方式将参数模块化为内核模块.假设内核模块foo具有名为bar的参数:

You can module parameters in some ways to a kernel module. Assuming a kernel module foo with a parameter named bar:

  • 使用可以在引导加载程序配置中提供的内核命令行.看命令行当前引导,运行.输出示例:BOOT_IMAGE=/vmlinuz root=/dev/sda1 foo.bar=some-value
  • 使用insmodmodprobe加载内核模块时:modprobe foo bar=some-value.
  • 加载模块时,通常可以在/sys/module/foo/parameters/bar上找到找到模块foo的参数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.

权限值0阻止创建sysfs条目(上面的第三个项目符号).内核代码中的一个示例用法是允许启用调试而无需在sysfs中公开此参数.

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.

可读/可写模块参数的示例是acpi.它允许您动态设置应生成的调试信息.可作为acpi.debug_level用于内核命令行或作为/sys/module/acpi/parameters/debug_level 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.

这篇关于模块参数权限的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆