Module parameters in sysfs

2.6内核中引入了一项新补丁,实现了模块参数在sysfs文件系统中的显示。此补丁创建了/sys/module目录,并为每个加载的模块设置子目录。对于不可卸载的模块,会设置只读参数refcnt,显示模块引用计数。此外,如果模块参数的perm值非零,则会在sysfs中创建相应的属性。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

In the 2.6 kernel, parameters to loadable modules are set up with the module_param() macro:

    module_param(name, type, perm);

The perm parameter was set aside for the sysfs representation ofthis parameter but has, until now, been unused; almost every declaredparameter simply sets it to zero in the 2.6.6 kernel. A new patch has been posted, however, whichmakes module parameters in sysfs a reality.

This patch creates a new /sys/module directory; a subdirectorywill be created for each module loaded into the system. For unloadablemodules, a read-only parameter (called refcnt) will be set upwhich contains the module's current reference count. There will also beattributes for every module parameter whose perm value is notzero; that value will, as expected, set the permissions mask for thatparameter.

If the permissions mask allows, module parameters will be writable. Intheory, this will give module authors an easy way to exportadministrator-tweakable knobs to user space. It is worth noting, however,that there is no mechanism for notifying a module that one of itsparameters has been changed. Module authors, thus, will have to be carefulto ensure that their modules will properly detect and respond to changes toparameters at any time before exporting those parameters in a writablemode. Even so, this patch represents the tying-up of yet another 2.6 looseend.


原文:https://lwn.net/Articles/85443/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值