Linux内核模块-创建proc文件-proc_root未声明的错误 [英] Linux Kernel Module - Creating proc file - proc_root undeclared error
问题描述
我从此URL复制并粘贴代码以使用内核模块创建和读取/写入proc文件,并得到未声明proc_root的错误.相同的示例在一些站点上,因此我认为它可以正常工作.有任何想法为什么我会收到此错误吗?我的makefile是否需要其他内容?以下也是我的makefile:
I copy and paste code from this URL for creating and reading/writing a proc file using a kernel module and get the error that proc_root is undeclared. This same example is on a few sites so I assume it works. Any ideas why I'd get this error? Does my makefile need something different. Below is my makefile as well:
创建基本proc文件的示例代码(直接复制和粘贴以完成初始测试): http://tldp.org/LDP/lkmpg/2.6/html/lkmpg .html#AEN769
Example code for a basic proc file creation (direct copy and paste to get initial test done): http://tldp.org/LDP/lkmpg/2.6/html/lkmpg.html#AEN769
Makefile 我正在使用:
obj-m := counter.o
KDIR := /MY/LINUX/SRC
PWD := $(shell pwd)
default:
$(MAKE) ARCH=um -C $(KDIR) SUBDIRS=$(PWD) modules
推荐答案
该示例已过时.在当前内核API下,将NULL
用作procfs的根.
That example is out of date. Under the current kernel API, pass NULL
for the root of procfs.
此外,您应该将proc_create()
与适当的const struct file_operations *
结合使用,而不是create_proc_entry
.
Also, instead of create_proc_entry
, you should use proc_create()
with a proper const struct file_operations *
.
这篇关于Linux内核模块-创建proc文件-proc_root未声明的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!