diff --git a/diff/windows/windows.go b/diff/windows/windows.go index 0778ccf82..2cfdfd71a 100644 --- a/diff/windows/windows.go +++ b/diff/windows/windows.go @@ -321,12 +321,10 @@ func mountsToLayerAndParents(mounts []mount.Mount) (string, []string, error) { } mnt := mounts[0] - if mnt.Type != "windows-layer" && mnt.Type != "bind" { + if mnt.Type != "windows-layer" { // This is a special case error. When this is received the diff service // will attempt the next differ in the chain which for Windows is the // lcow differ that we want. - // TODO: Is there any situation where we actually wanted a "bind" mount to - // fall through to the lcow differ? return "", nil, fmt.Errorf("windowsDiff does not support layer type %s: %w", mnt.Type, errdefs.ErrNotImplemented) } @@ -336,21 +334,16 @@ func mountsToLayerAndParents(mounts []mount.Mount) (string, []string, error) { } if mnt.ReadOnly() { - if mnt.Type == "bind" && len(parentLayerPaths) != 0 { - return "", nil, fmt.Errorf("unexpected bind-mount View with parents: %w", errdefs.ErrInvalidArgument) - } else if mnt.Type == "bind" { + if len(parentLayerPaths) == 0 { // rootfs.CreateDiff creates a new, empty View to diff against, // when diffing something with no parent. // This makes perfect sense for a walking Diff, but for WCOW, // we have to recognise this as "diff against nothing" return "", nil, nil - } else if len(parentLayerPaths) == 0 { - return "", nil, fmt.Errorf("unexpected windows-layer View with no parent: %w", errdefs.ErrInvalidArgument) } // Ignore the dummy sandbox. return parentLayerPaths[0], parentLayerPaths[1:], nil } - return mnt.Source, parentLayerPaths, nil } @@ -367,7 +360,7 @@ func mountPairToLayerStack(lower, upper []mount.Mount) ([]string, error) { lowerLayer, lowerParentLayerPaths, err := mountsToLayerAndParents(lower) if errdefs.IsNotImplemented(err) { - // Upper was a windows-layer or bind, lower is not. We can't handle that. + // Upper was a windows-layer, lower is not. We can't handle that. return nil, fmt.Errorf("windowsDiff cannot diff a windows-layer against a non-windows-layer: %w", errdefs.ErrInvalidArgument) } else if err != nil { return nil, fmt.Errorf("Lower mount invalid: %w", err) diff --git a/mount/mount_windows.go b/mount/mount_windows.go index 3ef7a3872..7e527c8df 100644 --- a/mount/mount_windows.go +++ b/mount/mount_windows.go @@ -148,6 +148,14 @@ func (m *Mount) GetParentPaths() ([]string, error) { // Unmount the mount at the provided path func Unmount(mount string, flags int) error { + if _, err := os.Stat(mount); err != nil { + if os.IsNotExist(err) { + return nil + } + + return fmt.Errorf("failed to access mount point %s: %w", mount, err) + } + mount = filepath.Clean(mount) adsFile := mount + ":" + sourceStreamName var layerPath string diff --git a/snapshots/windows/windows.go b/snapshots/windows/windows.go index eca46dfe8..4b89afe44 100644 --- a/snapshots/windows/windows.go +++ b/snapshots/windows/windows.go @@ -370,8 +370,8 @@ func (s *snapshotter) createSnapshot(ctx context.Context, kind snapshots.Kind, k } if len(newSnapshot.ParentIDs) == 0 { - // A parentless snapshot is just a bind-mount to a directory named - // "Files". When committed, there'll be some post-processing to fill in the rest + // A parentless snapshot a new base layer. Valid base layers must have a "Files" folder. + // When committed, there'll be some post-processing to fill in the rest // of the metadata. filesDir := filepath.Join(snDir, "Files") if err := os.MkdirAll(filesDir, 0700); err != nil {