与2.6.X内核版本相比,3.8.x内核的系统调用表有着很大的区别。从结构上来说:2.6.X内核版本调用号与调用表的分离定义(调用号定义文件:
/arch/x86/include/asm/unistd.h,系统调用表:arch/i386/kernel/entry.S ),当开发者对内核添加自己的系统调用时,需要分别修改这两个文件,指定系统调用号和对应的系统调用表。
调用号结构如下:
/*
* This file contains the system call numbers.
*/
#define __NR_restart_syscall 0
#define __NR_exit 1
#define __NR_fork 2
#define __NR_read 3
#define __NR_write 4
#define __NR_open 5
#define __NR_close 6
#define __NR_waitpid 7
#define __NR_creat 8
#define __NR_link 9
#define __NR_unlink 10
#define __NR_execve 11
#define __NR_chdir 12
调用表格式如下:
ENTRY(sys_call_table)
.long SYMBOL_NAME(sys_ni_syscall)
……
.long SYMBOL_NAME(sys_ni_syscall)
.rept NR_syscalls-(.-sys_call_table)/4
.long SYMBOL_NAME(sys_ni_syscall)
.endr
转到3.8.x中调用表格式使用新的结构(\arch\x86\syscalls\syscall_32.tbl):如下
# 32-bit system call numbers and entry vectors
#
# The format is:
# <number> <abi> <name> <entry point> <compat entry point>
#
# The abi is always "i386" for this file.
#
0 i386 restart_syscall sys_restart_syscall
1 i386 exit sys_exit
2 i386 fork sys_fork stub32_fork
3 i386 read sys_read
4 i386 write sys_write
5 i386 open sys_open compat_sys_open
6 i386 close sys_close
7 i386 waitpid sys_waitpid sys32_waitpid
8 i386 creat sys_creat
#
# The format is:
# <number> <abi> <name> <entry point> <compat entry point>
#
# The abi is always "i386" for this file.
#
0 i386 restart_syscall sys_restart_syscall
1 i386 exit sys_exit
2 i386 fork sys_fork stub32_fork
3 i386 read sys_read
4 i386 write sys_write
5 i386 open sys_open compat_sys_open
6 i386 close sys_close
7 i386 waitpid sys_waitpid sys32_waitpid
8 i386 creat sys_creat
………………
3.8.x中 系统调用号与系统调用表放置在同一个文件syscall_32.tbl中,更容易维护添加和使用!