From 4e69b504690d4861812911cb74098967c07363b8 Mon Sep 17 00:00:00 2001 From: "Paul \"TBBle\" Hampson" Date: Thu, 23 Jul 2020 23:04:24 +1000 Subject: [PATCH] Shortcut read-only bind-mounts in Windows, like non-Windows Signed-off-by: Paul "TBBle" Hampson --- snapshot/localmounter_windows.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/snapshot/localmounter_windows.go b/snapshot/localmounter_windows.go index a5cd1a25..6b6db4ec 100644 --- a/snapshot/localmounter_windows.go +++ b/snapshot/localmounter_windows.go @@ -25,6 +25,19 @@ func (lm *localMounter) Mount() (string, error) { return "", errors.Wrapf(errdefs.ErrNotImplemented, "request to mount %d layers, only 1 is supported", len(lm.mounts)) } + if lm.mounts[0].Type == "bind" || lm.mounts[0].Type == "rbind" { + ro := false + for _, opt := range lm.mounts[0].Options { + if opt == "ro" { + ro = true + break + } + } + if !ro { + return lm.mounts[0].Source, nil + } + } + // Windows mounts always activate in-place, so the target of the mount must be the source directory. // See https://github.com/containerd/containerd/pull/2366 dir := lm.mounts[0].Source