宏module_init不显示,我希望它的的printk [英] module_init not showing the printk that I want it to

查看:315
本文介绍了宏module_init不显示,我希望它的的printk的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图让我的模块显示一个的printk 。我是新来这个,所以我可能有一些编程错误。这是我的模块的C文件:

I am trying to make my module display a printk. I'm new to this so I might have some programming errors. This is my module C file:

#include <linux/linkage.h>
#include <linux/time.h>
#include <linux/module.h>

asmlinkage long sys_mycall(int myid, char* firstname)
{
    printk ("Hello, %s! \n sys_mycall called from process %d with  ID %d. \n",
        firstname, current->id, myid);

    return 0;
}

static int my_init(void)
{
    return 0;
}

static int my_exit(void)
{
    printk("Goodbye!");
    return 0;
}

module_init(sys_mycall);
module_exit(my_exit);

第一件事是,我不知道该怎么箭头指针正好作品,所以我所以它完全编译从的printk 通常忽略它。如果有人能给我一个链接或东西怎么理解呢我真的AP preciate它。

First thing is that I don't know how the arrow pointer exactly works so I usually omit it from the printk so it compiles perfectly. If someone can give me a link or something on how to understand it I would really appreciate it.

当我将其插入使用 insmod的终端,然后使用的dmesg 我得到的消息显示消息在宏module_init 调用 sys_mycall 但我不能任何参数添加到它,它显示的信息,但它并不显示何事身份识别码

When I insert it using insmod in the terminal and then display the message using dmesg I get the message by the module_init calling the sys_mycall but I cannot add any arguments to it and it displays the message but it doesn't show anything for firstname or for myid.

推荐答案

我觉得这个模块的init期望在功能没有参数的问题,它必须是void(你可以用不同的方式将它们添加),所以基本上你的函数被称为垃圾当前在堆栈中,这可能是任何东西,但它可能是零,否则你的内核会崩溃。

I think the problem that module init expect no parameters in the function, it must be void (you can add them in a different way), so basically your function is called with garbage that is currently in the stack, which might be anything but it probably zero as otherwise your kernel will crash.

你想要什么打印?我明白了电流 - > ID,但没有其他人。

what do you want to print? I understand current->id, but no the others.

这篇关于宏module_init不显示,我希望它的的printk的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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