添加系统调用时地址错误
我已经下载了内核2.6.38-5并且想要添加系统调用。 我执行了以下操作:
我已将系统调用添加到系统调用表中;
/arc/x86/kernel/syscall_table_32.S .long sys_mycall 我已添加系统调用号;
/include/asm-generic/unistd.h #定义__NR_mycall 244 __SYSCALL(__NR_mycall, sys_mycall) 我已将原型添加到
syscalls.h
;/include/linux/syscalls.h asmlinkage 长 sys_mycall(长输入); 而且,这是我的系统调用;
asmlinkage long sys_mycall(长输入) { 返回(输入* 2); }
我也编辑了 Makefile。
现在编译后,当我通过 syscall()
使用它时,它会给出 BAD ADDRESS
,errno 设置为 14。
我该怎么办?
I have downloaded kernel 2.6.38-5 and want to add a system call.
I did the following:
I have added my system call to system call table;
<src folder>/arc/x86/kernel/syscall_table_32.S .long sys_mycall
I have added the system call number;
<src folder>/include/asm-generic/unistd.h #define __NR_mycall 244 __SYSCALL(__NR_mycall, sys_mycall)
I have added the prototype to
syscalls.h
;<src follder>/include/linux/syscalls.h asmlinkage long sys_mycall(long input);
And, here is my system call;
asmlinkage long sys_mycall(long input) { return (input * 2); }
I have edited the Makefiles too.
Now after compilation, when I use it via syscall()
it gives me BAD ADDRESS
with errno set to 14.
What should I do?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在 x86 上,系统调用号 244 已被 get_thread_area( ),它采用指向 struct user_desc 的指针作为第一个参数:
您传递的是数字而不是指针,内核正在尝试解释它作为指针,它确定它指向进程之外,并返回
-EFAULT
。On x86, system call number 244 is already taken by get_thread_area(), which takes as first argument a pointer to a
struct user_desc
:You are passing a number instead of a pointer, the kernel is trying to interpret it as a pointer, it's determining that it points outside of your process, and returning
-EFAULT
.系统调用查询正在运行的内核。该函数被映射到内核中的地址空间。如果您不安装此内核并重新启动计算机,则该地址将无效。
Syscalls query the running kernel. The function is mapped to an address space in the kernel. If you do not install this kernel and reboot the machine, the address will be not be valid.