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()
172 struct bin_attribute *battr = of->kn->priv; in sysfs_kf_bin_open()
182 struct kernfs_node *kn = kobj->sd, *tmp; in sysfs_notify() local
184 if (kn && dir) in sysfs_notify()
185 kn = kernfs_find_and_get(kn, dir); in sysfs_notify()
187 kernfs_get(kn); in sysfs_notify()
189 if (kn && attr) { in sysfs_notify()
190 tmp = kernfs_find_and_get(kn, attr); in sysfs_notify()
191 kernfs_put(kn); in sysfs_notify()
192 kn = tmp; in sysfs_notify()
195 if (kn) { in sysfs_notify()
196 kernfs_notify(kn); in sysfs_notify()
197 kernfs_put(kn); in sysfs_notify()
262 struct kernfs_node *kn; in sysfs_add_file_mode_ns() local
294 kn = __kernfs_create_file(parent, attr->name, mode & 0777, uid, gid, in sysfs_add_file_mode_ns()
296 if (IS_ERR(kn)) { in sysfs_add_file_mode_ns()
297 if (PTR_ERR(kn) == -EEXIST) in sysfs_add_file_mode_ns()
299 return PTR_ERR(kn); in sysfs_add_file_mode_ns()
311 struct kernfs_node *kn; in sysfs_add_bin_file_mode_ns() local
329 kn = __kernfs_create_file(parent, attr->name, mode & 0777, uid, gid, in sysfs_add_bin_file_mode_ns()
331 if (IS_ERR(kn)) { in sysfs_add_bin_file_mode_ns()
332 if (PTR_ERR(kn) == -EEXIST) in sysfs_add_bin_file_mode_ns()
334 return PTR_ERR(kn); in sysfs_add_bin_file_mode_ns()
416 struct kernfs_node *kn; in sysfs_chmod_file() local
420 kn = kernfs_find_and_get(kobj->sd, attr->name); in sysfs_chmod_file()
421 if (!kn) in sysfs_chmod_file()
424 newattrs.ia_mode = (mode & S_IALLUGO) | (kn->mode & ~S_IALLUGO); in sysfs_chmod_file()
427 rc = kernfs_setattr(kn, &newattrs); in sysfs_chmod_file()
429 kernfs_put(kn); in sysfs_chmod_file()
447 struct kernfs_node *kn; in sysfs_break_active_protection() local
450 kn = kernfs_find_and_get(kobj->sd, attr->name); in sysfs_break_active_protection()
451 if (kn) in sysfs_break_active_protection()
452 kernfs_break_active_protection(kn); in sysfs_break_active_protection()
453 return kn; in sysfs_break_active_protection()
468 void sysfs_unbreak_active_protection(struct kernfs_node *kn) in sysfs_unbreak_active_protection() argument
470 struct kobject *kobj = kn->parent->priv; in sysfs_unbreak_active_protection()
472 kernfs_unbreak_active_protection(kn); in sysfs_unbreak_active_protection()
473 kernfs_put(kn); in sysfs_unbreak_active_protection()
505 struct kernfs_node *kn; in sysfs_remove_file_self() local
508 kn = kernfs_find_and_get(parent, attr->name); in sysfs_remove_file_self()
509 if (WARN_ON_ONCE(!kn)) in sysfs_remove_file_self()
512 ret = kernfs_remove_self(kn); in sysfs_remove_file_self()
514 kernfs_put(kn); in sysfs_remove_file_self()
585 static int internal_change_owner(struct kernfs_node *kn, kuid_t kuid, in internal_change_owner() argument
593 return kernfs_setattr(kn, &newattrs); in internal_change_owner()
613 struct kernfs_node *kn = NULL; in sysfs_link_change_owner() local
620 kn = kernfs_find_and_get_ns(kobj->sd, name, targ->sd->ns); in sysfs_link_change_owner()
621 if (!kn) in sysfs_link_change_owner()
625 if (kernfs_type(kn) != KERNFS_LINK) in sysfs_link_change_owner()
627 if (kn->symlink.target_kn->priv != targ) in sysfs_link_change_owner()
630 error = internal_change_owner(kn, kuid, kgid); in sysfs_link_change_owner()
633 kernfs_put(kn); in sysfs_link_change_owner()
652 struct kernfs_node *kn; in sysfs_file_change_owner() local
661 kn = kernfs_find_and_get(kobj->sd, name); in sysfs_file_change_owner()
662 if (!kn) in sysfs_file_change_owner()
665 error = internal_change_owner(kn, kuid, kgid); in sysfs_file_change_owner()
667 kernfs_put(kn); in sysfs_file_change_owner()