Add support for mounts on Darwin

Signed-off-by: Marat Radchenko <marat@slonopotamus.org>
This commit is contained in:
Marat Radchenko
2023-07-09 16:34:12 +03:00
parent 0789790f07
commit 2799b28e61
10 changed files with 200 additions and 171 deletions

View File

@@ -21,7 +21,6 @@ import (
"fmt"
"os"
"path/filepath"
"runtime"
"github.com/containerd/containerd/identifiers"
"github.com/containerd/containerd/mount"
@@ -129,10 +128,8 @@ type Bundle struct {
func (b *Bundle) Delete() error {
work, werr := os.Readlink(filepath.Join(b.Path, "work"))
rootfs := filepath.Join(b.Path, "rootfs")
if runtime.GOOS != "darwin" {
if err := mount.UnmountRecursive(rootfs, 0); err != nil {
return fmt.Errorf("unmount rootfs %s: %w", rootfs, err)
}
if err := mount.UnmountRecursive(rootfs, 0); err != nil {
return fmt.Errorf("unmount rootfs %s: %w", rootfs, err)
}
if err := os.Remove(rootfs); err != nil && !os.IsNotExist(err) {
return fmt.Errorf("failed to remove bundle rootfs: %w", err)