博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
linux kernel with param
阅读量:7290 次
发布时间:2019-06-30

本文共 1122 字,大约阅读时间需要 3 分钟。

Linux kernel support pass param to kernel, this params can be assigned at load time by insmod or modprobe.  or later read from /etc/modprobe.conf file.

There are two macro : module_param and module_param_array, 

To declare an param or array param ,use:

module_param(name, type, perm)   module_param_array(name, type, num, perm)

name is the name of your param or array.

type can be : bool ,invbool,charp, int, long, short, uint, ulong, ushort

num is the array num , array param where the values are supplied as a comma-separated list.

perm : S_IRUGO , S_IWUSR and so on .

int num = 0;static char* array[10] = {NULL};static int ntime = 0;static char* pstring = NULL;module_param_array(array, charp, &num, S_IRUGO);module_param(ntime, int, S_IRUGO);module_param(pstring, charp, S_IRUGO);static int __init init_func(void){        int i = 0;        printk("string :%s, int :%d\n", pstring, ntime);        printk("Array\n");        for(; i < num; ++i)                printk("%s\n", array[i]);        return 0;}

执行:

sudo insmod ./hello.ko array="hello,world" pstring="test" ntime=10

 

转载于:https://www.cnblogs.com/memoryh/p/4084113.html

你可能感兴趣的文章
Centos6.6安装mysql记录
查看>>
OCP读书笔记(5) - 使用RMAN创建备份
查看>>
java的接口和抽象类区别
查看>>
能够提高PHP的性能的一些注意事项
查看>>
020-请你说一说app测试的工具
查看>>
软件测试2019:第五次作业—— 安全测试(含安全测试工具实验)
查看>>
SSM框架搭建总结(2)
查看>>
Python学习(19)正则表达式
查看>>
PHP中空字符串、0、null、empty和false之间的关系
查看>>
【深度学习篇】---CNN和RNN结合与对比,实例讲解
查看>>
201771010126 王燕《面向对象程序设计(Java)》第十二周学习总结
查看>>
XAML实例教程系列 - 资源(Resources)
查看>>
LWIP互联网资料汇总
查看>>
外贸术语
查看>>
网络传输流量控制策略小结
查看>>
上传大文件
查看>>
Mybatis面试集合(转)
查看>>
分布式系统的完整介绍(一)
查看>>
考点1
查看>>
Asp.net 程序连接orcle如果在安装 32 位 Oracle 客户端组件的情况下以 64 位模式运行,...
查看>>