File tree Expand file tree Collapse file tree 2 files changed +30
-0
lines changed Expand file tree Collapse file tree 2 files changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -1686,6 +1686,33 @@ void drop_collected_mounts(struct vfsmount *mnt)
1686
1686
namespace_unlock ();
1687
1687
}
1688
1688
1689
+ /**
1690
+ * clone_private_mount - create a private clone of a path
1691
+ *
1692
+ * This creates a new vfsmount, which will be the clone of @path. The new will
1693
+ * not be attached anywhere in the namespace and will be private (i.e. changes
1694
+ * to the originating mount won't be propagated into this).
1695
+ *
1696
+ * Release with mntput().
1697
+ */
1698
+ struct vfsmount * clone_private_mount (struct path * path )
1699
+ {
1700
+ struct mount * old_mnt = real_mount (path -> mnt );
1701
+ struct mount * new_mnt ;
1702
+
1703
+ if (IS_MNT_UNBINDABLE (old_mnt ))
1704
+ return ERR_PTR (- EINVAL );
1705
+
1706
+ down_read (& namespace_sem );
1707
+ new_mnt = clone_mnt (old_mnt , path -> dentry , CL_PRIVATE );
1708
+ up_read (& namespace_sem );
1709
+ if (IS_ERR (new_mnt ))
1710
+ return ERR_CAST (new_mnt );
1711
+
1712
+ return & new_mnt -> mnt ;
1713
+ }
1714
+ EXPORT_SYMBOL_GPL (clone_private_mount );
1715
+
1689
1716
int iterate_mounts (int (* f )(struct vfsmount * , void * ), void * arg ,
1690
1717
struct vfsmount * root )
1691
1718
{
Original file line number Diff line number Diff line change @@ -81,6 +81,9 @@ extern struct vfsmount *mntget(struct vfsmount *mnt);
81
81
extern struct vfsmount * mnt_clone_internal (struct path * path );
82
82
extern int __mnt_is_readonly (struct vfsmount * mnt );
83
83
84
+ struct path ;
85
+ extern struct vfsmount * clone_private_mount (struct path * path );
86
+
84
87
struct file_system_type ;
85
88
extern struct vfsmount * vfs_kern_mount (struct file_system_type * type ,
86
89
int flags , const char * name ,
You can’t perform that action at this time.
0 commit comments