Skip to content

Commit 9dca2db

Browse files
committed
Handle windows-layer mounts somewhat like bind-mounts
windows-layer mounts (the only mount type supported by Windows) do not currently use the `target` parameter to `mount.All`. So instead, we treat them like bind-mounts and access the activated layer in-place. Unlike the bind-mounts, we still need to Mount and Unmount the layer. Since we don't own the directory, we must not delete it after we unmount it. Signed-off-by: Paul "TBBle" Hampson <[email protected]>
1 parent c378a7d commit 9dca2db

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

snapshot/localmounter.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,16 @@ func (lm *localMounter) Mount() (string, error) {
4747
lm.release = release
4848
}
4949

50+
// Windows mounts don't use the target parameter of mount.All, they activate in-place.
51+
if len(lm.mounts) == 1 && lm.mounts[0].Type == "windows-layer" {
52+
// TODO: How to handle read-only? A local copy would be awfully inefficient.
53+
if err := mount.All(lm.mounts, ""); err != nil {
54+
return "", errors.Wrapf(err, "failed to mount in-place: %+v", lm.mounts)
55+
}
56+
lm.target = lm.mounts[0].Source
57+
return lm.mounts[0].Source, nil
58+
}
59+
5060
if len(lm.mounts) == 1 && (lm.mounts[0].Type == "bind" || lm.mounts[0].Type == "rbind") {
5161
ro := false
5262
for _, opt := range lm.mounts[0].Options {

snapshot/localmounter_windows.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
package snapshot
22

33
import (
4-
"os"
5-
64
"github.com/containerd/containerd/mount"
75
)
86

@@ -14,7 +12,6 @@ func (lm *localMounter) Unmount() error {
1412
if err := mount.Unmount(lm.target, 0); err != nil {
1513
return err
1614
}
17-
os.RemoveAll(lm.target)
1815
lm.target = ""
1916
}
2017

0 commit comments

Comments
 (0)