在debugfs中实现读取操作列表 [英] implement a read operation list in debugfs
本文介绍了在debugfs中实现读取操作列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在实现一个内核模块.使用几种技术. 其中之一是对不同的模块变量进行读/写. 我能够读取/写入所有变量,但我模块中的列表除外. 链接列表:
i'm implementing a kernel module. using several techniques. 1 of them is to give read/write to different module variables. i was able to read/write all variables except the list i have in my module. the linked list:
static struct node {
struct list_head list;
unsigned int x;
struct tm time;
};
我希望在debugfs中有一个相应的文件,该文件将打印完整列表. 我尝试了所有的简单"读取功能,但是它们都没有真正起作用..:(
i would like to have a corresponding file in debugfs that will print the full list. i tried all the 'simple' read functions , but none of them actually work.. :(
推荐答案
您可以使用与此功能类似的功能来阅读列表:
You can read list using function similar to this one:
struct k_list {
struct list_head links;
int data;
};
struct k_list my_list;
static ssize_t pop_queue(struct file * file,
char *buf,
size_t count,
loff_t *ppos)
{
struct list_head *pos, *q;
struct k_list *tmp;
printk(KERN_INFO "--Listing inserted numbers--");
list_for_each_safe(pos, q, &my_list.links) {
tmp = list_entry(pos, struct k_list, links);
printk(KERN_INFO "object: %d ", tmp->data);
}
printk(KERN_INFO "--End of list--");
return count;
}
这篇关于在debugfs中实现读取操作列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文