一、在内核中添加系统调用的步骤:
1.在 kernel/sys.c 中添加系统调用函数
asmlinkage int sys_hello()
{
printk(KERN_INFO "hello world\n");
return 0;
}
2.在 include/asm/unistd.h 尾部添加系统调用号
#define __NR_hello (__NR_SYSCALL_BASE+352)
3.在 arch/arm/kernel/calls.S中的尾部添加系统调用函数
CALL(sys_hello)
#include <linux/unistd.h>
int main(void)
{
int result;
result= syscall(352);
printf("result= %d\n", result);
return 0;
}
1.在 kernel/sys.c 中添加系统调用函数
asmlinkage int sys_hello()
{
printk(KERN_INFO "hello world\n");
return 0;
}
2.在 include/asm/unistd.h 尾部添加系统调用号
#define __NR_hello (__NR_SYSCALL_BASE+352)
3.在 arch/arm/kernel/calls.S中的尾部添加系统调用函数
CALL(sys_hello)
二、测试添加的系统调用
写一个应用程序
#include <stdio.h>#include <linux/unistd.h>
int main(void)
{
int result;
result= syscall(352);
printf("result= %d\n", result);
return 0;
}