Ubuntu Pastebin

Paste from zyga at Tue, 31 Jan 2017 19:21:52 +0000

Download as text
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
From da15e54c23f4708dd7550bb6478469da311de804 Mon Sep 17 00:00:00 2001
From: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
Date: Tue, 31 Jan 2017 17:24:45 +0100
Subject: [PATCH] fs: store MS_BIND as MNT_BIND and show it in mountinfo

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@canonical.com>
---
 fs/namespace.c        | 1 +
 fs/proc_namespace.c   | 1 +
 include/linux/mount.h | 3 ++-
 3 files changed, 4 insertions(+), 1 deletion(-)

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..71d5ba3 100644
--- a/include/linux/mount.h
+++ b/include/linux/mount.h
@@ -48,7 +48,7 @@ struct mnt_namespace;
 #define MNT_ATIME_MASK (MNT_NOATIME | MNT_NODIRATIME | MNT_RELATIME )
 
 #define MNT_INTERNAL_FLAGS (MNT_SHARED | MNT_WRITE_HOLD | MNT_INTERNAL | \
-			    MNT_DOOMED | MNT_SYNC_UMOUNT | MNT_MARKED)
+			    MNT_DOOMED | MNT_SYNC_UMOUNT | MNT_MARKED | MNT_BIND)
 
 #define MNT_INTERNAL	0x4000
 
@@ -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
Download as text