Lines Matching refs:kn

26 static const struct sysfs_ops *sysfs_file_ops(struct kernfs_node *kn)  in sysfs_file_ops()  argument
28 struct kobject *kobj = kn->parent->priv; in sysfs_file_ops()
30 if (kn->flags & KERNFS_LOCKDEP) in sysfs_file_ops()
31 lockdep_assert_held(kn); in sysfs_file_ops()
43 struct kobject *kobj = of->kn->parent->priv; in sysfs_kf_seq_show()
44 const struct sysfs_ops *ops = sysfs_file_ops(of->kn); in sysfs_kf_seq_show()
59 count = ops->show(kobj, of->kn->priv, buf); in sysfs_kf_seq_show()
80 struct bin_attribute *battr = of->kn->priv; in sysfs_kf_bin_read()
81 struct kobject *kobj = of->kn->parent->priv; in sysfs_kf_bin_read()
104 const struct sysfs_ops *ops = sysfs_file_ops(of->kn); in sysfs_kf_read()
105 struct kobject *kobj = of->kn->parent->priv; in sysfs_kf_read()
114 len = ops->show(kobj, of->kn->priv, buf); in sysfs_kf_read()
130 const struct sysfs_ops *ops = sysfs_file_ops(of->kn); in sysfs_kf_write()
131 struct kobject *kobj = of->kn->parent->priv; in sysfs_kf_write()
136 return ops->store(kobj, of->kn->priv, buf, count); in sysfs_kf_write()
143 struct bin_attribute *battr = of->kn->priv; in sysfs_kf_bin_write()
144 struct kobject *kobj = of->kn->parent->priv; in sysfs_kf_bin_write()
164 struct bin_attribute *battr = of->kn->priv; in sysfs_kf_bin_mmap()
165 struct kobject *kobj = of->kn->parent->priv; in sysfs_kf_bin_mmap()
173 struct bin_attribute *battr = of->kn->priv; in sysfs_kf_bin_llseek()
174 struct kobject *kobj = of->kn->parent->priv; in sysfs_kf_bin_llseek()
184 struct bin_attribute *battr = of->kn->priv; in sysfs_kf_bin_open()
194 struct kernfs_node *kn = kobj->sd, *tmp; in sysfs_notify() local
196 if (kn && dir) in sysfs_notify()
197 kn = kernfs_find_and_get(kn, dir); in sysfs_notify()
199 kernfs_get(kn); in sysfs_notify()
201 if (kn && attr) { in sysfs_notify()
202 tmp = kernfs_find_and_get(kn, attr); in sysfs_notify()
203 kernfs_put(kn); in sysfs_notify()
204 kn = tmp; in sysfs_notify()
207 if (kn) { in sysfs_notify()
208 kernfs_notify(kn); in sysfs_notify()
209 kernfs_put(kn); in sysfs_notify()
275 struct kernfs_node *kn; in sysfs_add_file_mode_ns() local
307 kn = __kernfs_create_file(parent, attr->name, mode & 0777, uid, gid, in sysfs_add_file_mode_ns()
309 if (IS_ERR(kn)) { in sysfs_add_file_mode_ns()
310 if (PTR_ERR(kn) == -EEXIST) in sysfs_add_file_mode_ns()
312 return PTR_ERR(kn); in sysfs_add_file_mode_ns()
324 struct kernfs_node *kn; in sysfs_add_bin_file_mode_ns() local
342 kn = __kernfs_create_file(parent, attr->name, mode & 0777, uid, gid, in sysfs_add_bin_file_mode_ns()
344 if (IS_ERR(kn)) { in sysfs_add_bin_file_mode_ns()
345 if (PTR_ERR(kn) == -EEXIST) in sysfs_add_bin_file_mode_ns()
347 return PTR_ERR(kn); in sysfs_add_bin_file_mode_ns()
429 struct kernfs_node *kn; in sysfs_chmod_file() local
433 kn = kernfs_find_and_get(kobj->sd, attr->name); in sysfs_chmod_file()
434 if (!kn) in sysfs_chmod_file()
437 newattrs.ia_mode = (mode & S_IALLUGO) | (kn->mode & ~S_IALLUGO); in sysfs_chmod_file()
440 rc = kernfs_setattr(kn, &newattrs); in sysfs_chmod_file()
442 kernfs_put(kn); in sysfs_chmod_file()
460 struct kernfs_node *kn; in sysfs_break_active_protection() local
463 kn = kernfs_find_and_get(kobj->sd, attr->name); in sysfs_break_active_protection()
464 if (kn) in sysfs_break_active_protection()
465 kernfs_break_active_protection(kn); in sysfs_break_active_protection()
468 return kn; in sysfs_break_active_protection()
483 void sysfs_unbreak_active_protection(struct kernfs_node *kn) in sysfs_unbreak_active_protection() argument
485 struct kobject *kobj = kn->parent->priv; in sysfs_unbreak_active_protection()
487 kernfs_unbreak_active_protection(kn); in sysfs_unbreak_active_protection()
488 kernfs_put(kn); in sysfs_unbreak_active_protection()
520 struct kernfs_node *kn; in sysfs_remove_file_self() local
523 kn = kernfs_find_and_get(parent, attr->name); in sysfs_remove_file_self()
524 if (WARN_ON_ONCE(!kn)) in sysfs_remove_file_self()
527 ret = kernfs_remove_self(kn); in sysfs_remove_file_self()
529 kernfs_put(kn); in sysfs_remove_file_self()
600 static int internal_change_owner(struct kernfs_node *kn, kuid_t kuid, in internal_change_owner() argument
608 return kernfs_setattr(kn, &newattrs); in internal_change_owner()
628 struct kernfs_node *kn = NULL; in sysfs_link_change_owner() local
635 kn = kernfs_find_and_get_ns(kobj->sd, name, targ->sd->ns); in sysfs_link_change_owner()
636 if (!kn) in sysfs_link_change_owner()
640 if (kernfs_type(kn) != KERNFS_LINK) in sysfs_link_change_owner()
642 if (kn->symlink.target_kn->priv != targ) in sysfs_link_change_owner()
645 error = internal_change_owner(kn, kuid, kgid); in sysfs_link_change_owner()
648 kernfs_put(kn); in sysfs_link_change_owner()
667 struct kernfs_node *kn; in sysfs_file_change_owner() local
676 kn = kernfs_find_and_get(kobj->sd, name); in sysfs_file_change_owner()
677 if (!kn) in sysfs_file_change_owner()
680 error = internal_change_owner(kn, kuid, kgid); in sysfs_file_change_owner()
682 kernfs_put(kn); in sysfs_file_change_owner()