FWQ
Linux驱动 | debugfs接口创建
点击上方“嵌入式Linux充电站”,选择“置顶/星标公众号” 福利干货,第一时间送达 上篇介绍了procfs接口的创建,今天再介绍一种debugfs接口的创建。 实现效果 在/sys/kernel/debug/目录下创建一个ion/test文件,通过cat、echo的方式进行读写操作: 前期准备 内核配置打开debugfs: CONFIG_DEBUG_FS=y 登录后复制 挂载debugfs文件系统: mount -t debugfs none /sys/kernel/debug 登录后复制 代码实现 读写变量: #include <linux> #include <linux> #include <linux> static struct dentry *ion_dir; static u64 test_u64 = 0; static int __init debugfs_init(void) { //创建一个/sys/kernel/debug/ion目录 ion_dir = debugfs_create_dir("ion", NULL); if (!ion_dir) { printk("ion_dir is null "); return -1; }…