[PATCH RFC v3 06/12] fs/namespace: implement mnt_clone_direct()
Hannes Reinecke
hare at kernel.org
Tue Jun 23 02:15:51 PDT 2026
Implement mnt_clone_direct() to just clone an existing vfsmount.
Signed-off-by: Hannes Reinecke <hare at kernel.org>
---
fs/namespace.c | 11 +++++++++++
include/linux/mount.h | 1 +
2 files changed, 12 insertions(+)
diff --git a/fs/namespace.c b/fs/namespace.c
index 3d5cd5bf3b05376c867281541100c6a5e599d387..e7abbf632cc70d70547e4a2483f2217c95cc0c48 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -1482,6 +1482,17 @@ struct vfsmount *mnt_clone_internal(const struct path *path)
return &p->mnt;
}
+struct vfsmount *mnt_clone_direct(struct vfsmount *mnt, struct dentry *dentry)
+{
+ struct mount *p;
+
+ p = clone_mnt(real_mount(mnt), dentry, CL_SLAVE);
+ if (IS_ERR(p))
+ return ERR_CAST(p);
+ p->mnt.mnt_flags |= MNT_INTERNAL;
+ return &p->mnt;
+}
+
/*
* Returns the mount which either has the specified mnt_id, or has the next
* smallest id afer the specified one.
diff --git a/include/linux/mount.h b/include/linux/mount.h
index acfe7ef86a1b3fdd70ab460e6e731d3c532b6487..7e7e7d66c3024b907497954a247c7e35dbcfc946 100644
--- a/include/linux/mount.h
+++ b/include/linux/mount.h
@@ -75,6 +75,7 @@ extern void mnt_drop_write_file(struct file *file);
extern void mntput(struct vfsmount *mnt);
extern struct vfsmount *mntget(struct vfsmount *mnt);
extern void mnt_make_shortterm(struct vfsmount *mnt);
+extern struct vfsmount *mnt_clone_direct(struct vfsmount *mnt, struct dentry *dentry);
extern struct vfsmount *mnt_clone_internal(const struct path *path);
extern bool __mnt_is_readonly(const struct vfsmount *mnt);
extern bool mnt_may_suid(struct vfsmount *mnt);
--
2.51.0
More information about the Linux-nvme
mailing list