Lines Matching refs:kn

22 static struct kobject *sysfs_file_kobj(struct kernfs_node *kn)  in sysfs_file_kobj()  argument
25 return rcu_dereference(kn->__parent)->priv; in sysfs_file_kobj()
32 static const struct sysfs_ops *sysfs_file_ops(struct kernfs_node *kn) in sysfs_file_ops() argument
34 struct kobject *kobj = sysfs_file_kobj(kn); in sysfs_file_ops()
36 if (kn->flags & KERNFS_LOCKDEP) in sysfs_file_ops()
37 lockdep_assert_held(kn); in sysfs_file_ops()
49 struct kobject *kobj = sysfs_file_kobj(of->kn); in sysfs_kf_seq_show()
50 const struct sysfs_ops *ops = sysfs_file_ops(of->kn); in sysfs_kf_seq_show()
65 count = ops->show(kobj, of->kn->priv, buf); in sysfs_kf_seq_show()
86 const struct bin_attribute *battr = of->kn->priv; in sysfs_kf_bin_read()
87 struct kobject *kobj = sysfs_file_kobj(of->kn); in sysfs_kf_bin_read()
110 const struct sysfs_ops *ops = sysfs_file_ops(of->kn); in sysfs_kf_read()
111 struct kobject *kobj = sysfs_file_kobj(of->kn); in sysfs_kf_read()
120 len = ops->show(kobj, of->kn->priv, buf); in sysfs_kf_read()
136 const struct sysfs_ops *ops = sysfs_file_ops(of->kn); in sysfs_kf_write()
137 struct kobject *kobj = sysfs_file_kobj(of->kn); in sysfs_kf_write()
142 return ops->store(kobj, of->kn->priv, buf, count); in sysfs_kf_write()
149 const struct bin_attribute *battr = of->kn->priv; in sysfs_kf_bin_write()
150 struct kobject *kobj = sysfs_file_kobj(of->kn); in sysfs_kf_bin_write()
170 const struct bin_attribute *battr = of->kn->priv; in sysfs_kf_bin_mmap()
171 struct kobject *kobj = sysfs_file_kobj(of->kn); in sysfs_kf_bin_mmap()
179 const struct bin_attribute *battr = of->kn->priv; in sysfs_kf_bin_llseek()
180 struct kobject *kobj = sysfs_file_kobj(of->kn); in sysfs_kf_bin_llseek()
190 const struct bin_attribute *battr = of->kn->priv; in sysfs_kf_bin_open()
200 struct kernfs_node *kn = kobj->sd, *tmp; in sysfs_notify() local
202 if (kn && dir) in sysfs_notify()
203 kn = kernfs_find_and_get(kn, dir); in sysfs_notify()
205 kernfs_get(kn); in sysfs_notify()
207 if (kn && attr) { in sysfs_notify()
208 tmp = kernfs_find_and_get(kn, attr); in sysfs_notify()
209 kernfs_put(kn); in sysfs_notify()
210 kn = tmp; in sysfs_notify()
213 if (kn) { in sysfs_notify()
214 kernfs_notify(kn); in sysfs_notify()
215 kernfs_put(kn); in sysfs_notify()
281 struct kernfs_node *kn; in sysfs_add_file_mode_ns() local
313 kn = __kernfs_create_file(parent, attr->name, mode & 0777, uid, gid, in sysfs_add_file_mode_ns()
315 if (IS_ERR(kn)) { in sysfs_add_file_mode_ns()
316 if (PTR_ERR(kn) == -EEXIST) in sysfs_add_file_mode_ns()
318 return PTR_ERR(kn); in sysfs_add_file_mode_ns()
330 struct kernfs_node *kn; in sysfs_add_bin_file_mode_ns() local
348 kn = __kernfs_create_file(parent, attr->name, mode & 0777, uid, gid, in sysfs_add_bin_file_mode_ns()
350 if (IS_ERR(kn)) { in sysfs_add_bin_file_mode_ns()
351 if (PTR_ERR(kn) == -EEXIST) in sysfs_add_bin_file_mode_ns()
353 return PTR_ERR(kn); in sysfs_add_bin_file_mode_ns()
435 struct kernfs_node *kn; in sysfs_chmod_file() local
439 kn = kernfs_find_and_get(kobj->sd, attr->name); in sysfs_chmod_file()
440 if (!kn) in sysfs_chmod_file()
443 newattrs.ia_mode = (mode & S_IALLUGO) | (kn->mode & ~S_IALLUGO); in sysfs_chmod_file()
446 rc = kernfs_setattr(kn, &newattrs); in sysfs_chmod_file()
448 kernfs_put(kn); in sysfs_chmod_file()
466 struct kernfs_node *kn; in sysfs_break_active_protection() local
469 kn = kernfs_find_and_get(kobj->sd, attr->name); in sysfs_break_active_protection()
470 if (kn) in sysfs_break_active_protection()
471 kernfs_break_active_protection(kn); in sysfs_break_active_protection()
474 return kn; in sysfs_break_active_protection()
489 void sysfs_unbreak_active_protection(struct kernfs_node *kn) in sysfs_unbreak_active_protection() argument
491 struct kobject *kobj = sysfs_file_kobj(kn); in sysfs_unbreak_active_protection()
493 kernfs_unbreak_active_protection(kn); in sysfs_unbreak_active_protection()
494 kernfs_put(kn); in sysfs_unbreak_active_protection()
526 struct kernfs_node *kn; in sysfs_remove_file_self() local
529 kn = kernfs_find_and_get(parent, attr->name); in sysfs_remove_file_self()
530 if (WARN_ON_ONCE(!kn)) in sysfs_remove_file_self()
533 ret = kernfs_remove_self(kn); in sysfs_remove_file_self()
535 kernfs_put(kn); in sysfs_remove_file_self()
606 static int internal_change_owner(struct kernfs_node *kn, kuid_t kuid, in internal_change_owner() argument
614 return kernfs_setattr(kn, &newattrs); in internal_change_owner()
634 struct kernfs_node *kn = NULL; in sysfs_link_change_owner() local
641 kn = kernfs_find_and_get_ns(kobj->sd, name, targ->sd->ns); in sysfs_link_change_owner()
642 if (!kn) in sysfs_link_change_owner()
646 if (kernfs_type(kn) != KERNFS_LINK) in sysfs_link_change_owner()
648 if (kn->symlink.target_kn->priv != targ) in sysfs_link_change_owner()
651 error = internal_change_owner(kn, kuid, kgid); in sysfs_link_change_owner()
654 kernfs_put(kn); in sysfs_link_change_owner()
673 struct kernfs_node *kn; in sysfs_file_change_owner() local
682 kn = kernfs_find_and_get(kobj->sd, name); in sysfs_file_change_owner()
683 if (!kn) in sysfs_file_change_owner()
686 error = internal_change_owner(kn, kuid, kgid); in sysfs_file_change_owner()
688 kernfs_put(kn); in sysfs_file_change_owner()