Module parameters in sysfs

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/

你可能感兴趣的:(Module parameters in sysfs)