2014-04-11 23:06:56 +08:00
|
|
|
// +build linux
|
|
|
|
|
|
|
|
package mount
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"syscall"
|
|
|
|
)
|
|
|
|
|
|
|
|
func MsMoveRoot(rootfs string) error {
|
2014-07-15 07:55:49 +08:00
|
|
|
if err := syscall.Mount(rootfs, "/", "", syscall.MS_MOVE, ""); err != nil {
|
2014-04-11 23:06:56 +08:00
|
|
|
return fmt.Errorf("mount move %s into / %s", rootfs, err)
|
|
|
|
}
|
2014-07-15 07:55:49 +08:00
|
|
|
|
|
|
|
if err := syscall.Chroot("."); err != nil {
|
2014-04-11 23:06:56 +08:00
|
|
|
return fmt.Errorf("chroot . %s", err)
|
|
|
|
}
|
2014-07-15 07:55:49 +08:00
|
|
|
|
|
|
|
return syscall.Chdir("/")
|
2014-04-11 23:06:56 +08:00
|
|
|
}
|