[PATCH 03/16] vfs: Implement vfs_loopback_mount

From: Eric W. Biederman
Date: Fri Apr 15 2016 - 11:46:51 EST


Add a helper to turn a struct path into a mount.

Signed-off-by: "Eric W. Biederman" <ebiederm@xxxxxxxxxxxx>
---
fs/namespace.c | 9 +++++++++
include/linux/mount.h | 1 +
2 files changed, 10 insertions(+)

diff --git a/fs/namespace.c b/fs/namespace.c
index 4fb1691b4355..714778360c2b 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -1047,6 +1047,15 @@ static struct mount *clone_mnt(struct mount *old, struct dentry *root,
return ERR_PTR(err);
}

+struct vfsmount *vfs_loopback_mount(struct path *path)
+{
+ struct mount *p;
+ p = clone_mnt(real_mount(path->mnt), path->dentry, 0);
+ if (IS_ERR(p))
+ return ERR_CAST(p);
+ return &p->mnt;
+}
+
static void cleanup_mnt(struct mount *mnt)
{
/*
diff --git a/include/linux/mount.h b/include/linux/mount.h
index f822c3c11377..8f6039ad898e 100644
--- a/include/linux/mount.h
+++ b/include/linux/mount.h
@@ -89,6 +89,7 @@ struct file_system_type;
extern struct vfsmount *vfs_kern_mount(struct file_system_type *type,
int flags, const char *name,
void *data);
+struct vfsmount *vfs_loopback_mount(struct path *path);

extern void mnt_set_expiry(struct vfsmount *mnt, struct list_head *expiry_list);
extern void mark_mounts_for_expiry(struct list_head *mounts);
--
2.8.1