linux-kernel - 识别创建 sysfs 条目的内核模块

标签 linux-kernel linux-device-driver

在一个正在运行的 Linux 系统上,我想知道哪个设备驱动程序模块创建了一个特定的 sysfs 条目。有可能知道吗?我知道我可以 grep 内核源代码中的相关字符串并尝试识别。但是,有没有办法不这样做?

最佳答案

您可以通过查看源代码找到哪个驱动程序创建了 sysfs 条目。如果驱动程序使用 device_create_file()/device_remove_file() 在其初始化/退出序列中,您可以确定驱动程序已经创建了一个 sysfs 属性文件。
您还可以找到 DEVICE_ATTR(_name, _mode, _show, _store) 源中的宏以找出 sysfs 文件提供的功能。
通常,您可以 cat 文件或向其回显字符串。
一个 猫/sys/.../文件 , 将对应于 _show 函数和 回显/sys/.../文件 将对应宏中提到的 _store 函数。

关于linux-kernel - 识别创建 sysfs 条目的内核模块,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13062061/

相关文章:

linux - .ko 文件未创建

linux - 编写 Sysfs 模块

linux - 如何延迟 Linux 内核模块临界区

c - 在中断处理程序中将数据从内核缓冲区移动到用户空间缓冲区

linux - tcp_max_syn_backlog 和 somaxconn 有什么区别?

linux-kernel - Linux内核镜像字符串提取

linux-kernel - 编译我的驱动程序源时找不到 linux/bounds.h

linux - 从内核向用户空间发送信号

linux-kernel - sysfs 属性可以在 Linux 设备驱动程序中采用非数值吗?

linux - 内核如何找到发送硬件中断的正确进程