请教一个系统调用的基本问题---------急
添加一个求累加值的系统调用1:在/usr/src/linux/kernel/sys.c最后添加系统服务例程如下
asmlinkage int sys_addtotal(int numdata)
{
int i=0,enddata=0;
while(i<=numdata)
enddata+=i++;
return enddata;
}
2:在/usr/src/linux/arch/i386/kernel/entry.s中添加如下
.long sys_mq_timedsend
.long sys_mq_timedreceive /* 280 */
.long sys_mq_notify
.long sys_mq_getsetattr
.long sys_addtotal /我添加的/
syscall_table_size=(.-sys_call_table)
3:在/usr/src/linux/include/asm-i386/unistd.h中添加如下
#define __NR_mq_open 277
#define __NR_mq_unlink (__NR_mq_open+1)
#define __NR_mq_timedsend (__NR_mq_open+2)
#define __NR_mq_timedreceive (__NR_mq_open+3)
#define __NR_mq_notify (__NR_mq_open+4)
#define __NR_mq_getsetattr (__NR_mq_open+5)
#define NR_syscalls 283
#define __NR_addtotal /我添加的/
4:测试程序(test.c)用记事本写的另存为test.c文件程序如下
#include
#include
_syscall1(int,addtotal,int, num)
main()
{
int i,j;
do
printf("Please input a number\n");
while(scanf("%d",&i)==EOF);
if((j=addtotal(i))==-1)
printf("Error occurred in syscall-addtotal();\n");
printf("Total from 0 to %d is %d \n",i,j);
}
然后重新编译内核用新的内核引导系统
在终端下输入
# gcc -o test test.c
test.c: In function `addtotal':
test.c:5: error: parse error before ')' token
请问这是什么原因,改如何解决!急 mdk10.0 kernel2.6.3
页:
[1]