中国IT动力,最新最全的IT技术教程
最新100篇 | 推荐100篇 | 专题100篇 | 排行榜 | 搜索 | 在线API文档
首 页 | 程序开发 | 操作系统 | 软件应用 | 图形图象 | 网络应用 | 精文荟萃 | 教育认证 | 硬件维护 | 未整理篇 | 站长教程
ASP JS PHP工程 ASP.NET 网站建设 UML J2EESUN .NET VC VB VFP 网络维护 数据库 DB2 SQL2000 Oracle Mysql
服务器 Win2000 Office C DreamWeaver FireWorks Flash PhotoShop 上网宝典 CorelDraw 协议大全 网络安全 微软认证
硬件维护  CPU  主板  硬盘  内存  显卡  显示器  键盘鼠标  声卡音箱  打印机  机箱电源  BIOS  网卡  C#  Java  Delphi  vs.net2005
  当前位置:> 操作系统 > Linux > Linux综合
2.4与2.6内核模块的区别
作者:未知 时间:2005-09-13 22:39 出处:Blog.ChinaUnix.net 责编:chinaitpower
              摘要:2.4与2.6内核模块的区别
郁闷了一天好不容易google到

12. Differences Between Versions Of Linux

One thing that deserves mention in this section is the variety of Linux versions that exist in the world and what we call them. Unlike a proprietary software product where one company carefully controls the name and creates a small number of well defined releases, variations of Linux are developed by lots of different independent people and all of them are called Linux.

The most basic Linux releases are controlled by Linus Torvalds and distributed by kernel.org as the main Linux releases. They are the only releases that can properly by called "Linux 2.4," "Linux 2.6.6," etc.

But hardly anybody uses those releases. Instead, people start with those releases and make modifications. People often sloppily refer to a Linux based on Linux 2.6.6 as Linux 2.6.6 itself. But to be correct, you have to add something -- usually a hyphen and a suffix. Red Hat versions of Linux, which you see a lot, unfortunately use just a plain number for that suffix, e.g. Linux 2.6.6-12. (It would be better if they used something more explicitly Red Hat, such as Linux 2.6.6-rh12).

Remember that in this document, "Linux" means the kernel; when we consider the operating systems called "Linux", the situation gets even more complicated.

12.1. Linux 2.4 - Linux 2.6

12.1.1. Linking Done In Kernel

The biggest change to LKMs between Linux 2.4 and Linux 2.6 is an internal one: LKMs get loaded much differently. Most people won't see any difference except that the suffix on a file containing an LKM has changed, because they use high level tools to manage the LKMs and the interface to those tools hasn't changed.

Before Linux 2.6, a user space program would interpret the ELF object (.o) file and do all the work of linking it to the running kernel, generating a finished binary image. The program would pass that image to the kernel and the kernel would do little more than stick it in memory. In Linux 2.6, the kernel does the linking. A user space program passes the contents of the ELF object file directly to the kernel. For this to work, the ELF object image must contain additional information. To identify this particular kind of ELF object file, we name the file with suffix ".ko" ("kernel object") instead of ".o" For example, the serial device driver that in Linux 2.4 lived in the file serial.o in Linux 2.6 lives in the file serial.ko.

So there is a whole new modutils package for use with Linux 2.6. In it, insmod is a trivial program, as compared to the full blown linker of the Linux 2.4 version.

Also, the procedure to build an LKM is somewhat harder. To make a .ko file, you start with a regular .o file. You run the program modpost (which comes with the Linux source code) on it to create a C source file that describes the additional sections the .ko file needs. We'll call this the .mod file because you conventionally include ".mod" in the file name.

You compile the .mod file and link the result with the original .o file to make a .ko file.

The .mod object file contains the name that the LKM instance will have when you load the LKM. You set that name with a -D compile option (when you compile the .mod file) that sets the KBUILD_MODNAME macro.

This change means some things are decidedly harder -- choosing the name for the LKM instance, for example. In Linux 2.4, the name was one of the inputs to the kernel. insmod decided on the name and passed it to the kernel. insmod's -o option told it explicitly what to use for the LKM instance name. But in 2.6, there is no such parameter on the system call and hence no -o option on insmod. The name is part of the ELF object (.o file) that you pass to the kernel. The default name is built into the ELF object, but if you want to load it with some other name, you must edit the ELF image before passing it to insmod.

12.1.2. No Module Busy Function

In Linux 2.6 can_unload (see Section 11.4) is gone.

12.1.3. CONFIG_MODULE_UNLOAD

You can configure the kernel build to build a kernel that does not allow unloading of modules at all, thus sidestepping any problems with modules that get unloaded while still in use. See Section 11.4.

12.1.4. Reference Counting

The interface that the code of an LKM uses to manipulate its reference count has been replaced.

关闭本页
 
首页 | 投资与合作 | 服务条款 | 隐私政策 | 收藏本站 | 设为首页 | 新用户注册 | 免责声明 | 使用帮助
Copyright ©2005-2008 chinaitpower.com All rights reserved. www.chinaitpower.com 版权所有