惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

雷峰网
雷峰网
Security Archives - TechRepublic
Security Archives - TechRepublic
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Last Week in AI
Last Week in AI
博客园 - 司徒正美
阮一峰的网络日志
阮一峰的网络日志
WordPress大学
WordPress大学
爱范儿
爱范儿
J
Java Code Geeks
T
Tailwind CSS Blog
Apple Machine Learning Research
Apple Machine Learning Research
人人都是产品经理
人人都是产品经理
宝玉的分享
宝玉的分享
博客园 - 【当耐特】
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Help Net Security
Help Net Security
Hacker News: Ask HN
Hacker News: Ask HN
月光博客
月光博客
S
Secure Thoughts
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
博客园 - 聂微东
Hugging Face - Blog
Hugging Face - Blog
V
Visual Studio Blog
博客园 - 三生石上(FineUI控件)
O
OpenAI News
酷 壳 – CoolShell
酷 壳 – CoolShell
N
News and Events Feed by Topic
腾讯CDC
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
Webroot Blog
Webroot Blog
博客园 - Franky
有赞技术团队
有赞技术团队
美团技术团队
Jina AI
Jina AI
S
Security @ Cisco Blogs
博客园 - 叶小钗
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
博客园_首页
C
CERT Recently Published Vulnerability Notes
T
Threat Research - Cisco Blogs
Project Zero
Project Zero
A
Arctic Wolf
大猫的无限游戏
大猫的无限游戏
Latest news
Latest news
小众软件
小众软件
IT之家
IT之家
S
Security Affairs

博客园 - 中土

strcpy和memcpy的标准实现 Linux 命令缩写部分解释 Eclipse RCP 的一些有用的资源及应用案例 分析Linux和windows动态库 C/C++中的函数参数传递机制(zz) LDD3 笔记: 第3章 字符设备的驱动 2008年看书计划 H.264学习建议(zz) - 中土 - 博客园 几种常用的视频接口(端子) U-boot 移植到FS2410 NandFlash和NorFlash的区别 Linux basic use Kernel resource list Linux2.6 驱动设计―从 2.4.x 到 2.6.x Linux 2.6.x 内核模块入门(LKM) C++中无处不在的临时变量 类中引用成员的初始化 C++初始化与赋值 C异常处理实现: setjmp和longjmp
A simple tourial for Linux 2.6.24 kernel module
中土 · 2008-10-11 · via 博客园 - 中土

Author: Charles Yang <chio.yang@gmail.com>

Linux Dist: Ubuntu 8.04 Hardy

1. Preparation

1.1 Download source code with apporiate version

Usually, the linux release distribution have no full kernel source code tree. So you should get a copy of kernel source from www.kernel.org. For convience, you had better download the same version as you running linux kernel.

You can type uname -r  in you X-term, for example:

charles@charles-laptop ~> uname -r
2.6.24-16-generic

1.2 Learn the document for Linux Kernel Module (LKM)

Once you plan to do modules development, you should refer to:  $SRCDIR/Document/kbuild/modules.txt

In my ubuntu 8.04, I can find it in /usr/src/linux-headers-2.6.24-16/Documentation/kbuild

Now let read the document for module development..

1). How to build external module

 From modules.txt, we know the simplest make command:

make -<path-to-kernel> M=`pwd`

 the <path-to-kernel> means the kernel source path.

For the running kernel use:

make -/lib/modules/`uname -r`/build M=`pwd`

The -C option: change to the directory before execute the make command.

Actually, that will result in search the Makefile  in /lib/modules/2.6.24-16-generic/build in my OS.

Notice: Most of files in /lib/modules/2.6.24-16-generic/build actually link to /usr/src/linux-headers-2.6.24-16/

The M=`pwd`: define a MACRO required by Makefile in /lib/modules/2.6.24-16-generic/build, which can tell the directory of current exernal module code.

Therefore you needn't  write your own Makefile for build your modules, that's completed by kbuild - a good machism for kernel modules.

2. make target

 make -C $KDIR M=`pwd`
 make 
-C $KDIR M=`pwd` all
 make 
-C $KDIR M=`pwd` modules
 make 
-C $KDIR M=`pwd` modules_install
 make 
-C $KDIR M=`pwd` clean
 make 
-C $KDIR M=`pwd` help

 the first 3 commands are absolutely same. For more details, you can refer to modules.txt