kernel中创建属性并且操作

来源:互联网 发布:零基础大数据培训班 编辑:程序博客网 时间:2024/06/15 22:44

    在wakeup.c中发现有wakeup_source这个property,这个property在adb shell到机台中,然后cd d进去,ls就可以看到了。

   既然有现成的例子,就一样模仿一个:

1.建立一个static struct dentry *xxx

2.xxx=debugfs_create_file("xxx_xxx",S_IRUGO,NULL,NULL,&xxx_fops)

3.static const struct file_operations xxx_fops={

    .owner=THIS_MODULE,

    .open=XXXXX,

    .read=xxxxx_read,

   }

4.ssize_t xxxx_read(struct file *file,char _user &buf,size_t size,loff_t *ppos)

{



}

使用这个属性就cat /d/xxx就可以调用read函数了

0 0