Browse code

pkg/mount: add more sharesubtree options

Signed-off-by: Vincent Batts <vbatts@redhat.com>

Vincent Batts authored on 2014/10/31 23:18:41
Showing 5 changed files
... ...
@@ -37,7 +37,14 @@ func parseOptions(options string) (int, string) {
37 37
 		"nodiratime":    {false, NODIRATIME},
38 38
 		"bind":          {false, BIND},
39 39
 		"rbind":         {false, RBIND},
40
+		"unbindable":    {false, UNBINDABLE},
41
+		"runbindable":   {false, RUNBINDABLE},
40 42
 		"private":       {false, PRIVATE},
43
+		"rprivate":      {false, RPRIVATE},
44
+		"shared":        {false, SHARED},
45
+		"rshared":       {false, RSHARED},
46
+		"slave":         {false, SLAVE},
47
+		"rslave":        {false, RSLAVE},
41 48
 		"relatime":      {false, RELATIME},
42 49
 		"norelatime":    {true, RELATIME},
43 50
 		"strictatime":   {false, STRICTATIME},
... ...
@@ -19,7 +19,14 @@ const (
19 19
 	MANDLOCK    = 0
20 20
 	NODEV       = 0
21 21
 	NODIRATIME  = 0
22
+	UNBINDABLE  = 0
23
+	RUNBINDABLE = 0
22 24
 	PRIVATE     = 0
25
+	RPRIVATE    = 0
26
+	SHARED      = 0
27
+	RSHARED     = 0
28
+	SLAVE       = 0
29
+	RSLAVE      = 0
23 30
 	RBIND       = 0
24 31
 	RELATIVE    = 0
25 32
 	RELATIME    = 0
... ...
@@ -17,7 +17,14 @@ const (
17 17
 	NODIRATIME  = syscall.MS_NODIRATIME
18 18
 	BIND        = syscall.MS_BIND
19 19
 	RBIND       = syscall.MS_BIND | syscall.MS_REC
20
+	UNBINDABLE  = syscall.MS_UNBINDABLE
21
+	RUNBINDABLE = syscall.MS_UNBINDABLE | syscall.MS_REC
20 22
 	PRIVATE     = syscall.MS_PRIVATE
23
+	RPRIVATE    = syscall.MS_PRIVATE | syscall.MS_REC
24
+	SLAVE       = syscall.MS_SLAVE
25
+	RSLAVE      = syscall.MS_SLAVE | syscall.MS_REC
26
+	SHARED      = syscall.MS_SHARED
27
+	RSHARED     = syscall.MS_SHARED | syscall.MS_REC
21 28
 	RELATIME    = syscall.MS_RELATIME
22 29
 	STRICTATIME = syscall.MS_STRICTATIME
23 30
 )
... ...
@@ -11,7 +11,14 @@ const (
11 11
 	NODIRATIME  = 0
12 12
 	NOEXEC      = 0
13 13
 	NOSUID      = 0
14
+	UNBINDABLE  = 0
15
+	RUNBINDABLE = 0
14 16
 	PRIVATE     = 0
17
+	RPRIVATE    = 0
18
+	SHARED      = 0
19
+	RSHARED     = 0
20
+	SLAVE       = 0
21
+	RSLAVE      = 0
15 22
 	RBIND       = 0
16 23
 	RELATIME    = 0
17 24
 	RELATIVE    = 0
... ...
@@ -2,7 +2,39 @@
2 2
 
3 3
 package mount
4 4
 
5
+func MakeShared(mountPoint string) error {
6
+	return ensureMountedAs(mountPoint, "shared")
7
+}
8
+
9
+func MakeRShared(mountPoint string) error {
10
+	return ensureMountedAs(mountPoint, "rshared")
11
+}
12
+
5 13
 func MakePrivate(mountPoint string) error {
14
+	return ensureMountedAs(mountPoint, "private")
15
+}
16
+
17
+func MakeRPrivate(mountPoint string) error {
18
+	return ensureMountedAs(mountPoint, "rprivate")
19
+}
20
+
21
+func MakeSlave(mountPoint string) error {
22
+	return ensureMountedAs(mountPoint, "slave")
23
+}
24
+
25
+func MakeRSlave(mountPoint string) error {
26
+	return ensureMountedAs(mountPoint, "rslave")
27
+}
28
+
29
+func MakeUnbindable(mountPoint string) error {
30
+	return ensureMountedAs(mountPoint, "unbindable")
31
+}
32
+
33
+func MakeRUnbindable(mountPoint string) error {
34
+	return ensureMountedAs(mountPoint, "runbindable")
35
+}
36
+
37
+func ensureMountedAs(mountPoint, options string) error {
6 38
 	mounted, err := Mounted(mountPoint)
7 39
 	if err != nil {
8 40
 		return err
... ...
@@ -13,6 +45,10 @@ func MakePrivate(mountPoint string) error {
13 13
 			return err
14 14
 		}
15 15
 	}
16
+	mounted, err = Mounted(mountPoint)
17
+	if err != nil {
18
+		return err
19
+	}
16 20
 
17
-	return ForceMount("", mountPoint, "none", "private")
21
+	return ForceMount("", mountPoint, "none", options)
18 22
 }