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 = ;
static char* array[] = {NULL};
static int ntime = ;
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 = ;
printk("string :%s, int :%d\n", pstring, ntime);
printk("Array\n");
for(; i < num; ++i)
printk("%s\n", array[i]);
return ;
}

执行:

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

linux kernel with param的更多相关文章

  1. andriod and linux kernel启动流程

    虽然这里的Arm Linux kernel前面加上了Android,但实际上还是和普遍Arm linux kernel启动的过程一样的,这里只是结合一下Android的Makefile,讲一下boot ...

  2. Linux kernel的中断子系统之(五):驱动申请中断API

    返回目录:<ARM-Linux中断系统>. 总结:二重点区分了抢占式内核和非抢占式内核的区别:抢占式内核可以在内核空间进行抢占,通过对中断处理进行线程化可以提高Linux内核实时性. 三介 ...

  3. Linux kernel pwn notes(内核漏洞利用学习)

    前言 对这段时间学习的 linux 内核中的一些简单的利用技术做一个记录,如有差错,请见谅. 相关的文件 https://gitee.com/hac425/kernel_ctf 相关引用已在文中进行了 ...

  4. Linux kernel中断子系统之(五):驱动申请中断API【转】

    转自:http://www.wowotech.net/linux_kenrel/request_threaded_irq.html 一.前言 本文主要的议题是作为一个普通的驱动工程师,在撰写自己负责的 ...

  5. Linux Kernel - Debug Guide (Linux内核调试指南 )

    http://blog.csdn.net/blizmax6/article/details/6747601 linux内核调试指南 一些前言 作者前言 知识从哪里来 为什么撰写本文档 为什么需要汇编级 ...

  6. linux内核可以接受的参数 | Linux kernel启动参数 | 通过grub给内核传递参数

    在Linux中,给kernel传递参数以控制其行为总共有三种方法: 1.build kernel之时的各个configuration选项. 2.当kernel启动之时,可以参数在kernel被GRUB ...

  7. Linux kernel make 常用选项介绍

    Linux kernel 编译方法大全记录 一.这是一个我自己写的自动make脚本: #!/bin/sh export ARCH=arm export CROSS_COMPILE=arm-linux- ...

  8. Linux Kernel代码艺术——系统调用宏定义

    我们习惯在SI(Source Insight)中阅读Linux内核,SI会建立符号表数据库,能非常方便地跳转到变量.宏.函数等的定义处.但在处理系统调用的函数时,却会遇到一些麻烦:我们知道系统调用函数 ...

  9. Linux Kernel 代码艺术——编译时断言

    本系列文章主要写我在阅读Linux内核过程中,关注的比较难以理解但又设计巧妙的代码片段(不关注OS的各个模块的设计思想,此部分我准备写在“深入理解Linux Kernel” 系列文章中),一来通过内核 ...

随机推荐

  1. 网络传输速度bps与下载文件所需时间的换算

    相信很多同志都非常关注自己家的计算机上网的宽带是多少.关心单位上网的宽带是多少! 但是很多同志都经常误解网络传输速度,以至于责备网络接入商(电信.网通.铁通等单位)欺骗用户,限制上网的速度! 本文,就 ...

  2. 美国H1B基本情况及相关数据

    H-1B是外国人在美国工作的签证,从美国学校毕业之后会有12个月的OPT实习期,在OPT结束之前必须申请到H1B签证才能在实习期结束后继续工作. H1B需要由雇佣你的公司帮你申请,也就是说必须先找到工 ...

  3. 爬虫入门scrapy

    Python之路[第十九篇]:爬虫   网络爬虫(又被称为网页蜘蛛,网络机器人,在FOAF社区中间,更经常的称为网页追逐者),是一种按照一定的规则,自动地抓取万维网信息的程序或者脚本.另外一些不常使用 ...

  4. iOS系统下 的手机屏幕尺寸 分辨率 及系统版本 总结

    今天  我对iOS系统下 的手机屏幕尺寸 分辨率 及系统版本做了一次系统总结 供大家参考. 首先 是系统:    随着iOS 系统不断升级,现在已经到iOS7.0了, 并且TA有了很多新变化,最震撼的 ...

  5. 【转】ViewGroup的onMeasure和onLayout分析

    ViewGroup的onMeasure和onLayout分析 一个Viewgroup基本的继承类格式如下: 1 import android.content.Context; 2 import and ...

  6. XMLObject 简易xml格式接口数据生成和解析工具

    简单的请求封装,相当于封装了Book对象,但比Book对象参数更灵活 XMLObject xml = new XMLObject("book");xml.add("aut ...

  7. centos7上源码安装mysql5.7.11

    由于初学,安装这玩意搞了三天,其间各种报错难以解决,网上各种解答误导.最好的办法还是使用官方的英文文档,建议初学者一定要使用官方的文档,特别是下面两个页面作为初学者一定要细看: Installing ...

  8. EasyGUI基础教程

    安装EasyGUI 教程http://www.cnblogs.com/zym941001/p/5323319.html Helloworld import easygui as g g.msgbox( ...

  9. Storm累计求和进群运行代码

    打成jar包放在主节点上去运行. import java.util.Map; import backtype.storm.Config; import backtype.storm.StormSubm ...

  10. c# 结课小结

    C#总结知识点 模块一:知识点梳理 输入输出表达式---数据类型---变量与常量 ----运算符---语句-----数组与集合---函数--结构体: 模块二:输入与输出 输入:  console.re ...