linux中使用sysfs我想在一个指定的目录下创建一个属性文件,改如何操作

请参阅内核目录中的Documentation/filesystems/sysfs.txt文件。

首先使用DEVICE_ATTR作为宏:

#defineDEVICE_ATTR(_name,_mode,_show,_store)\

structdevice_attributedev_attr_##_name=__ATTR(_name,_mode,_show,_storage)

显示:

statsize_tshow_name(structdevice*dev,structsevice_tribute*attr,

      char*buf)

{

name);

}

3.存储:

stat_name

constchar*buf,size_tcount)

{

name,size(dev->name),"%*s",

name)-1),buf);

返回计数;