linux2.6内核系统调用的增加方法介绍



linux2.6内核系统调用的增加方法介绍,内核版本linux-2.6.38。

1. 定义系统调用名
在linux-2.6.38/kernel目录新增一C文件,如:newsyscall.c
[cpp] view plaincopyprint?

#include
#include

asmlinkage int sys_newsyscall(int a, int b)
{
int c = 0;
printk(“Add a new syscall!\n”);
c = a + b;
return c;
}

2. 定义系统调用号
在linux-2.6.38/arch/x86/include/asm/unistd_32.h中新增
[cpp] view plaincopyprint?

#define __NR_newsyscall 335 // 系统调用需接着上一个调用号
添加系统调用的个数
[cpp] view plaincopyprint?


#define __NR_syscalls 336

3. 修改系统调用函数表
在linux-2.6.38/arch/x86/kernel/syscall_table_32.S文件末尾新增
[cpp] view plaincopyprint?

.long sys_newsyscall

4. 修改Makefile
[html] view plaincopyprint?

obj-y += newsyscall.o