The only option we supply is either BIND or a mount propagation flag,
so it makes sense to specify the flag value directly, rather than using
parseOptions() every time.
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
| ... | ... |
@@ -3,49 +3,49 @@ package mount // import "github.com/docker/docker/pkg/mount" |
| 3 | 3 |
// MakeShared ensures a mounted filesystem has the SHARED mount option enabled. |
| 4 | 4 |
// See the supported options in flags.go for further reference. |
| 5 | 5 |
func MakeShared(mountPoint string) error {
|
| 6 |
- return ensureMountedAs(mountPoint, "shared") |
|
| 6 |
+ return ensureMountedAs(mountPoint, SHARED) |
|
| 7 | 7 |
} |
| 8 | 8 |
|
| 9 | 9 |
// MakeRShared ensures a mounted filesystem has the RSHARED mount option enabled. |
| 10 | 10 |
// See the supported options in flags.go for further reference. |
| 11 | 11 |
func MakeRShared(mountPoint string) error {
|
| 12 |
- return ensureMountedAs(mountPoint, "rshared") |
|
| 12 |
+ return ensureMountedAs(mountPoint, RSHARED) |
|
| 13 | 13 |
} |
| 14 | 14 |
|
| 15 | 15 |
// MakePrivate ensures a mounted filesystem has the PRIVATE mount option enabled. |
| 16 | 16 |
// See the supported options in flags.go for further reference. |
| 17 | 17 |
func MakePrivate(mountPoint string) error {
|
| 18 |
- return ensureMountedAs(mountPoint, "private") |
|
| 18 |
+ return ensureMountedAs(mountPoint, PRIVATE) |
|
| 19 | 19 |
} |
| 20 | 20 |
|
| 21 | 21 |
// MakeRPrivate ensures a mounted filesystem has the RPRIVATE mount option |
| 22 | 22 |
// enabled. See the supported options in flags.go for further reference. |
| 23 | 23 |
func MakeRPrivate(mountPoint string) error {
|
| 24 |
- return ensureMountedAs(mountPoint, "rprivate") |
|
| 24 |
+ return ensureMountedAs(mountPoint, RPRIVATE) |
|
| 25 | 25 |
} |
| 26 | 26 |
|
| 27 | 27 |
// MakeSlave ensures a mounted filesystem has the SLAVE mount option enabled. |
| 28 | 28 |
// See the supported options in flags.go for further reference. |
| 29 | 29 |
func MakeSlave(mountPoint string) error {
|
| 30 |
- return ensureMountedAs(mountPoint, "slave") |
|
| 30 |
+ return ensureMountedAs(mountPoint, SLAVE) |
|
| 31 | 31 |
} |
| 32 | 32 |
|
| 33 | 33 |
// MakeRSlave ensures a mounted filesystem has the RSLAVE mount option enabled. |
| 34 | 34 |
// See the supported options in flags.go for further reference. |
| 35 | 35 |
func MakeRSlave(mountPoint string) error {
|
| 36 |
- return ensureMountedAs(mountPoint, "rslave") |
|
| 36 |
+ return ensureMountedAs(mountPoint, RSLAVE) |
|
| 37 | 37 |
} |
| 38 | 38 |
|
| 39 | 39 |
// MakeUnbindable ensures a mounted filesystem has the UNBINDABLE mount option |
| 40 | 40 |
// enabled. See the supported options in flags.go for further reference. |
| 41 | 41 |
func MakeUnbindable(mountPoint string) error {
|
| 42 |
- return ensureMountedAs(mountPoint, "unbindable") |
|
| 42 |
+ return ensureMountedAs(mountPoint, UNBINDABLE) |
|
| 43 | 43 |
} |
| 44 | 44 |
|
| 45 | 45 |
// MakeRUnbindable ensures a mounted filesystem has the RUNBINDABLE mount |
| 46 | 46 |
// option enabled. See the supported options in flags.go for further reference. |
| 47 | 47 |
func MakeRUnbindable(mountPoint string) error {
|
| 48 |
- return ensureMountedAs(mountPoint, "runbindable") |
|
| 48 |
+ return ensureMountedAs(mountPoint, RUNBINDABLE) |
|
| 49 | 49 |
} |
| 50 | 50 |
|
| 51 | 51 |
// MakeMount ensures that the file or directory given is a mount point, |
| ... | ... |
@@ -59,13 +59,13 @@ func MakeMount(mnt string) error {
|
| 59 | 59 |
return nil |
| 60 | 60 |
} |
| 61 | 61 |
|
| 62 |
- return ForceMount(mnt, mnt, "none", "bind") |
|
| 62 |
+ return mount(mnt, mnt, "none", uintptr(BIND), "") |
|
| 63 | 63 |
} |
| 64 | 64 |
|
| 65 |
-func ensureMountedAs(mountPoint, options string) error {
|
|
| 66 |
- if err := MakeMount(mountPoint); err != nil {
|
|
| 65 |
+func ensureMountedAs(mnt string, flags int) error {
|
|
| 66 |
+ if err := MakeMount(mnt); err != nil {
|
|
| 67 | 67 |
return err |
| 68 | 68 |
} |
| 69 | 69 |
|
| 70 |
- return ForceMount("", mountPoint, "none", options)
|
|
| 70 |
+ return mount("", mnt, "none", uintptr(flags), "")
|
|
| 71 | 71 |
} |