linux为内核新增系统调用

1、编写hello.c文件,实现系统调用执行函数,如:

asmlinkage long sys_helloworld(void){

    printk( "helloworld!");

     return 1;

}

2、修改syscalls.h文件,添加sys_helloworld函数声明,如在syscalls.h中添加asmlinkage long sys_helloworld(void);

3、修改syscall_table.S(也可能是syscall_table_32.s等类似名称),为系统调用函数分配系统调用号,如:

在syscall_table.S添加:

300  32  helloworld           sys_helloworld

4、修改make文件,使hello.c编进内核,或动态加载。

5、编写用户态程序,调用syscall(300)测试;

猜你喜欢

转载自www.cnblogs.com/wangliangblog/p/10874249.html