From 5773dfd84441d636cc66c7ee162b8a013b9c530e Mon Sep 17 00:00:00 2001 From: Justin Cormack Date: Tue, 22 Aug 2017 17:26:16 +0100 Subject: [PATCH] Cleanup cleanup code Only remove main mount at rootfs, as we do not really know about the state of the rest. Signed-off-by: Justin Cormack --- pkg/init/cmd/service/prepare.go | 22 +--------------------- 1 file changed, 1 insertion(+), 21 deletions(-) diff --git a/pkg/init/cmd/service/prepare.go b/pkg/init/cmd/service/prepare.go index 9c72857f4..1981f07e3 100644 --- a/pkg/init/cmd/service/prepare.go +++ b/pkg/init/cmd/service/prepare.go @@ -266,27 +266,7 @@ func prepareProcess(pid int, runtime Runtime) error { // cleanup functions are best efforts only, mainly for rw onboot containers func cleanup(path string) { - // see if we are dealing with a read only or read write container - if _, err := os.Stat(filepath.Join(path, "lower")); err != nil { - cleanupRO(path) - } else { - cleanupRW(path) - } -} - -func cleanupRO(path string) { - // remove the bind mount + // remove the root mount rootfs := filepath.Join(path, "rootfs") _ = unix.Unmount(rootfs, 0) } - -func cleanupRW(path string) { - // remove the overlay mount - rootfs := filepath.Join(path, "rootfs") - _ = os.RemoveAll(rootfs) - _ = unix.Unmount(rootfs, 0) - // remove the tmpfs - tmp := filepath.Join(path, "tmp") - _ = os.RemoveAll(tmp) - _ = unix.Unmount(tmp, 0) -}