linux内核syscall_define6,系统调用问题,帮忙看看,谢谢!

我在添加系统调用时,在最后编译的时候遇到了如下错误:

[root@localhost ~]# gcc test.c

test.c: 在函数 '_syscall0' 中:

test.c:7: 错误:expected '=', ',', ';', 'asm' or '__attribute__' before '{' token

test.c:5: 错误:省略了形参的名字

test.c:10: 错误:expected '{' at end of input

我的具体步骤是这样的:

1./usr/src/linux/kernel/sys.c中最后添加:

asmlinkage int sys_hello(void)

{

printk("hello world!n");

return 0;

}

2./usr/src/linux/include/asm-i386/unistd.h中添加:

#define __NR_hello              320

下面改为#define NR_syscalls 321

3./usr/src/linux/arch/i386/kernel/syscall_table.S中添加:

.long sys_hello         /*320*/

4./usr/include/asm/unistd.h中添加:

#define __NR_hello              320

最后重新编译内核:make mrproper; make menuconfig; make; make modules_install; make install; reboot; 一直都没有出错,然后进入新内核,(我的内核版本是2.6.21.6),

/root下添加test.c:

#include

#include

#define __NR_hello 320

int errno;

_syscall0(int, hello)

int main()

{

hello();

return 0;

}

然后,gcc test.c

便出现了上述错误,不明白为什么,请问这是什么原因?这其中有什么做错的吗?

希望得到大家的指点,麻烦大家了,谢谢!

|

_syscall0(int, hello) 要在内核空间定义,用户空间不支持__asm__,__attribute__这些gnu扩展。

|

用户空间访问的不能用_syscall0

|

2.4的时候我用_SYSCALL0成功过 2.6后来就直接用SYSCALL(调用号,参数)

|

我也看到 有人用_syscall0成功过

http://blog.csdn.net/rickey_berkeley/archive/2005/09/02/470362.aspx

我试了也没成功。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值