在我的項目中,我使用char驅動程序在用戶空間和內核空間之間進行通信。我使用函數copy_to_user(void user *to, const void *from, unsigned long n)
將數據從內核空間複製到用戶空間緩衝區。我們可以在#include <asm/uaccess.h>
頭文件下找到這個功能。 我使用Linux Kernel版本4.4.0-59-generic,Ubuntu OS版本16.04 LTS編譯了該項目,並且其工作正常,沒有任何錯誤和警告。我得到所需的輸出。copy_to_user在Linux內核版本4.12.8中未定義
我使用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
。我認爲頭文件仍然支持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'
此操作系統版本16.04.2 LTS擁有Linux的頭,4.10.0-35。 如何擺脫此警告?建議和支持表示讚賞。如果需要更多信息,請隨時詢問。
謝謝布羅尼斯拉夫。您的解決方案奏效 –
不客氣。 –