[PATCH] fs: store MS_BIND as MNT_BIND and show it in mountinfo

Zygmunt Krynicki zygmunt.krynicki at canonical.com
Thu Feb 2 13:21:04 UTC 2017


This patch adds a new MNT_ flag that is set for bind mounts (it mirrors
MS_BIND) and surfaces it via mountinfo. This allows for easier
identification of mount entries that are bind mounted from somewhere
else.

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki at canonical.com>
---
 fs/namespace.c        | 1 +
 fs/proc_namespace.c   | 1 +
 include/linux/mount.h | 1 +
 3 files changed, 3 insertions(+)

diff --git a/fs/namespace.c b/fs/namespace.c
index c9ba9d1..e2fc0c1 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -2162,6 +2162,7 @@ static int do_loopback(struct path *path, const char *old_name,
 	}
 
 	mnt->mnt.mnt_flags &= ~MNT_LOCKED;
+	mnt->mnt.mnt_flags |= MNT_BIND;
 
 	err = graft_tree(mnt, parent, mp);
 	if (err) {
diff --git a/fs/proc_namespace.c b/fs/proc_namespace.c
index 876459559..e510585 100644
--- a/fs/proc_namespace.c
+++ b/fs/proc_namespace.c
@@ -67,6 +67,7 @@ static void show_mnt_opts(struct seq_file *m, struct vfsmount *mnt)
 		{ MNT_NOATIME, ",noatime" },
 		{ MNT_NODIRATIME, ",nodiratime" },
 		{ MNT_RELATIME, ",relatime" },
+		{ MNT_BIND, ",bind" },
 		{ 0, NULL }
 	};
 	const struct proc_fs_info *fs_infop;
diff --git a/include/linux/mount.h b/include/linux/mount.h
index 1172cce..81f7bec 100644
--- a/include/linux/mount.h
+++ b/include/linux/mount.h
@@ -62,6 +62,7 @@ struct mnt_namespace;
 #define MNT_SYNC_UMOUNT		0x2000000
 #define MNT_MARKED		0x4000000
 #define MNT_UMOUNT		0x8000000
+#define MNT_BIND		0x10000000
 
 struct vfsmount {
 	struct dentry *mnt_root;	/* root of the mounted tree */
-- 
2.7.4





More information about the kernel-team mailing list