In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains "how to use module_param ()". The content in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "how to use module_param ()".
Declare a variable
Module_param (name, type, perm)
Name is not only the parameter name seen by the user, but also the variable that accepts the parameters in the module.
Type represents the data type of the parameter and is one of the following: byte, short, ushort, int, uint, long, ulong, charp, bool, invbool
Perm specifies access to the corresponding files in sysfs. Access permissions are managed in the same way as linux files, such as 0644, or using macros such as S _ IRUGO in stat.h.
0 means that the corresponding item in sysfs is completely closed.
You can also make the variable name inside the module source file different from the external parameter name, which is defined by module_param_named ().
Module_param_named (name, variable, type, perm)
Name is the externally visible parameter name
Variable is the global variable name inside the source file, while module_param is implemented through module_param_named, except that name is the same as variable.
Another way is to use the macro module _ param_string () to have the kernel copy the string directly into the character array in the program.
Module_param_string (name, string, len, perm)
Here, name is the external parameter name
String is the internal variable name
Len is the size of the buffer named after string (it can be less than the size of buffer, but it doesn't make sense)
Perm indicates access to sysfs (or perm is zero, which means that the corresponding sysfs entry is completely closed).
If you need to pass multiple parameters, you can do so through the macro module _ param_array (). Internal call to external parameters
Module_param_array (name, type, nump, perm)
Name is both the parameter name of the external module and the variable name inside the program.
Type is a data type
Perm is the access right for sysfs. The pointer nump points to an integer whose value indicates how many parameters are stored in the array name. It is worth noting that the name array must be allocated statically.
Module parameters support many types:
Bool
Invbool
A Boolean (true or false) value (the associated variable should be of type int). The invbool type reverses the value, so the true value becomes false and vice versa.
Charp
A character pointer value. The memory is allocated for the string provided by the user, and the pointer is therefore set.
Int
Long
Short
Uint
Ulong
Ushort
The basic variable length integer value. What starts with u is an unsigned value.
Array parameters, values provided by a comma-spaced list, are also supported by module loaders. Declare an array parameter, using:
Module_param_array (name,type,num,perm)
Where name is the name of your array (also the parameter name)
Type is the type of array element
Num is an integer variable
Perm is the usual permission value.
If the array parameter is set at load time, num is set to the number of supplied numbers. The module loader rejects more values than the array can drop.
Thank you for your reading, the above is the content of "how to use module_param ()", after the study of this article, I believe you have a deeper understanding of how to use module_param (), and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.