copy_to_user在linux内核版本4.12.8中未定义

Vij*_*ran 10 linux linux-device-driver linux-kernel embedded-linux ubuntu-16.04

在我的项目中,我使用char驱动程序在用户空间和内核空间之间进行通信.我使用该函数copy_to_user(void user *to, const void *from, unsigned long n)将数据从内核空间复制到用户空间缓冲区.我们可以在#include < asm/uaccess.h >头文件下找到这个函数.我使用Linux内核版本4.4.0-59-generic,Ubuntu OS版本16.04 LTS编译了该项目,并且其工作正常,没有任何错误和警告.我得到了所需的输出.

我使用Linux内核版本4.12.8,Ubuntu OS版本16.04.2 LTS编译了同一个项目,它在编译期间向我发出警告WARNING: "copy_to_user" [/home/ldrv1/Desktop/Vijay/code/build/uts.ko] undefined!.当我对我的模块进行insmod时,我得到如下错误insmod: ERROR: could not insert module uts.ko: Unknown symbol in module.我认为#include <asm/uaccess.h>4.12.8内核版本仍然支持头文件,否则我会遇到致命错误:编译时没有这样的文件或目录错误.我尝试使用apt-get install linux-headers-$(uname -r)命令更新linux内核头文件 ,我得到以下响应:

Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package linux-headers-4.12.8
E: Couldn't find any package by glob 'linux-headers-4.12.8'
E: Couldn't find any package by regex 'linux-headers-4.12.8'
Run Code Online (Sandbox Code Playgroud)

此操作系统版本16.04.2 LTS具有linux-headers-4.10.0-35.我如何摆脱这个警告?建议和支持表示赞赏.如果需要更多信息,请随时询问.

小智 13

  1. 您应该使用#include <linux/uaccess.h>4.12.8.这是定义.

    4.4中,一些司机#include <asm/uaccess.h>在其他人使用时使用#include <linux/uaccess.h>.

    #include <linux/uaccess.h> 我认为是可取的.

  2. 你应该做的apt-get update,然后apt-get install linux-headers-generic.