Lines Matching full:parent

20 static DEFINE_RWLOCK(kernfs_rename_lock);	/* kn->parent and ->name */
59 return strscpy(buf, kn->parent ? kn->name : "/", buflen); in kernfs_name_locked()
67 while (to->parent && to != from) { in kernfs_depth()
69 to = to->parent; in kernfs_depth()
87 a = a->parent; in kernfs_common_ancestor()
91 b = b->parent; in kernfs_common_ancestor()
97 b = b->parent; in kernfs_common_ancestor()
98 a = a->parent; in kernfs_common_ancestor()
172 kn = kn->parent; in kernfs_path_from_node_locked()
209 * @from: parent kernfs_node relative to which we need to build the path
215 * be on the same kernfs-root. If @from is not parent of @to, then a relative
284 * kernfs_get_parent - determine the parent node and pin it
287 * Determines @kn's parent, pins and returns it. This function can be
290 * Return: parent node of @kn
294 struct kernfs_node *parent; in kernfs_get_parent() local
298 parent = kn->parent; in kernfs_get_parent()
299 kernfs_get(parent); in kernfs_get_parent()
302 return parent; in kernfs_get_parent()
353 * @kn->parent->dir.children.
363 struct rb_node **node = &kn->parent->dir.children.rb_node; in kernfs_link_sibling()
364 struct rb_node *parent = NULL; in kernfs_link_sibling() local
371 parent = *node; in kernfs_link_sibling()
382 rb_link_node(&kn->rb, parent, node); in kernfs_link_sibling()
383 rb_insert_color(&kn->rb, &kn->parent->dir.children); in kernfs_link_sibling()
388 kn->parent->dir.subdirs++; in kernfs_link_sibling()
389 kernfs_inc_rev(kn->parent); in kernfs_link_sibling()
400 * kn->parent->dir.children.
415 kn->parent->dir.subdirs--; in kernfs_unlink_sibling()
416 kernfs_inc_rev(kn->parent); in kernfs_unlink_sibling()
419 rb_erase(&kn->rb, &kn->parent->dir.children); in kernfs_unlink_sibling()
554 struct kernfs_node *parent; in kernfs_put() local
563 * kn->parent won't change beneath us. in kernfs_put()
565 parent = kn->parent; in kernfs_put()
569 parent ? parent->name : "", kn->name, atomic_read(&kn->active)); in kernfs_put()
580 kn = parent; in kernfs_put()
611 struct kernfs_node *parent, in __kernfs_new_node() argument
662 if (parent) { in __kernfs_new_node()
663 ret = security_kernfs_init_security(parent, kn); in __kernfs_new_node()
681 struct kernfs_node *kernfs_new_node(struct kernfs_node *parent, in kernfs_new_node() argument
688 if (parent->mode & S_ISGID) { in kernfs_new_node()
693 if (parent->iattr) in kernfs_new_node()
694 gid = parent->iattr->ia_gid; in kernfs_new_node()
700 kn = __kernfs_new_node(kernfs_root(parent), parent, in kernfs_new_node()
703 kernfs_get(parent); in kernfs_new_node()
704 kn->parent = parent; in kernfs_new_node()
759 * kernfs_add_one - add kernfs_node to parent without warning
762 * The caller must already have initialized @kn->parent. This
763 * function increments nlink of the parent's inode if @kn is a
764 * directory and link into the children list of the parent.
772 struct kernfs_node *parent = kn->parent; in kernfs_add_one() local
773 struct kernfs_root *root = kernfs_root(parent); in kernfs_add_one()
781 has_ns = kernfs_ns_enabled(parent); in kernfs_add_one()
783 has_ns ? "required" : "invalid", parent->name, kn->name)) in kernfs_add_one()
786 if (kernfs_type(parent) != KERNFS_DIR) in kernfs_add_one()
790 if (parent->flags & (KERNFS_REMOVING | KERNFS_EMPTY_DIR)) in kernfs_add_one()
799 /* Update timestamps on the parent */ in kernfs_add_one()
802 ps_iattr = parent->iattr; in kernfs_add_one()
829 * @parent: kernfs_node to search under
833 * Look for kernfs_node with name @name under @parent.
837 static struct kernfs_node *kernfs_find_ns(struct kernfs_node *parent, in kernfs_find_ns() argument
841 struct rb_node *node = parent->dir.children.rb_node; in kernfs_find_ns()
842 bool has_ns = kernfs_ns_enabled(parent); in kernfs_find_ns()
845 lockdep_assert_held(&kernfs_root(parent)->kernfs_rwsem); in kernfs_find_ns()
849 has_ns ? "required" : "invalid", parent->name, name); in kernfs_find_ns()
870 static struct kernfs_node *kernfs_walk_ns(struct kernfs_node *parent, in kernfs_walk_ns() argument
877 lockdep_assert_held_read(&kernfs_root(parent)->kernfs_rwsem); in kernfs_walk_ns()
890 while ((name = strsep(&p, "/")) && parent) { in kernfs_walk_ns()
893 parent = kernfs_find_ns(parent, name, ns); in kernfs_walk_ns()
898 return parent; in kernfs_walk_ns()
903 * @parent: kernfs_node to search under
907 * Look for kernfs_node with name @name under @parent and get a reference
912 struct kernfs_node *kernfs_find_and_get_ns(struct kernfs_node *parent, in kernfs_find_and_get_ns() argument
916 struct kernfs_root *root = kernfs_root(parent); in kernfs_find_and_get_ns()
919 kn = kernfs_find_ns(parent, name, ns); in kernfs_find_and_get_ns()
929 * @parent: kernfs_node to search under
933 * Look for kernfs_node with path @path under @parent and get a reference
938 struct kernfs_node *kernfs_walk_and_get_ns(struct kernfs_node *parent, in kernfs_walk_and_get_ns() argument
942 struct kernfs_root *root = kernfs_root(parent); in kernfs_walk_and_get_ns()
945 kn = kernfs_walk_ns(parent, path, ns); in kernfs_walk_and_get_ns()
1042 * @parent: parent in which to create a new directory
1052 struct kernfs_node *kernfs_create_dir_ns(struct kernfs_node *parent, in kernfs_create_dir_ns() argument
1061 kn = kernfs_new_node(parent, name, mode | S_IFDIR, in kernfs_create_dir_ns()
1066 kn->dir.root = parent->dir.root; in kernfs_create_dir_ns()
1081 * @parent: parent in which to create a new directory
1086 struct kernfs_node *kernfs_create_empty_dir(struct kernfs_node *parent, in kernfs_create_empty_dir() argument
1093 kn = kernfs_new_node(parent, name, S_IRUGO|S_IXUGO|S_IFDIR, in kernfs_create_empty_dir()
1099 kn->dir.root = parent->dir.root; in kernfs_create_empty_dir()
1122 struct kernfs_node *parent; in kernfs_dop_revalidate() local
1124 /* If the kernfs parent node has changed discard and in kernfs_dop_revalidate()
1128 * dentry parent, even if a concurrent rename is in in kernfs_dop_revalidate()
1142 parent = kernfs_dentry_node(dentry->d_parent); in kernfs_dop_revalidate()
1143 if (parent) { in kernfs_dop_revalidate()
1144 if (kernfs_dir_changed(parent, dentry)) { in kernfs_dop_revalidate()
1151 /* The kernfs parent node hasn't changed, leave the in kernfs_dop_revalidate()
1166 if (kernfs_dentry_node(dentry->d_parent) != kn->parent) in kernfs_dop_revalidate()
1174 if (kn->parent && kernfs_ns_enabled(kn->parent) && in kernfs_dop_revalidate()
1193 struct kernfs_node *parent = dir->i_private; in kernfs_iop_lookup() local
1199 root = kernfs_root(parent); in kernfs_iop_lookup()
1201 if (kernfs_ns_enabled(parent)) in kernfs_iop_lookup()
1204 kn = kernfs_find_ns(parent, dentry->d_name.name, ns); in kernfs_iop_lookup()
1225 kernfs_set_rev(parent, dentry); in kernfs_iop_lookup()
1236 struct kernfs_node *parent = dir->i_private; in kernfs_iop_mkdir() local
1237 struct kernfs_syscall_ops *scops = kernfs_root(parent)->syscall_ops; in kernfs_iop_mkdir()
1243 if (!kernfs_get_active(parent)) in kernfs_iop_mkdir()
1246 ret = scops->mkdir(parent, dentry->d_name.name, mode); in kernfs_iop_mkdir()
1248 kernfs_put_active(parent); in kernfs_iop_mkdir()
1366 /* no sibling left, visit parent */ in kernfs_next_descendant_post()
1367 return pos->parent; in kernfs_next_descendant_post()
1379 WARN_ON_ONCE(kn->parent && RB_EMPTY_NODE(&kn->rb)); in kernfs_activate_one()
1461 if (kn->parent && RB_EMPTY_NODE(&kn->rb)) in __kernfs_remove()
1492 if (!pos->parent || kernfs_unlink_sibling(pos)) { in __kernfs_remove()
1494 pos->parent ? pos->parent->iattr : NULL; in __kernfs_remove()
1496 /* update timestamps on the parent */ in __kernfs_remove()
1668 * @parent: parent of the target
1672 * Look for the kernfs_node with @name and @ns under @parent and remove it.
1676 int kernfs_remove_by_name_ns(struct kernfs_node *parent, const char *name, in kernfs_remove_by_name_ns() argument
1682 if (!parent) { in kernfs_remove_by_name_ns()
1688 root = kernfs_root(parent); in kernfs_remove_by_name_ns()
1691 kn = kernfs_find_ns(parent, name, ns); in kernfs_remove_by_name_ns()
1709 * @new_parent: new parent to put @sd under
1724 if (!kn->parent) in kernfs_rename_ns()
1736 if ((kn->parent == new_parent) && (kn->ns == new_ns) && in kernfs_rename_ns()
1760 /* rename_lock protects ->parent and ->name accessors */ in kernfs_rename_ns()
1763 old_parent = kn->parent; in kernfs_rename_ns()
1764 kn->parent = new_parent; in kernfs_rename_ns()
1793 struct kernfs_node *parent, loff_t hash, struct kernfs_node *pos) in kernfs_dir_pos() argument
1797 pos->parent == parent && hash == pos->hash; in kernfs_dir_pos()
1803 struct rb_node *node = parent->dir.children.rb_node; in kernfs_dir_pos()
1827 struct kernfs_node *parent, ino_t ino, struct kernfs_node *pos) in kernfs_dir_next_pos() argument
1829 pos = kernfs_dir_pos(ns, parent, ino, pos); in kernfs_dir_next_pos()
1845 struct kernfs_node *parent = kernfs_dentry_node(dentry); in kernfs_fop_readdir() local
1853 root = kernfs_root(parent); in kernfs_fop_readdir()
1856 if (kernfs_ns_enabled(parent)) in kernfs_fop_readdir()
1859 for (pos = kernfs_dir_pos(ns, parent, ctx->pos, pos); in kernfs_fop_readdir()
1861 pos = kernfs_dir_next_pos(ns, parent, ctx->pos, pos)) { in kernfs_fop_readdir()