...
1
2
3 package wclayer
4
5 import (
6 "context"
7 "syscall"
8
9 "github.com/Microsoft/hcsshim/internal/hcserror"
10 "github.com/Microsoft/hcsshim/internal/log"
11 "github.com/Microsoft/hcsshim/internal/oc"
12 "go.opencensus.io/trace"
13 )
14
15
16
17
18
19 func GetLayerMountPath(ctx context.Context, path string) (_ string, err error) {
20 title := "hcsshim::GetLayerMountPath"
21 ctx, span := oc.StartSpan(ctx, title)
22 defer span.End()
23 defer func() { oc.SetSpanStatus(span, err) }()
24 span.AddAttributes(trace.StringAttribute("path", path))
25
26 var mountPathLength uintptr = 0
27
28
29 log.G(ctx).Debug("Calling proc (1)")
30 err = getLayerMountPath(&stdDriverInfo, path, &mountPathLength, nil)
31 if err != nil {
32 return "", hcserror.New(err, title, "(first call)")
33 }
34
35
36 if mountPathLength == 0 {
37 return "", nil
38 }
39 mountPathp := make([]uint16, mountPathLength)
40 mountPathp[0] = 0
41
42
43 log.G(ctx).Debug("Calling proc (2)")
44 err = getLayerMountPath(&stdDriverInfo, path, &mountPathLength, &mountPathp[0])
45 if err != nil {
46 return "", hcserror.New(err, title, "(second call)")
47 }
48
49 mountPath := syscall.UTF16ToString(mountPathp[0:])
50 span.AddAttributes(trace.StringAttribute("mountPath", mountPath))
51 return mountPath, nil
52 }
53
View as plain text