summaryrefslogtreecommitdiffstats
path: root/fs/kernfs/mount.c
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 16:00:41 -0800
commit0c23b2259a4850494e2c53e864ea840597c6cdd3 (patch)
treef4d061ea433e443edd43d1f0a186e06aeb2ed95e /fs/kernfs/mount.c
parent2536390da0d300b2734c721235c082498879841d (diff)
downloadlinux-0c23b2259a4850494e2c53e864ea840597c6cdd3.tar.gz
linux-0c23b2259a4850494e2c53e864ea840597c6cdd3.tar.bz2
linux-0c23b2259a4850494e2c53e864ea840597c6cdd3.zip
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/mount.c')
-rw-r--r--fs/kernfs/mount.c14
1 files changed, 14 insertions, 0 deletions
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 = {
.show_options = kernfs_sop_show_options,
};
+/**
+ * kernfs_root_from_sb - determine kernfs_root associated with a super_block
+ * @sb: the super_block in question
+ *
+ * Return the kernfs_root associated with @sb. If @sb is not a kernfs one,
+ * %NULL is returned.
+ */
+struct kernfs_root *kernfs_root_from_sb(struct super_block *sb)
+{
+ if (sb->s_op == &kernfs_sops)
+ return kernfs_info(sb)->root;
+ return NULL;
+}
+
static int kernfs_fill_super(struct super_block *sb)
{
struct kernfs_super_info *info = kernfs_info(sb);