Advertisement

sysfs_create_group 创建sysfs组文件(python代码)

阅读量:

#include <linux/kobject.h>

#include <linux/string.h>

#include <linux/sysfs.h>

#include <linux/init.h>

static int foo;

static ssize_t foo_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf)

{

return sprintf(buf, "%d\n", foo);

}

static ssize_t foo_store(struct kobject *kobj, struct kobj_attribute *attr, const char *buf, size_t count)

{

sscanf(buf, "%du", &foo);

return count;

}

static struct kobj_attribute foo_attribute = _ATTR(foo , 0666, foo_show, foo_store);

static struct attribute *attrs[] = {

&foo _attribute.attr,

NULL,

};

static struct attribute_gro

全部评论 (0)

还没有任何评论哟~