You've already forked runc
mirror of
https://github.com/opencontainers/runc.git
synced 2025-08-05 14:35:47 +03:00
libct/msMoveRoot: benefit from GetMounts filter
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
This commit is contained in:
@@ -805,17 +805,22 @@ func pivotRoot(rootfs string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func msMoveRoot(rootfs string) error {
|
func msMoveRoot(rootfs string) error {
|
||||||
mountinfos, err := mountinfo.GetMounts(nil)
|
mountinfos, err := mountinfo.GetMounts(func(info *mountinfo.Info) (skip, stop bool) {
|
||||||
|
skip = false
|
||||||
|
stop = false
|
||||||
|
// Collect every sysfs and proc file systems, except those under the container rootfs
|
||||||
|
if (info.Fstype != "proc" && info.Fstype != "sysfs") || strings.HasPrefix(info.Mountpoint, rootfs) {
|
||||||
|
skip = true
|
||||||
|
return
|
||||||
|
}
|
||||||
|
return
|
||||||
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, info := range mountinfos {
|
for _, info := range mountinfos {
|
||||||
p := info.Mountpoint
|
p := info.Mountpoint
|
||||||
// Umount every syfs and proc file systems, except those under the container rootfs
|
|
||||||
if (info.Fstype != "proc" && info.Fstype != "sysfs") || filepath.HasPrefix(p, rootfs) {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
// Be sure umount events are not propagated to the host.
|
// Be sure umount events are not propagated to the host.
|
||||||
if err := unix.Mount("", p, "", unix.MS_SLAVE|unix.MS_REC, ""); err != nil {
|
if err := unix.Mount("", p, "", unix.MS_SLAVE|unix.MS_REC, ""); err != nil {
|
||||||
return err
|
return err
|
||||||
|
Reference in New Issue
Block a user