Signed-off-by: Vincent Batts <vbatts@redhat.com>
Vincent Batts authored on 2014/10/31 23:18:41... | ... |
@@ -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}, |
... | ... |
@@ -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 |
) |
... | ... |
@@ -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 |
} |