标 题: FreeBSD kld简介
发信站: BBS 水木清华站
上面的东西大致是daemonnews上的一片文章 by Andrew
在google上可以找到.
我觉得将的太罗索,还有一点小错误.改一改,放到这里来.
你要是感兴趣的话,千万去thc看看.
最后在强调一下
原文的作者是
Andrew Reiter
http://www.subterrain.net/~awr/KLD-Turorial/
就象Linux下的lkm一样,FreeBSD中有相应的东东.
如果我没有搞错的话,2.x系列中是叫lkm的.现在
还有系统的同志可以在/usr/share/example/lkm
中看到这些前辈的影子.
但是时代变迁,到了3.x系列之后,新的东西出现
了,就是所谓的kld.
这里摘录的是关于FreeBSD的lkm和kld的比较:
1. LKM system used a userland linker to
push prerelocated binary data into
the kernel.
2. KLD system does the relocation itself
in the kernel. LKMs had special data
structures that the lkm driver knew about
and used those to wire it into the kernel
3. LKMs were single purpose and were quite
difficult to change from LKM to actual
kernel code.
4. With KLDs, thins were made to be more
generic. A file could contain 0 or more
modules.
5. Each module is self-contianed and self-
initializing and registering.
6. KLDs and kernel code are compiled the
same.
7. It's possible to take a piece of the
kernel and easily make it a KLD without
much difficulty.
8. The dependncies and versioning are now
at the module level.
我们都知道kld有什么好处了,那么就开始作
一个吧. 标准的例子在/usr/share/example/kld.
btw: 3.x系列的还有lkm的目录,有人愿意看吗?
kld目录中有两个子目录,对应了两种主要的方法.
写设备驱动(cdev)和增加系统调用(syscall).
我们还是从一般的情况开始吧.
所有的kld都会有一个类似的函数:
static int
load_handler (module_t mod, int what, void *arg)
{
int err=0;
switch(what) {
case MOD_LOAD:
........
break;
| 论坛热门帖子: | [lch203] 写得蛮好的linux学习笔记(10-21) [黑马制造] 学习java的30个目标(10-19) [笑傲股林] 做测试半年了,有点迷茫,应该再学些什么提高自己的测试水平和测试能力呢?(10-19) [udp8589] 大家用google的来吱一声? 用百度的~~也来报道下?(10-18) [沂偌掳兆] 本人总结的一些认为C++比较经典的书籍,希望对大家有用(10-18) |
| TAG标签: | 简介 我们 kld 一个 可以 模块 系统 调用 定义 lkm 两个 |
注册
个人空间
