kobj_attribute
来源:互联网 发布:mac qq怎么上传群文件 编辑:程序博客网 时间:2024/05/30 13:42
struct attribute attr;
ssize_t (*show)(struct kobject *kobj, struct kobj_attribute *attr,
char *buf);
ssize_t (*store)(struct kobject *kobj, struct kobj_attribute *attr,
const char *buf, size_t count);
};
struct attribute {
const char *name;
umode_t mode;
#ifdef CONFIG_DEBUG_LOCK_ALLOC
struct lock_class_key*key;
struct lock_class_keyskey;
#endif
};
const struct sysfs_ops kobj_sysfs_ops = {
.show = kobj_attr_show,
.store = kobj_attr_store,
};
/* default kobject attribute operations */
static ssize_t kobj_attr_show(struct kobject *kobj, struct attribute *attr,
char *buf)
{
struct kobj_attribute *kattr;
ssize_t ret = -EIO;
kattr = container_of(attr, struct kobj_attribute, attr);
if (kattr->show)
ret = kattr->show(kobj, kattr, buf);
return ret;
}
static ssize_t kobj_attr_store(struct kobject *kobj, struct attribute *attr,
const char *buf, size_t count)
{
struct kobj_attribute *kattr;
ssize_t ret = -EIO;
kattr = container_of(attr, struct kobj_attribute, attr);//定位到结构体的头部起始地址
if (kattr->store)
ret = kattr->store(kobj, kattr, buf, count);
return ret;
}
static void dynamic_kobj_release(struct kobject *kobj)
{
pr_debug("kobject: (%p): %s\n", kobj, __func__);
kfree(kobj);
}
static struct kobj_type dynamic_kobj_ktype = {
.release = dynamic_kobj_release,
.sysfs_ops = &kobj_sysfs_ops,
};
struct kobj_type {
void (*release)(struct kobject *kobj);
const struct sysfs_ops *sysfs_ops;
struct attribute **default_attrs;
const struct kobj_ns_type_operations *(*child_ns_type)(struct kobject *kobj);
const void *(*namespace)(struct kobject *kobj);
};
- kobj_attribute
- Linux设备模型-4-kobj_attribute
- Linux Kernel设备驱动模型之struct kobj_attribute
- Tomcat常见问题
- Cocos2d-x 之帧动画 Animate
- 使用rsync +cwrsync实现windows和linux的文件同步
- 服务器运维学习中的知识点积累
- Git使用中出现的错误以及解决办法积累
- kobj_attribute
- MockStatic of Unit Test
- 搭建Springmvc+Mybatis+Spring环境
- 使用gradle打war包时,包含中文文件名导致war包无法解压的解决办法
- Linux CentOS中Java环境变量的配置
- SpringBoot设置Filter过滤请求参数
- 使用Idea打开Maven项目的正确姿势
- Java菜鸟面试突破系列之事物方方面面(事物种类特性及隔离级别、悲观锁和乐观锁等)
- 韩大帅的工作中出现的报错集(更新中)