mirror of
https://github.com/linuxkit/linuxkit.git
synced 2025-07-20 01:29:07 +00:00
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:
parent
49cf74f4f6
commit
5773dfd844
@ -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)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user