aboutsummaryrefslogtreecommitdiffstats
path: root/fs/kernfs
diff options
context:
space:
mode:
authorTejun Heo <tj@kernel.org>2014-02-03 14:09:15 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2014-02-07 19:00:41 -0500
commit0c23b2259a4850494e2c53e864ea840597c6cdd3 (patch)
treef4d061ea433e443edd43d1f0a186e06aeb2ed95e /fs/kernfs
parent2536390da0d300b2734c721235c082498879841d (diff)
kernfs: implement kernfs_node_from_dentry(), kernfs_root_from_sb() and kernfs_rename()
Implement helpers to determine node from dentry and root from super_block. Also add a kernfs_rename_ns() wrapper which assumes NULL namespace. These generally make sense and will be used by cgroup. v2: Some dummy implementations for !CONFIG_SYSFS was missing. Fixed. Reported by kbuild test robot. Signed-off-by: Tejun Heo <tj@kernel.org> Cc: kbuild test robot <fengguang.wu@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'fs/kernfs')
-rw-r--r--fs/kernfs/dir.c18
-rw-r--r--fs/kernfs/mount.c14
2 files changed, 32 insertions, 0 deletions
diff --git a/fs/kernfs/dir.c b/fs/kernfs/dir.c
index 3cff0a233cd1..42a250f83b98 100644
--- a/fs/kernfs/dir.c
+++ b/fs/kernfs/dir.c
@@ -350,6 +350,24 @@ const struct dentry_operations kernfs_dops = {
350 .d_release = kernfs_dop_release, 350 .d_release = kernfs_dop_release,
351}; 351};
352 352
353/**
354 * kernfs_node_from_dentry - determine kernfs_node associated with a dentry
355 * @dentry: the dentry in question
356 *
357 * Return the kernfs_node associated with @dentry. If @dentry is not a
358 * kernfs one, %NULL is returned.
359 *
360 * While the returned kernfs_node will stay accessible as long as @dentry
361 * is accessible, the returned node can be in any state and the caller is
362 * fully responsible for determining what's accessible.
363 */
364struct kernfs_node *kernfs_node_from_dentry(struct dentry *dentry)
365{
366 if (dentry->d_op == &kernfs_dops)
367 return dentry->d_fsdata;
368 return NULL;
369}
370
353static struct kernfs_node *__kernfs_new_node(struct kernfs_root *root, 371static struct kernfs_node *__kernfs_new_node(struct kernfs_root *root,
354 const char *name, umode_t mode, 372 const char *name, umode_t mode,
355 unsigned flags) 373 unsigned flags)
diff --git a/fs/kernfs/mount.c b/fs/kernfs/mount.c
index 70cc6983d9b5..e5b28b0ebc37 100644
--- a/fs/kernfs/mount.c
+++ b/fs/kernfs/mount.c
@@ -48,6 +48,20 @@ static const struct super_operations kernfs_sops = {
48 .show_options = kernfs_sop_show_options, 48 .show_options = kernfs_sop_show_options,
49}; 49};
50 50
51/**
52 * kernfs_root_from_sb - determine kernfs_root associated with a super_block
53 * @sb: the super_block in question
54 *
55 * Return the kernfs_root associated with @sb. If @sb is not a kernfs one,
56 * %NULL is returned.
57 */
58struct kernfs_root *kernfs_root_from_sb(struct super_block *sb)
59{
60 if (sb->s_op == &kernfs_sops)
61 return kernfs_info(sb)->root;
62 return NULL;
63}
64
51static int kernfs_fill_super(struct super_block *sb) 65static int kernfs_fill_super(struct super_block *sb)
52{ 66{
53 struct kernfs_super_info *info = kernfs_info(sb); 67 struct kernfs_super_info *info = kernfs_info(sb);