2014-10-30 17:04:56 -04:00
|
|
|
// +build linux
|
|
|
|
|
|
|
|
package mount
|
|
|
|
|
2014-10-31 10:18:41 -04:00
|
|
|
func MakeShared(mountPoint string) error {
|
|
|
|
return ensureMountedAs(mountPoint, "shared")
|
|
|
|
}
|
|
|
|
|
|
|
|
func MakeRShared(mountPoint string) error {
|
|
|
|
return ensureMountedAs(mountPoint, "rshared")
|
|
|
|
}
|
|
|
|
|
2014-10-30 17:04:56 -04:00
|
|
|
func MakePrivate(mountPoint string) error {
|
2014-10-31 10:18:41 -04:00
|
|
|
return ensureMountedAs(mountPoint, "private")
|
|
|
|
}
|
|
|
|
|
|
|
|
func MakeRPrivate(mountPoint string) error {
|
|
|
|
return ensureMountedAs(mountPoint, "rprivate")
|
|
|
|
}
|
|
|
|
|
|
|
|
func MakeSlave(mountPoint string) error {
|
|
|
|
return ensureMountedAs(mountPoint, "slave")
|
|
|
|
}
|
|
|
|
|
|
|
|
func MakeRSlave(mountPoint string) error {
|
|
|
|
return ensureMountedAs(mountPoint, "rslave")
|
|
|
|
}
|
|
|
|
|
|
|
|
func MakeUnbindable(mountPoint string) error {
|
|
|
|
return ensureMountedAs(mountPoint, "unbindable")
|
|
|
|
}
|
|
|
|
|
|
|
|
func MakeRUnbindable(mountPoint string) error {
|
|
|
|
return ensureMountedAs(mountPoint, "runbindable")
|
|
|
|
}
|
|
|
|
|
|
|
|
func ensureMountedAs(mountPoint, options string) error {
|
2014-10-30 17:04:56 -04:00
|
|
|
mounted, err := Mounted(mountPoint)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
if !mounted {
|
|
|
|
if err := Mount(mountPoint, mountPoint, "none", "bind,rw"); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
2014-10-31 10:18:41 -04:00
|
|
|
mounted, err = Mounted(mountPoint)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2014-10-30 17:04:56 -04:00
|
|
|
|
2014-10-31 10:18:41 -04:00
|
|
|
return ForceMount("", mountPoint, "none", options)
|
2014-10-30 17:04:56 -04:00
|
|
|
}
|