Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: wcow: add support for bind and cache mounts #5708

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions executor/oci/spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,8 @@ func GenerateSpec(ctx context.Context, meta executor.Meta, mounts []executor.Mou
return nil, nil, err
}
s.Mounts = append(s.Mounts, specs.Mount{
Destination: m.Dest,
Type: mount.Type,
Destination: getAbsPath(m.Dest), // for Windows only
Type: getMountType(mount.Type),
Source: mount.Source,
Options: mount.Options,
})
Expand Down Expand Up @@ -243,6 +243,10 @@ type submounts struct {

func (s *submounts) subMount(m mount.Mount, subPath string) (mount.Mount, error) {
if path.Join("/", subPath) == "/" {
// for Windows, the mounting by HCS doesn't go through
// WCIFS, hence we have to give the direct path of the
// mount, which is in the /Files subdirectory.
m.Source = getCompleteSourcePath(m.Source)
return m, nil
}
if s.m == nil {
Expand Down
18 changes: 18 additions & 0 deletions executor/oci/spec_unix.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//go:build !windows

package oci

// no effect for non-Windows
func getMountType(mType string) string {
return mType
}

// no effect for non-Windows
func getAbsPath(p string) string {
return p
}

// no effect for non-Windows
func getCompleteSourcePath(p string) string {
return p
}
22 changes: 22 additions & 0 deletions executor/oci/spec_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,3 +110,25 @@ func sub(m mount.Mount, subPath string) (mount.Mount, func() error, error) {
m.Source = src
return m, func() error { return nil }, nil
}

func getMountType(_ string) string {
// HCS shim doesn't expect a named type
// for the mount.
return ""
}

// Returns an absolute path, starting with the
// default drive letter (C:). HCS Shim expects an absolute path.
func getAbsPath(p string) string {
// We can just prepend drive-letter (C:),
// since at this point, the path has already
// gone through filepath.Clean()
return filepath.Join("C:\\", p)
}

// For Windows, the mounting by HCS doesn't go through
// WCIFS, hence we have to give the direct path of the
// mount, which is in the /Files subdirectory.
func getCompleteSourcePath(p string) string {
return filepath.Join(p, "Files")
}
Loading