Linux内核编程:函数的隐式声明'vmalloc'

Linux kernel programming: implicit declaration of function 'vmalloc'

我正在向 Linux 内核 6.22 添加系统调用。

#include <stddef.h>
#incldue <linux/kernel.h>
#include <linux/sched.h>
#include <linux/types.h>
#include <linux/lists.h>
#include <asm-i386/uaccess.h>

asmlinkage long sys_mypstree(char* buffer2copy){
     char* buffer = (char*)vmalloc(sizeof(buffer2copy));
     ...
}

然后当我让 kernel.It 显示 warning:implicit 函数声明时 'vmalloc'。那么,我现在要做什么?

你绝对应该:
#include <linux/vmalloc.h> 因为它会修复您的警告。