小编Rob*_*ord的帖子

linux / init.h:没有这样的文件或目录

我正在尝试为我的班级构建一个内核模块,并且遇到了很多错误,但是在该错误的顶部是臭名昭著的“无此类文件或目录”错误。这似乎是问题的根源。这似乎不仅影响init.h,还影响module.h和kernel.h。该程序的前三行如下:

#include <linux/init.h>
#include <linux/module.h>
#include <linux/kernel.h>
Run Code Online (Sandbox Code Playgroud)

在浏览类似问题时,我环顾四周并尝试了其他路径来确定这些文件的位置,但是到目前为止,仍然没有任何效果。最奇怪的部分是我已经使用了这个模块。提供给我的启动器代码顶部是该代码(我没有做任何更改),并且没有给我该错误。虽然,显然之后的代码不同,但这似乎是当前最大的问题。

完整的代码如下:

#include </usr/include/linux/init.h>
#include </usr/include/linux/module.h>
#include </usr/include/linux/kernel.h>

/* This function is called when the module is loaded. */
int simple_init(void)
{
    printk(KERN_INFO "Loading Module\n");
    static LIST_HEAD(birthday_list)
    struct birthday{
        int day;
        int month;
        int year;
        struct list_head list;
    };
    struct birthday *ptr, *next;
    struct birthday *bob;
    struct birthday *judy;
    struct birthday *josh;
    struct birthday *lana;
    struct birthday *jan;

    bob = kmalloc(sizeof(*bob), GFP_KERNEL);
    bob -> day = 17;
    bob -> month = 1;
    bob …
Run Code Online (Sandbox Code Playgroud)

c linux debian kernel module

6
推荐指数
2
解决办法
2万
查看次数

标签 统计

c ×1

debian ×1

kernel ×1

linux ×1

module ×1