如何在驱动程序模块中使用seq_file实现可写的proc文件 [英] How to implement a writable proc file by using seq_file in a driver module
问题描述
在 Linux Device Driver 3rd ed 的书中,/proc
文件系统用作输出方法来导出某个设备驱动程序的运行状态.
In the book of Linux Device Driver 3rd ed, /proc
file system is used as a output method to export the running state of a certain device driver.
但是,在某些情况下,/proc
文件系统用作更改驱动程序模块内部参数的一个接口.
However, in some circumstances, /proc
file system is used as one interface to change the internal parameters of a driver module.
我在Google上搜索了很多东西,发现Internet上的某些实现太旧了,以至于它们使用的是create_proc_entry()
而不是proc_create()
.
I googled a lot, and found some implementations on the Internet are too old that they used create_proc_entry()
rather than proc_create()
.
此外,我更喜欢通过seq_file
来实现(实际上,我不确定是否可以实现).我检查了seq_write()
函数,却一无所获.
What's more, I'm prefer to implement this by seq_file
(actually, I'm not sure is it possible). I checked the seq_write()
function, and obtained nothing.
有人可以给我示范一个完成任务的例子吗? seq_file
实施是更可取的.
Can anyone show me an example to finish this mission? seq_file
implementation is more preferred.
推荐答案
我绑了很多东西之后.我发现实际上没有seq
版本写入功能.但是,您可以将/proc
文件视为普通设备文件,可以通过file_operations
中定义的方法进行操作.
After I tied a lot. I found there is actually no seq
version write function. However, you can treat /proc
file as a normal device file which can be operated by methods defined in file_operations
.
这篇关于如何在驱动程序模块中使用seq_file实现可写的proc文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!