A.1. Changes between 2.0 and 2.2

本文档详细记录了从2.0版本到2.2版本内核模块的重要变化,包括asm/uaccess.h的使用、get_user函数的新特性、file_operations结构中的新增flush函数、close函数返回值的改变、read/write函数头的更新、proc_register_dynamic的移除、信号处理方式的变化、queue_task_irq的替代方案、模块参数声明方式的改进以及对称多处理(SMP)的支持增强。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

A.1.1. Changes between 2.0 and 2.2

I don't know the entire kernel well enough do document all of the changes. In the course of converting the examples (or actually, adapting Emmanuel Papirakis's changes) I came across the following differences. I listed all of them here together to help module programmers, especially those who learned from previous versions of this book and are most familiar with the techniques I use, convert to the new version.

An additional resource for people who wish to convert to 2.2 is located on Richard Gooch's site .

asm/uaccess.h

If you need put_user or get_user you have to #include it.

get_user

In version 2.2, get_user receives both the pointer into user memory and the variable in kernel memory to fill with the information. The reason for this is that get_user can now read two or four bytes at a time if the variable we read is two or four bytes long.

file_operations

This structure now has a flush function between the open and close functions.

close in file_operations

In version 2.2, the close function returns an integer, so it's allowed to fail.

read, write in file_operations

The headers for these functions changed. They now return ssize_t instead of an integer, and their parameter list is different. The inode is no longer a parameter, and on the other hand the offset into the file is.

proc_register_dynamic

This function no longer exists. Instead, you call the regular proc_register and put zero in the inode field of the structure.

Signals

The signals in the task structure are no longer a 32 bit integer, but an array of _NSIG_WORDS integers.

queue_task_irq

Even if you want to scheduale a task to happen from inside an interrupt handler, you use queue_task, not queue_task_irq.

Module Parameters

You no longer just declare module parameters as global variables. In 2.2 you have to also use MODULE_PARM to declare their type. This is a big improvement, because it allows the module to receive string parameters which start with a digits, for example, without getting confused.

Symmetrical Multi-Processing

The kernel is no longer inside one huge spinlock, which means that kernel modules have to be aware of SMP.

 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值