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 <justin.cormack@docker.com>
This commit is contained in:
Justin Cormack 2017-08-22 17:26:16 +01:00
parent 49cf74f4f6
commit 5773dfd844

View File

@ -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)
}