找不到新的syscall(Linux内核3.0.0),我应该从哪里开始寻找? [英] New syscall not found (linux kernel 3.0.0) where should I start looking?

查看:90
本文介绍了找不到新的syscall(Linux内核3.0.0),我应该从哪里开始寻找?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了两个新的系统调用,但是当我尝试测试它们时,出现以下错误:

I created two new syscalls, but when I try to test them I get the following error:

matt@ubuntu:~/test$ gcc test.c 
test.c: In function ‘newcall’:
test.c:6:17: error: ‘sys_get_slob_amnt_free’ undeclared (first use in this function)
test.c:6:17: note: each undeclared identifier is reported only once for each function it appears in
matt@ubuntu:~/test$ 

我也用syscall(sys_get_slob_amnt_free)进行了尝试,结果相同.

I also tried this with syscall(sys_get_slob_amnt_free) with the same result.

这是测试代码:

#include <unistd.h>
#include <stdio.h>

unsigned long newcall()
{
        return syscall(__NR_get_slob_amnt_free);
}
int main()
{
        printf("%d\n", newcall());
        return 0;
}

为了添加这些,我将它们放在syscall表中 (/usr/src/linux-3.0/include/asm-generic/unistd.h)

In order to add these I put them in the syscall table (/usr/src/linux-3.0/include/asm-generic/unistd.h)

#define __NR_sendmmsg 269
__SC_COMP(__NR_sendmmsg, sys_ sendmmsg, compat_sys_sendmmsg)
/** my changes here **/
#define __NR_get_slob_amnt_free 270
__SYSCALL(__NR__get_slob_amnt_free, sys_get_slob_amnt_free)
#define __NR_get_slob_amnt_claimed 271)
__SYSCALL(__NR_get_slob_amnt_claimed, sys_get_slob_amnt_claimed)
/**  /my changes **/

#undef __NR_syscalls
#define __NR_syscalls 272

这是调用本身的代码(../linux-3.0/mm/slob.c)

And here is the code for the calls themselves (../linux-3.0/mm/slob.c)

asmlinkage unsigned int sys_get_slob_amnt_claimed()
{
    return memClaimed;
}

asmlinkage unsigned int sys_get_slob_amnt_free()
{
    return memClaimed - memUsed;
}

我试图弄清楚我是否正在破坏测试代码(也许我需要添加更多内容?还是链接某些内容?)或者如果我在添加syscall时忽略了某些内容.借助重新编译内核所花费的时间,它真的可以帮助我了解从哪里开始寻找.

I'm trying to figure out whether I'm botching the test code (maybe I need to include something more? or link something?) Or if I've overlooked something in adding the syscall in the first place. With the amount of time it takes to recompile the kernel, it would really help me out to know where to start looking.

诚然,这与家庭作业有关.该作业是关于修改slob.c的,我对此有很好的了解.我这样做只是为了看看到目前为止我所做的修改是否会在任何地方进行.感谢您提供的任何指导.谢谢!

Admittedly, this is related to a homework assignment. The assignment is about modifying slob.c, which I have a pretty good handle on. I'm just doing this to get a peek at whether the modifications I've made so far are going anywhere. I appreciate any guidance you can give. Thanks!

已解决(或至少对我而言已解决).

Solved (or at least solved enough for me).

非常感谢bdonlan!尽管syscall(270)并没有直接执行,但它使我记忆犹新-我完全忽略了另一组相关数字. 还需要修改文件/linux-3.0/arch/x86/kernel/syscall_table_32.c,以正确添加系统调用.

Many thanks to bdonlan! Although syscall(270) didn't do it directly, it jogged my memory--there is another set of relevant numbers that I was neglecting entirely. The file /linux-3.0/arch/x86/kernel/syscall_table_32.c needed to be modified as well in order to properly add the syscall.

一旦我向该文件添加了.long sys_get_slob_amnt_free.long sys_get_slob_amnt_claimed并重建了内核,我可以使用syscall(###)来打我的系统调用,其中###是syscall_table_32.c中的编号(而不是unistd.h中的编号) ).我觉得他们应该匹配-但由于这只是美化的调试信息,我想我会再说一次这个谜,并称其为好.

Once I added .long sys_get_slob_amnt_free and .long sys_get_slob_amnt_claimed to that file and rebuilt the kernel, I could hit my syscalls by using syscall(###) where ### is the numbering in syscall_table_32.c (not the numbering in unistd.h). I feel like they should match--but since this is just glorified debug information I think I'll leave that mystery for another time and just call it good.

推荐答案

我需要添加另一组相关数字.为了正确添加系统调用,还需要修改文件/linux-3.0/arch/x86/kernel/syscall_table_32.c.

There is another set of relevant numbers that I was needed to add. The file /linux-3.0/arch/x86/kernel/syscall_table_32.c needed to be modified as well in order to properly add the syscall.

一旦我向该文件添加了.long sys_get_slob_amnt_free.long sys_get_slob_amnt_claimed并重建了内核,我可以使用syscall(###)来打我的syscall,其中###是syscall_table_32.c中的编号(不是编号unistd.h)

Once I added .long sys_get_slob_amnt_free and .long sys_get_slob_amnt_claimed to that file and rebuilt the kernel, I could hit my syscalls by using syscall(###) where ### is the numbering in syscall_table_32.c (not the numbering in unistd.h)

这篇关于找不到新的syscall(Linux内核3.0.0),我应该从哪里开始寻找?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆