@@ -1142,6 +1142,25 @@ struct vfsmount *mntget(struct vfsmount *mnt)
}
EXPORT_SYMBOL(mntget);
+struct vfsmount *legitimize_mntget(struct vfsmount *vfsmnt)
+{
+ struct mount *mnt;
+
+ if (vfsmnt == NULL)
+ return NULL;
+
+ read_seqlock_excl(&mount_lock);
+ mnt = real_mount(vfsmnt);
+ if (vfsmnt->mnt_flags & (MNT_SYNC_UMOUNT | MNT_UMOUNT | MNT_DOOMED))
+ vfsmnt = NULL;
+ else
+ mnt_add_count(mnt, 1);
+ read_sequnlock_excl(&mount_lock);
+
+ return vfsmnt;
+}
+EXPORT_SYMBOL(legitimize_mntget);
+
struct vfsmount *mnt_clone_internal(struct path *path)
{
struct mount *p;
@@ -79,6 +79,7 @@ extern void mnt_drop_write(struct vfsmount *mnt);
extern void mnt_drop_write_file(struct file *file);
extern void mntput(struct vfsmount *mnt);
extern struct vfsmount *mntget(struct vfsmount *mnt);
+extern struct vfsmount *legitimize_mntget(struct vfsmount *vfsmnt);
extern struct vfsmount *mnt_clone_internal(struct path *path);
extern int __mnt_is_readonly(struct vfsmount *mnt);
New helper legitimize_mntget for getting a mnt without setting MNT_SYNC_UMOUNT | MNT_UMOUNT | MNT_DOOMED, otherwise return NULL. v6, New one Signed-off-by: Kinglong Mee <kinglongmee@gmail.com> --- fs/namespace.c | 19 +++++++++++++++++++ include/linux/mount.h | 1 + 2 files changed, 20 insertions(+)