1.下载内核源码2.6.36.4
2.建立文件夹~/linux/linux-dirty
cd ~linux/linux-dirty把解压缩后的内核源码存入此目录
qian@ubuntu:~/linux/linux-dirty$ ls
arch crypto fs Kbuild Makefile REPORTING-BUGS sound
block Documentation include kernel mm samples tools
COPYING drivers init lib net scripts usr
CREDITS firmware ipc MAINTAINERS README security virt
3.编辑文件 arch/x86/kernel/syscall_table_32
.S
末尾添加
.long sys_mysyscall /* 341 */
.char * sys_getWebPageTitle /* 342 */
你的新调用的编号就是上一行的编号+1,记住这个编号,后面要用。
4.kernel/sys.c
添加
asmlinkage
long
sys_mysyscall(
int
number)
{
if
(number>0)
return
123456
else
return
654321;
}
|
asmlinage char * sys_getWebPageTitle(char *website)
{
..............
}
5.arch/x86/include/asm/unistd_32.h
#define __NR_mysyscall 341 //这341是之前记下的那个编号
|
#define __NR_mygetWebPageTitle //342
6.
如果是第一次编译内核,可能会出席ncurses库没有安装。
apt-get install libncurses5-dev
make defconfig
make
arch/x86/kernel/syscall_table_32.S: Assembler messages:
arch/x86/kernel/syscall_table_32.S:344: Error: unknown pseudo-op: `.char'
make[2]: *** [arch/x86/kernel/entry_32.o] Error 1
make[1]: *** [arch/x86/kernel] Error 2
http://zakir.is-programmer.com/posts/22294.html
http://www.cnblogs.com/kenjones/archive/2011/03/09/1978611.html