mirror of
https://github.com/opencontainers/runc.git
synced 2026-07-12 09:46:25 +08:00
e9ec77ab34
Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@docker.com> (github: crosbymichael)
21 lines
360 B
Go
21 lines
360 B
Go
// +build linux
|
|
|
|
package mount
|
|
|
|
import (
|
|
"fmt"
|
|
"syscall"
|
|
)
|
|
|
|
func MsMoveRoot(rootfs string) error {
|
|
if err := syscall.Mount(rootfs, "/", "", syscall.MS_MOVE, ""); err != nil {
|
|
return fmt.Errorf("mount move %s into / %s", rootfs, err)
|
|
}
|
|
|
|
if err := syscall.Chroot("."); err != nil {
|
|
return fmt.Errorf("chroot . %s", err)
|
|
}
|
|
|
|
return syscall.Chdir("/")
|
|
}
|