mount.go 829 B

12345678910111213141516171819202122232425262728
  1. //go:build windows
  2. package computestorage
  3. import (
  4. "context"
  5. "github.com/Microsoft/hcsshim/internal/interop"
  6. "github.com/Microsoft/hcsshim/internal/oc"
  7. "github.com/pkg/errors"
  8. "golang.org/x/sys/windows"
  9. )
  10. // GetLayerVhdMountPath returns the volume path for a virtual disk of a writable container layer.
  11. func GetLayerVhdMountPath(ctx context.Context, vhdHandle windows.Handle) (path string, err error) {
  12. title := "hcsshim::GetLayerVhdMountPath"
  13. ctx, span := oc.StartSpan(ctx, title) //nolint:ineffassign,staticcheck
  14. defer span.End()
  15. defer func() { oc.SetSpanStatus(span, err) }()
  16. var mountPath *uint16
  17. err = hcsGetLayerVhdMountPath(vhdHandle, &mountPath)
  18. if err != nil {
  19. return "", errors.Wrap(err, "failed to get vhd mount path")
  20. }
  21. path = interop.ConvertAndFreeCoTaskMemString(mountPath)
  22. return path, nil
  23. }