Browse code

Remove case sensitive duplicate dir in vendor

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>

Tonis Tiigi authored on 2016/02/04 05:56:01
Showing 62 changed files
... ...
@@ -5,9 +5,9 @@ package windows
5 5
 import (
6 6
 	"fmt"
7 7
 
8
+	"github.com/Microsoft/hcsshim"
8 9
 	"github.com/Sirupsen/logrus"
9 10
 	"github.com/docker/docker/daemon/execdriver"
10
-	"github.com/microsoft/hcsshim"
11 11
 )
12 12
 
13 13
 // Exec implements the exec driver Driver interface.
... ...
@@ -11,9 +11,9 @@ import (
11 11
 	"strings"
12 12
 	"time"
13 13
 
14
+	"github.com/Microsoft/hcsshim"
14 15
 	"github.com/Sirupsen/logrus"
15 16
 	"github.com/docker/docker/daemon/execdriver"
16
-	"github.com/microsoft/hcsshim"
17 17
 )
18 18
 
19 19
 // defaultContainerNAT is the default name of the container NAT device that is
... ...
@@ -6,9 +6,9 @@ import (
6 6
 	"fmt"
7 7
 	"syscall"
8 8
 
9
+	"github.com/Microsoft/hcsshim"
9 10
 	"github.com/Sirupsen/logrus"
10 11
 	"github.com/docker/docker/daemon/execdriver"
11
-	"github.com/microsoft/hcsshim"
12 12
 )
13 13
 
14 14
 // Terminate implements the exec driver Driver interface.
... ...
@@ -3,7 +3,7 @@
3 3
 package windows
4 4
 
5 5
 import (
6
-	"github.com/microsoft/hcsshim"
6
+	"github.com/Microsoft/hcsshim"
7 7
 )
8 8
 
9 9
 // TtyConsole implements the exec driver Terminal interface.
... ...
@@ -15,6 +15,7 @@ import (
15 15
 	"sync"
16 16
 	"time"
17 17
 
18
+	"github.com/Microsoft/hcsshim"
18 19
 	"github.com/Sirupsen/logrus"
19 20
 	"github.com/docker/docker/daemon/graphdriver"
20 21
 	"github.com/docker/docker/pkg/archive"
... ...
@@ -22,7 +23,6 @@ import (
22 22
 	"github.com/docker/docker/pkg/idtools"
23 23
 	"github.com/docker/docker/pkg/ioutils"
24 24
 	"github.com/docker/docker/pkg/random"
25
-	"github.com/microsoft/hcsshim"
26 25
 )
27 26
 
28 27
 // init registers the windows graph drivers to the register.
... ...
@@ -16,7 +16,7 @@ clone git github.com/gorilla/mux e444e69cbd
16 16
 clone git github.com/kr/pty 5cf931ef8f
17 17
 clone git github.com/mattn/go-shellwords v1.0.0
18 18
 clone git github.com/mattn/go-sqlite3 v1.1.0
19
-clone git github.com/microsoft/hcsshim 35ad4d808a97203cb1748d7c43167e91f51e7f86
19
+clone git github.com/Microsoft/hcsshim 35ad4d808a97203cb1748d7c43167e91f51e7f86
20 20
 clone git github.com/mistifyio/go-zfs v2.1.1
21 21
 clone git github.com/tchap/go-patricia v2.1.0
22 22
 clone git github.com/vdemeester/shakers 3c10293ce22b900c27acad7b28656196fcc2f73b
23 23
new file mode 100644
... ...
@@ -0,0 +1,22 @@
0
+The MIT License (MIT)
1
+
2
+Copyright (c) 2015 Microsoft
3
+
4
+Permission is hereby granted, free of charge, to any person obtaining a copy
5
+of this software and associated documentation files (the "Software"), to deal
6
+in the Software without restriction, including without limitation the rights
7
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+copies of the Software, and to permit persons to whom the Software is
9
+furnished to do so, subject to the following conditions:
10
+
11
+The above copyright notice and this permission notice shall be included in all
12
+copies or substantial portions of the Software.
13
+
14
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+SOFTWARE.
21
+
0 22
new file mode 100644
... ...
@@ -0,0 +1,28 @@
0
+package hcsshim
1
+
2
+import "github.com/Sirupsen/logrus"
3
+
4
+// ActivateLayer will find the layer with the given id and mount it's filesystem.
5
+// For a read/write layer, the mounted filesystem will appear as a volume on the
6
+// host, while a read-only layer is generally expected to be a no-op.
7
+// An activated layer must later be deactivated via DeactivateLayer.
8
+func ActivateLayer(info DriverInfo, id string) error {
9
+	title := "hcsshim::ActivateLayer "
10
+	logrus.Debugf(title+"Flavour %d ID %s", info.Flavour, id)
11
+
12
+	infop, err := convertDriverInfo(info)
13
+	if err != nil {
14
+		logrus.Error(err)
15
+		return err
16
+	}
17
+
18
+	err = activateLayer(&infop, id)
19
+	if err != nil {
20
+		err = makeErrorf(err, title, "id=%s flavour=%d", id, info.Flavour)
21
+		logrus.Error(err)
22
+		return err
23
+	}
24
+
25
+	logrus.Debugf(title+" - succeeded id=%s flavour=%d", id, info.Flavour)
26
+	return nil
27
+}
0 28
new file mode 100644
... ...
@@ -0,0 +1,34 @@
0
+package hcsshim
1
+
2
+import "github.com/Sirupsen/logrus"
3
+
4
+// CopyLayer performs a commit of the srcId (which is expected to be a read-write
5
+// layer) into a new read-only layer at dstId.  This requires the full list of
6
+// on-disk paths to parent layers, provided in parentLayerPaths, in order to
7
+// complete the commit.
8
+func CopyLayer(info DriverInfo, srcId, dstId string, parentLayerPaths []string) error {
9
+	title := "hcsshim::CopyLayer "
10
+	logrus.Debugf(title+"srcId %s dstId", srcId, dstId)
11
+
12
+	// Generate layer descriptors
13
+	layers, err := layerPathsToDescriptors(parentLayerPaths)
14
+	if err != nil {
15
+		return err
16
+	}
17
+
18
+	// Convert info to API calling convention
19
+	infop, err := convertDriverInfo(info)
20
+	if err != nil {
21
+		return err
22
+	}
23
+
24
+	err = copyLayer(&infop, srcId, dstId, layers)
25
+	if err != nil {
26
+		err = makeErrorf(err, title, "srcId=%s dstId=%d", srcId, dstId)
27
+		logrus.Error(err)
28
+		return err
29
+	}
30
+
31
+	logrus.Debugf(title+" - succeeded srcId=%s dstId=%s", srcId, dstId)
32
+	return nil
33
+}
0 34
new file mode 100644
... ...
@@ -0,0 +1,22 @@
0
+package hcsshim
1
+
2
+import "github.com/Sirupsen/logrus"
3
+
4
+// CreateComputeSystem creates a container, initializing its configuration in
5
+// the Host Compute Service such that it can be started by a call to the
6
+// StartComputeSystem method.
7
+func CreateComputeSystem(id string, configuration string) error {
8
+
9
+	title := "HCSShim::CreateComputeSystem"
10
+	logrus.Debugln(title+" id=%s, configuration=%s", id, configuration)
11
+
12
+	err := createComputeSystem(id, configuration)
13
+	if err != nil {
14
+		err = makeErrorf(err, title, "id=%s configuration=%s", id, configuration)
15
+		logrus.Error(err)
16
+		return err
17
+	}
18
+
19
+	logrus.Debugf(title+"- succeeded %s", id)
20
+	return nil
21
+}
0 22
new file mode 100644
... ...
@@ -0,0 +1,27 @@
0
+package hcsshim
1
+
2
+import "github.com/Sirupsen/logrus"
3
+
4
+// CreateLayer creates a new, empty, read-only layer on the filesystem based on
5
+// the parent layer provided.
6
+func CreateLayer(info DriverInfo, id, parent string) error {
7
+	title := "hcsshim::CreateLayer "
8
+	logrus.Debugf(title+"Flavour %d ID %s parent %s", info.Flavour, id, parent)
9
+
10
+	// Convert info to API calling convention
11
+	infop, err := convertDriverInfo(info)
12
+	if err != nil {
13
+		logrus.Error(err)
14
+		return err
15
+	}
16
+
17
+	err = createLayer(&infop, id, parent)
18
+	if err != nil {
19
+		err = makeErrorf(err, title, "id=%s parent=%s flavour=%d", id, parent, info.Flavour)
20
+		logrus.Error(err)
21
+		return err
22
+	}
23
+
24
+	logrus.Debugf(title+" - succeeded id=%s parent=%s flavour=%d", id, parent, info.Flavour)
25
+	return nil
26
+}
0 27
new file mode 100644
... ...
@@ -0,0 +1,103 @@
0
+package hcsshim
1
+
2
+import (
3
+	"encoding/json"
4
+	"io"
5
+	"syscall"
6
+
7
+	"github.com/Microsoft/go-winio"
8
+	"github.com/Sirupsen/logrus"
9
+)
10
+
11
+// CreateProcessParams is used as both the input of CreateProcessInComputeSystem
12
+// and to convert the parameters to JSON for passing onto the HCS
13
+type CreateProcessParams struct {
14
+	ApplicationName  string
15
+	CommandLine      string
16
+	WorkingDirectory string
17
+	Environment      map[string]string
18
+	EmulateConsole   bool
19
+	ConsoleSize      [2]int
20
+}
21
+
22
+// makeOpenFiles calls winio.MakeOpenFile for each handle in a slice but closes all the handles
23
+// if there is an error.
24
+func makeOpenFiles(hs []syscall.Handle) (_ []io.ReadWriteCloser, err error) {
25
+	fs := make([]io.ReadWriteCloser, len(hs))
26
+	for i, h := range hs {
27
+		if h != syscall.Handle(0) {
28
+			if err == nil {
29
+				fs[i], err = winio.MakeOpenFile(h)
30
+			}
31
+			if err != nil {
32
+				syscall.Close(h)
33
+			}
34
+		}
35
+	}
36
+	if err != nil {
37
+		for _, f := range fs {
38
+			if f != nil {
39
+				f.Close()
40
+			}
41
+		}
42
+		return nil, err
43
+	}
44
+	return fs, nil
45
+}
46
+
47
+// CreateProcessInComputeSystem starts a process in a container. This is invoked, for example,
48
+// as a result of docker run, docker exec, or RUN in Dockerfile. If successful,
49
+// it returns the PID of the process.
50
+func CreateProcessInComputeSystem(id string, useStdin bool, useStdout bool, useStderr bool, params CreateProcessParams) (_ uint32, _ io.WriteCloser, _ io.ReadCloser, _ io.ReadCloser, hr uint32, err error) {
51
+	title := "HCSShim::CreateProcessInComputeSystem"
52
+	logrus.Debugf(title+" id=%s", id)
53
+	hr = 0xFFFFFFFF
54
+
55
+	// If we are not emulating a console, ignore any console size passed to us
56
+	if !params.EmulateConsole {
57
+		params.ConsoleSize[0] = 0
58
+		params.ConsoleSize[1] = 0
59
+	}
60
+
61
+	paramsJson, err := json.Marshal(params)
62
+	if err != nil {
63
+		return
64
+	}
65
+
66
+	logrus.Debugf(title+" - Calling Win32 %s %s", id, paramsJson)
67
+
68
+	var pid uint32
69
+
70
+	handles := make([]syscall.Handle, 3)
71
+	var stdinParam, stdoutParam, stderrParam *syscall.Handle
72
+	if useStdin {
73
+		stdinParam = &handles[0]
74
+	}
75
+	if useStdout {
76
+		stdoutParam = &handles[1]
77
+	}
78
+	if useStderr {
79
+		stderrParam = &handles[2]
80
+	}
81
+
82
+	err = createProcessWithStdHandlesInComputeSystem(id, string(paramsJson), &pid, stdinParam, stdoutParam, stderrParam)
83
+	if err != nil {
84
+		winerr := makeErrorf(err, title, "id=%s params=%v", id, params)
85
+		hr = winerr.HResult()
86
+		// Windows TP4: Hyper-V Containers may return this error with more than one
87
+		// concurrent exec. Do not log it as an error
88
+		if hr != Win32InvalidArgument {
89
+			logrus.Error(winerr)
90
+		}
91
+		err = winerr
92
+		return
93
+	}
94
+
95
+	pipes, err := makeOpenFiles(handles)
96
+	if err != nil {
97
+		return
98
+	}
99
+
100
+	logrus.Debugf(title+" - succeeded id=%s params=%s pid=%d", id, paramsJson, pid)
101
+	return pid, pipes[0], pipes[1], pipes[2], 0, nil
102
+}
0 103
new file mode 100644
... ...
@@ -0,0 +1,35 @@
0
+package hcsshim
1
+
2
+import "github.com/Sirupsen/logrus"
3
+
4
+// CreateSandboxLayer creates and populates new read-write layer for use by a container.
5
+// This requires both the id of the direct parent layer, as well as the full list
6
+// of paths to all parent layers up to the base (and including the direct parent
7
+// whose id was provided).
8
+func CreateSandboxLayer(info DriverInfo, layerId, parentId string, parentLayerPaths []string) error {
9
+	title := "hcsshim::CreateSandboxLayer "
10
+	logrus.Debugf(title+"layerId %s parentId %s", layerId, parentId)
11
+
12
+	// Generate layer descriptors
13
+	layers, err := layerPathsToDescriptors(parentLayerPaths)
14
+	if err != nil {
15
+		return err
16
+	}
17
+
18
+	// Convert info to API calling convention
19
+	infop, err := convertDriverInfo(info)
20
+	if err != nil {
21
+		logrus.Error(err)
22
+		return err
23
+	}
24
+
25
+	err = createSandboxLayer(&infop, layerId, parentId, layers)
26
+	if err != nil {
27
+		err = makeErrorf(err, title, "layerId=%s parentId=%s", layerId, parentId)
28
+		logrus.Error(err)
29
+		return err
30
+	}
31
+
32
+	logrus.Debugf(title+"- succeeded layerId=%s parentId=%s", layerId, parentId)
33
+	return nil
34
+}
0 35
new file mode 100644
... ...
@@ -0,0 +1,26 @@
0
+package hcsshim
1
+
2
+import "github.com/Sirupsen/logrus"
3
+
4
+// DeactivateLayer will dismount a layer that was mounted via ActivateLayer.
5
+func DeactivateLayer(info DriverInfo, id string) error {
6
+	title := "hcsshim::DeactivateLayer "
7
+	logrus.Debugf(title+"Flavour %d ID %s", info.Flavour, id)
8
+
9
+	// Convert info to API calling convention
10
+	infop, err := convertDriverInfo(info)
11
+	if err != nil {
12
+		logrus.Error(err)
13
+		return err
14
+	}
15
+
16
+	err = deactivateLayer(&infop, id)
17
+	if err != nil {
18
+		err = makeErrorf(err, title, "id=%s flavour=%d", id, info.Flavour)
19
+		logrus.Error(err)
20
+		return err
21
+	}
22
+
23
+	logrus.Debugf(title+"succeeded flavour=%d id=%s", info.Flavour, id)
24
+	return nil
25
+}
0 26
new file mode 100644
... ...
@@ -0,0 +1,27 @@
0
+package hcsshim
1
+
2
+import "github.com/Sirupsen/logrus"
3
+
4
+// DestroyLayer will remove the on-disk files representing the layer with the given
5
+// id, including that layer's containing folder, if any.
6
+func DestroyLayer(info DriverInfo, id string) error {
7
+	title := "hcsshim::DestroyLayer "
8
+	logrus.Debugf(title+"Flavour %d ID %s", info.Flavour, id)
9
+
10
+	// Convert info to API calling convention
11
+	infop, err := convertDriverInfo(info)
12
+	if err != nil {
13
+		logrus.Error(err)
14
+		return err
15
+	}
16
+
17
+	err = destroyLayer(&infop, id)
18
+	if err != nil {
19
+		err = makeErrorf(err, title, "id=%s flavour=%d", id, info.Flavour)
20
+		logrus.Error(err)
21
+		return err
22
+	}
23
+
24
+	logrus.Debugf(title+"succeeded flavour=%d id=%s", info.Flavour, id)
25
+	return nil
26
+}
0 27
new file mode 100644
... ...
@@ -0,0 +1,36 @@
0
+package hcsshim
1
+
2
+import "github.com/Sirupsen/logrus"
3
+
4
+// ExportLayer will create a folder at exportFolderPath and fill that folder with
5
+// the transport format version of the layer identified by layerId. This transport
6
+// format includes any metadata required for later importing the layer (using
7
+// ImportLayer), and requires the full list of parent layer paths in order to
8
+// perform the export.
9
+func ExportLayer(info DriverInfo, layerId string, exportFolderPath string, parentLayerPaths []string) error {
10
+	title := "hcsshim::ExportLayer "
11
+	logrus.Debugf(title+"flavour %d layerId %s folder %s", info.Flavour, layerId, exportFolderPath)
12
+
13
+	// Generate layer descriptors
14
+	layers, err := layerPathsToDescriptors(parentLayerPaths)
15
+	if err != nil {
16
+		return err
17
+	}
18
+
19
+	// Convert info to API calling convention
20
+	infop, err := convertDriverInfo(info)
21
+	if err != nil {
22
+		logrus.Error(err)
23
+		return err
24
+	}
25
+
26
+	err = exportLayer(&infop, layerId, exportFolderPath, layers)
27
+	if err != nil {
28
+		err = makeErrorf(err, title, "layerId=%s flavour=%d folder=%s", layerId, info.Flavour, exportFolderPath)
29
+		logrus.Error(err)
30
+		return err
31
+	}
32
+
33
+	logrus.Debugf(title+"succeeded flavour=%d layerId=%s folder=%s", info.Flavour, layerId, exportFolderPath)
34
+	return nil
35
+}
0 36
new file mode 100644
... ...
@@ -0,0 +1,55 @@
0
+package hcsshim
1
+
2
+import (
3
+	"syscall"
4
+
5
+	"github.com/Sirupsen/logrus"
6
+)
7
+
8
+// GetLayerMountPath will look for a mounted layer with the given id and return
9
+// the path at which that layer can be accessed.  This path may be a volume path
10
+// if the layer is a mounted read-write layer, otherwise it is expected to be the
11
+// folder path at which the layer is stored.
12
+func GetLayerMountPath(info DriverInfo, id string) (string, error) {
13
+	title := "hcsshim::GetLayerMountPath "
14
+	logrus.Debugf(title+"Flavour %d ID %s", info.Flavour, id)
15
+
16
+	// Convert info to API calling convention
17
+	infop, err := convertDriverInfo(info)
18
+	if err != nil {
19
+		logrus.Error(err)
20
+		return "", err
21
+	}
22
+
23
+	var mountPathLength uintptr
24
+	mountPathLength = 0
25
+
26
+	// Call the procedure itself.
27
+	logrus.Debugf("Calling proc (1)")
28
+	err = getLayerMountPath(&infop, id, &mountPathLength, nil)
29
+	if err != nil {
30
+		err = makeErrorf(err, title, "(first call) id=%s flavour=%d", id, info.Flavour)
31
+		logrus.Error(err)
32
+		return "", err
33
+	}
34
+
35
+	// Allocate a mount path of the returned length.
36
+	if mountPathLength == 0 {
37
+		return "", nil
38
+	}
39
+	mountPathp := make([]uint16, mountPathLength)
40
+	mountPathp[0] = 0
41
+
42
+	// Call the procedure again
43
+	logrus.Debugf("Calling proc (2)")
44
+	err = getLayerMountPath(&infop, id, &mountPathLength, &mountPathp[0])
45
+	if err != nil {
46
+		err = makeErrorf(err, title, "(second call) id=%s flavour=%d", id, info.Flavour)
47
+		logrus.Error(err)
48
+		return "", err
49
+	}
50
+
51
+	path := syscall.UTF16ToString(mountPathp[0:])
52
+	logrus.Debugf(title+"succeeded flavour=%d id=%s path=%s", info.Flavour, id, path)
53
+	return path, nil
54
+}
0 55
new file mode 100644
... ...
@@ -0,0 +1,22 @@
0
+package hcsshim
1
+
2
+import "github.com/Sirupsen/logrus"
3
+
4
+// GetSharedBaseImages will enumerate the images stored in the common central
5
+// image store and return descriptive info about those images for the purpose
6
+// of registering them with the graphdriver, graph, and tagstore.
7
+func GetSharedBaseImages() (imageData string, err error) {
8
+	title := "hcsshim::GetSharedBaseImages "
9
+
10
+	logrus.Debugf("Calling proc")
11
+	var buffer *uint16
12
+	err = getBaseImages(&buffer)
13
+	if err != nil {
14
+		err = makeError(err, title, "")
15
+		logrus.Error(err)
16
+		return
17
+	}
18
+	imageData = convertAndFreeCoTaskMemString(buffer)
19
+	logrus.Debugf(title+" - succeeded output=%s", imageData)
20
+	return
21
+}
0 22
new file mode 100644
... ...
@@ -0,0 +1,19 @@
0
+package hcsshim
1
+
2
+import (
3
+	"crypto/sha1"
4
+	"fmt"
5
+)
6
+
7
+type GUID [16]byte
8
+
9
+func NewGUID(source string) *GUID {
10
+	h := sha1.Sum([]byte(source))
11
+	var g GUID
12
+	copy(g[0:], h[0:16])
13
+	return &g
14
+}
15
+
16
+func (g *GUID) ToString() string {
17
+	return fmt.Sprintf("%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x-%02x", g[3], g[2], g[1], g[0], g[5], g[4], g[7], g[6], g[8:10], g[10:])
18
+}
0 19
new file mode 100644
... ...
@@ -0,0 +1,93 @@
0
+// Shim for the Host Compute Service (HSC) to manage Windows Server
1
+// containers and Hyper-V containers.
2
+
3
+package hcsshim
4
+
5
+import (
6
+	"fmt"
7
+	"syscall"
8
+	"unsafe"
9
+)
10
+
11
+//go:generate go run mksyscall_windows.go -output zhcsshim.go hcsshim.go
12
+
13
+//sys coTaskMemFree(buffer unsafe.Pointer) = ole32.CoTaskMemFree
14
+
15
+//sys activateLayer(info *driverInfo, id string) (hr error) = vmcompute.ActivateLayer?
16
+//sys copyLayer(info *driverInfo, srcId string, dstId string, descriptors []WC_LAYER_DESCRIPTOR) (hr error) = vmcompute.CopyLayer?
17
+//sys createLayer(info *driverInfo, id string, parent string) (hr error) = vmcompute.CreateLayer?
18
+//sys createSandboxLayer(info *driverInfo, id string, parent string, descriptors []WC_LAYER_DESCRIPTOR) (hr error) = vmcompute.CreateSandboxLayer?
19
+//sys deactivateLayer(info *driverInfo, id string) (hr error) = vmcompute.DeactivateLayer?
20
+//sys destroyLayer(info *driverInfo, id string) (hr error) = vmcompute.DestroyLayer?
21
+//sys exportLayer(info *driverInfo, id string, path string, descriptors []WC_LAYER_DESCRIPTOR) (hr error) = vmcompute.ExportLayer?
22
+//sys getLayerMountPath(info *driverInfo, id string, length *uintptr, buffer *uint16) (hr error) = vmcompute.GetLayerMountPath?
23
+//sys getBaseImages(buffer **uint16) (hr error) = vmcompute.GetBaseImages?
24
+//sys importLayer(info *driverInfo, id string, path string, descriptors []WC_LAYER_DESCRIPTOR) (hr error) = vmcompute.ImportLayer?
25
+//sys layerExists(info *driverInfo, id string, exists *uint32) (hr error) = vmcompute.LayerExists?
26
+//sys nameToGuid(name string, guid *GUID) (hr error) = vmcompute.NameToGuid?
27
+//sys prepareLayer(info *driverInfo, id string, descriptors []WC_LAYER_DESCRIPTOR) (hr error) = vmcompute.PrepareLayer?
28
+//sys unprepareLayer(info *driverInfo, id string) (hr error) = vmcompute.UnprepareLayer?
29
+
30
+//sys createComputeSystem(id string, configuration string) (hr error) = vmcompute.CreateComputeSystem?
31
+//sys createProcessWithStdHandlesInComputeSystem(id string, paramsJson string, pid *uint32, stdin *syscall.Handle, stdout *syscall.Handle, stderr *syscall.Handle) (hr error) = vmcompute.CreateProcessWithStdHandlesInComputeSystem?
32
+//sys resizeConsoleInComputeSystem(id string, pid uint32, height uint16, width uint16, flags uint32) (hr error) = vmcompute.ResizeConsoleInComputeSystem?
33
+//sys shutdownComputeSystem(id string, timeout uint32) (hr error) = vmcompute.ShutdownComputeSystem?
34
+//sys startComputeSystem(id string) (hr error) = vmcompute.StartComputeSystem?
35
+//sys terminateComputeSystem(id string) (hr error) = vmcompute.TerminateComputeSystem?
36
+//sys terminateProcessInComputeSystem(id string, pid uint32) (hr error) = vmcompute.TerminateProcessInComputeSystem?
37
+//sys waitForProcessInComputeSystem(id string, pid uint32, timeout uint32, exitCode *uint32) (hr error) = vmcompute.WaitForProcessInComputeSystem?
38
+
39
+//sys _hnsCall(method string, path string, object string, response **uint16) (hr error) = vmcompute.HNSCall?
40
+
41
+const (
42
+	// Specific user-visible exit codes
43
+	WaitErrExecFailed = 32767
44
+
45
+	// Known Win32 RC values which should be trapped
46
+	Win32PipeHasBeenEnded                 = 0x8007006d // WaitForProcessInComputeSystem: The pipe has been ended
47
+	Win32SystemShutdownIsInProgress       = 0x8007045B // ShutdownComputeSystem: A system shutdown is in progress
48
+	Win32SpecifiedPathInvalid             = 0x800700A1 // ShutdownComputeSystem: The specified path is invalid
49
+	Win32SystemCannotFindThePathSpecified = 0x80070003 // ShutdownComputeSystem: The system cannot find the path specified
50
+	Win32InvalidArgument                  = 0x80072726 // CreateProcessInComputeSystem: An invalid argument was supplied
51
+	EFail                                 = 0x80004005
52
+
53
+	// Timeout on wait calls
54
+	TimeoutInfinite = 0xFFFFFFFF
55
+)
56
+
57
+type hcsError struct {
58
+	title string
59
+	rest  string
60
+	err   error
61
+}
62
+
63
+type Win32Error interface {
64
+	error
65
+	HResult() uint32
66
+}
67
+
68
+func makeError(err error, title, rest string) Win32Error {
69
+	return &hcsError{title, rest, err}
70
+}
71
+
72
+func makeErrorf(err error, title, format string, a ...interface{}) Win32Error {
73
+	return makeError(err, title, fmt.Sprintf(format, a...))
74
+}
75
+
76
+func (e *hcsError) HResult() uint32 {
77
+	if hr, ok := e.err.(syscall.Errno); ok {
78
+		return uint32(hr)
79
+	} else {
80
+		return EFail
81
+	}
82
+}
83
+
84
+func (e *hcsError) Error() string {
85
+	return fmt.Sprintf("%s- Win32 API call returned error r1=0x%x err=%s%s", e.title, e.HResult(), e.err, e.rest)
86
+}
87
+
88
+func convertAndFreeCoTaskMemString(buffer *uint16) string {
89
+	str := syscall.UTF16ToString((*[1 << 30]uint16)(unsafe.Pointer(buffer))[:])
90
+	coTaskMemFree(unsafe.Pointer(buffer))
91
+	return str
92
+}
0 93
new file mode 100644
... ...
@@ -0,0 +1,131 @@
0
+package hcsshim
1
+
2
+import (
3
+	"encoding/json"
4
+	"fmt"
5
+	"net"
6
+
7
+	"github.com/Sirupsen/logrus"
8
+)
9
+
10
+type NatPolicy struct {
11
+	Type         string
12
+	Protocol     string
13
+	InternalPort uint16
14
+	ExternalPort uint16
15
+}
16
+
17
+type QosPolicy struct {
18
+	Type                            string
19
+	MaximumOutgoingBandwidthInBytes uint64
20
+}
21
+
22
+// Subnet is assoicated with a network and represents a list
23
+// of subnets available to the network
24
+type Subnet struct {
25
+	AddressPrefix  string `json:",omitempty"`
26
+	GatewayAddress string `json:",omitempty"`
27
+}
28
+
29
+// MacPool is assoicated with a network and represents a list
30
+// of macaddresses available to the network
31
+type MacPool struct {
32
+	StartMacAddress string `json:",omitempty"`
33
+	EndMacAddress   string `json:",omitempty"`
34
+}
35
+
36
+// HNSNetwork represents a network in HNS
37
+type HNSNetwork struct {
38
+	Id       string            `json:",omitempty"`
39
+	Name     string            `json:",omitempty"`
40
+	Type     string            `json:",omitempty"`
41
+	Policies []json.RawMessage `json:",omitempty"`
42
+	MacPools []MacPool         `json:",omitempty"`
43
+	Subnets  []Subnet          `json:",omitempty"`
44
+}
45
+
46
+// HNSEndpoint represents a network endpoint in HNS
47
+type HNSEndpoint struct {
48
+	Id                 string            `json:",omitempty"`
49
+	Name               string            `json:",omitempty"`
50
+	VirtualNetwork     string            `json:",omitempty"`
51
+	VirtualNetworkName string            `json:",omitempty"`
52
+	Policies           []json.RawMessage `json:",omitempty"`
53
+	MacAddress         string            `json:",omitempty"`
54
+	IPAddress          net.IP            `json:",omitempty"`
55
+}
56
+
57
+type hnsNetworkResponse struct {
58
+	Success bool
59
+	Error   string
60
+	Output  HNSNetwork
61
+}
62
+
63
+type hnsResponse struct {
64
+	Success bool
65
+	Error   string
66
+	Output  json.RawMessage
67
+}
68
+
69
+func hnsCall(method, path, request string, returnResponse interface{}) error {
70
+	var responseBuffer *uint16
71
+	err := _hnsCall(method, path, request, &responseBuffer)
72
+	if err != nil {
73
+		return makeError(err, "hnsCall ", "")
74
+	}
75
+	response := convertAndFreeCoTaskMemString(responseBuffer)
76
+
77
+	hnsresponse := &hnsResponse{}
78
+	if err = json.Unmarshal([]byte(response), &hnsresponse); err != nil {
79
+		return err
80
+	}
81
+
82
+	if !hnsresponse.Success {
83
+		return fmt.Errorf("HNS failed with error : %s", hnsresponse.Error)
84
+	}
85
+
86
+	if len(hnsresponse.Output) == 0 {
87
+		return nil
88
+	}
89
+
90
+	logrus.Debugf("Network Response : %s", hnsresponse.Output)
91
+	err = json.Unmarshal(hnsresponse.Output, returnResponse)
92
+	if err != nil {
93
+		return err
94
+	}
95
+
96
+	return nil
97
+}
98
+
99
+// HNSNetworkRequest makes a call into HNS to update/query a single network
100
+func HNSNetworkRequest(method, path, request string) (*HNSNetwork, error) {
101
+	var network HNSNetwork
102
+	err := hnsCall(method, "/networks/"+path, request, &network)
103
+	if err != nil {
104
+		return nil, err
105
+	}
106
+
107
+	return &network, nil
108
+}
109
+
110
+// HNSListNetworkRequest makes a HNS call to query the list of available networks
111
+func HNSListNetworkRequest(method, path, request string) ([]HNSNetwork, error) {
112
+	var network []HNSNetwork
113
+	err := hnsCall(method, "/networks/"+path, request, &network)
114
+	if err != nil {
115
+		return nil, err
116
+	}
117
+
118
+	return network, nil
119
+}
120
+
121
+// HNSEndpointRequest makes a HNS call to modify/query a network endpoint
122
+func HNSEndpointRequest(method, path, request string) (*HNSEndpoint, error) {
123
+	endpoint := &HNSEndpoint{}
124
+	err := hnsCall(method, "/endpoints/"+path, request, &endpoint)
125
+	if err != nil {
126
+		return nil, err
127
+	}
128
+
129
+	return endpoint, nil
130
+}
0 131
new file mode 100644
... ...
@@ -0,0 +1,35 @@
0
+package hcsshim
1
+
2
+import "github.com/Sirupsen/logrus"
3
+
4
+// ImportLayer will take the contents of the folder at importFolderPath and import
5
+// that into a layer with the id layerId.  Note that in order to correctly populate
6
+// the layer and interperet the transport format, all parent layers must already
7
+// be present on the system at the paths provided in parentLayerPaths.
8
+func ImportLayer(info DriverInfo, layerId string, importFolderPath string, parentLayerPaths []string) error {
9
+	title := "hcsshim::ImportLayer "
10
+	logrus.Debugf(title+"flavour %d layerId %s folder %s", info.Flavour, layerId, importFolderPath)
11
+
12
+	// Generate layer descriptors
13
+	layers, err := layerPathsToDescriptors(parentLayerPaths)
14
+	if err != nil {
15
+		return err
16
+	}
17
+
18
+	// Convert info to API calling convention
19
+	infop, err := convertDriverInfo(info)
20
+	if err != nil {
21
+		logrus.Error(err)
22
+		return err
23
+	}
24
+
25
+	err = importLayer(&infop, layerId, importFolderPath, layers)
26
+	if err != nil {
27
+		err = makeErrorf(err, title, "layerId=%s flavour=%d folder=%s", layerId, info.Flavour, importFolderPath)
28
+		logrus.Error(err)
29
+		return err
30
+	}
31
+
32
+	logrus.Debugf(title+"succeeded flavour=%d layerId=%s folder=%s", info.Flavour, layerId, importFolderPath)
33
+	return nil
34
+}
0 35
new file mode 100644
... ...
@@ -0,0 +1,30 @@
0
+package hcsshim
1
+
2
+import "github.com/Sirupsen/logrus"
3
+
4
+// LayerExists will return true if a layer with the given id exists and is known
5
+// to the system.
6
+func LayerExists(info DriverInfo, id string) (bool, error) {
7
+	title := "hcsshim::LayerExists "
8
+	logrus.Debugf(title+"Flavour %d ID %s", info.Flavour, id)
9
+
10
+	// Convert info to API calling convention
11
+	infop, err := convertDriverInfo(info)
12
+	if err != nil {
13
+		logrus.Error(err)
14
+		return false, err
15
+	}
16
+
17
+	// Call the procedure itself.
18
+	var exists uint32
19
+
20
+	err = layerExists(&infop, id, &exists)
21
+	if err != nil {
22
+		err = makeErrorf(err, title, "id=%s flavour=%d", id, info.Flavour)
23
+		logrus.Error(err)
24
+		return false, err
25
+	}
26
+
27
+	logrus.Debugf(title+"succeeded flavour=%d id=%s exists=%d", info.Flavour, id, exists)
28
+	return exists != 0, nil
29
+}
0 30
new file mode 100644
... ...
@@ -0,0 +1,111 @@
0
+package hcsshim
1
+
2
+// This file contains utility functions to support storage (graph) related
3
+// functionality.
4
+
5
+import (
6
+	"path/filepath"
7
+	"syscall"
8
+
9
+	"github.com/Sirupsen/logrus"
10
+)
11
+
12
+/* To pass into syscall, we need a struct matching the following:
13
+enum GraphDriverType
14
+{
15
+    DiffDriver,
16
+    FilterDriver
17
+};
18
+
19
+struct DriverInfo {
20
+    GraphDriverType Flavour;
21
+    LPCWSTR HomeDir;
22
+};
23
+*/
24
+type DriverInfo struct {
25
+	Flavour int
26
+	HomeDir string
27
+}
28
+
29
+type driverInfo struct {
30
+	Flavour  int
31
+	HomeDirp *uint16
32
+}
33
+
34
+func convertDriverInfo(info DriverInfo) (driverInfo, error) {
35
+	homedirp, err := syscall.UTF16PtrFromString(info.HomeDir)
36
+	if err != nil {
37
+		logrus.Debugf("Failed conversion of home to pointer for driver info: %s", err.Error())
38
+		return driverInfo{}, err
39
+	}
40
+
41
+	return driverInfo{
42
+		Flavour:  info.Flavour,
43
+		HomeDirp: homedirp,
44
+	}, nil
45
+}
46
+
47
+/* To pass into syscall, we need a struct matching the following:
48
+typedef struct _WC_LAYER_DESCRIPTOR {
49
+
50
+    //
51
+    // The ID of the layer
52
+    //
53
+
54
+    GUID LayerId;
55
+
56
+    //
57
+    // Additional flags
58
+    //
59
+
60
+    union {
61
+        struct {
62
+            ULONG Reserved : 31;
63
+            ULONG Dirty : 1;    // Created from sandbox as a result of snapshot
64
+        };
65
+        ULONG Value;
66
+    } Flags;
67
+
68
+    //
69
+    // Path to the layer root directory, null-terminated
70
+    //
71
+
72
+    PCWSTR Path;
73
+
74
+} WC_LAYER_DESCRIPTOR, *PWC_LAYER_DESCRIPTOR;
75
+*/
76
+type WC_LAYER_DESCRIPTOR struct {
77
+	LayerId GUID
78
+	Flags   uint32
79
+	Pathp   *uint16
80
+}
81
+
82
+func layerPathsToDescriptors(parentLayerPaths []string) ([]WC_LAYER_DESCRIPTOR, error) {
83
+	// Array of descriptors that gets constructed.
84
+	var layers []WC_LAYER_DESCRIPTOR
85
+
86
+	for i := 0; i < len(parentLayerPaths); i++ {
87
+		// Create a layer descriptor, using the folder name
88
+		// as the source for a GUID LayerId
89
+		_, folderName := filepath.Split(parentLayerPaths[i])
90
+		g, err := NameToGuid(folderName)
91
+		if err != nil {
92
+			logrus.Debugf("Failed to convert name to guid %s", err)
93
+			return nil, err
94
+		}
95
+
96
+		p, err := syscall.UTF16PtrFromString(parentLayerPaths[i])
97
+		if err != nil {
98
+			logrus.Debugf("Failed conversion of parentLayerPath to pointer %s", err)
99
+			return nil, err
100
+		}
101
+
102
+		layers = append(layers, WC_LAYER_DESCRIPTOR{
103
+			LayerId: g,
104
+			Flags:   0,
105
+			Pathp:   p,
106
+		})
107
+	}
108
+
109
+	return layers, nil
110
+}
0 111
new file mode 100644
... ...
@@ -0,0 +1,797 @@
0
+// Copyright 2013 The Go Authors. All rights reserved.
1
+// Use of this source code is governed by a BSD-style
2
+// license that can be found in the LICENSE file.
3
+
4
+// +build ignore
5
+
6
+/*
7
+mksyscall_windows generates windows system call bodies
8
+
9
+It parses all files specified on command line containing function
10
+prototypes (like syscall_windows.go) and prints system call bodies
11
+to standard output.
12
+
13
+The prototypes are marked by lines beginning with "//sys" and read
14
+like func declarations if //sys is replaced by func, but:
15
+
16
+* The parameter lists must give a name for each argument. This
17
+  includes return parameters.
18
+
19
+* The parameter lists must give a type for each argument:
20
+  the (x, y, z int) shorthand is not allowed.
21
+
22
+* If the return parameter is an error number, it must be named err.
23
+
24
+* If go func name needs to be different from it's winapi dll name,
25
+  the winapi name could be specified at the end, after "=" sign, like
26
+  //sys LoadLibrary(libname string) (handle uint32, err error) = LoadLibraryA
27
+
28
+* Each function that returns err needs to supply a condition, that
29
+  return value of winapi will be tested against to detect failure.
30
+  This would set err to windows "last-error", otherwise it will be nil.
31
+  The value can be provided at end of //sys declaration, like
32
+  //sys LoadLibrary(libname string) (handle uint32, err error) [failretval==-1] = LoadLibraryA
33
+  and is [failretval==0] by default.
34
+
35
+Usage:
36
+	mksyscall_windows [flags] [path ...]
37
+
38
+The flags are:
39
+	-output
40
+		Specify output file name (outputs to console if blank).
41
+	-trace
42
+		Generate print statement after every syscall.
43
+*/
44
+package main
45
+
46
+import (
47
+	"bufio"
48
+	"bytes"
49
+	"errors"
50
+	"flag"
51
+	"fmt"
52
+	"go/format"
53
+	"go/parser"
54
+	"go/token"
55
+	"io"
56
+	"io/ioutil"
57
+	"log"
58
+	"os"
59
+	"strconv"
60
+	"strings"
61
+	"text/template"
62
+)
63
+
64
+var (
65
+	filename       = flag.String("output", "", "output file name (standard output if omitted)")
66
+	printTraceFlag = flag.Bool("trace", false, "generate print statement after every syscall")
67
+)
68
+
69
+func trim(s string) string {
70
+	return strings.Trim(s, " \t")
71
+}
72
+
73
+var packageName string
74
+
75
+func packagename() string {
76
+	return packageName
77
+}
78
+
79
+func syscalldot() string {
80
+	if packageName == "syscall" {
81
+		return ""
82
+	}
83
+	return "syscall."
84
+}
85
+
86
+// Param is function parameter
87
+type Param struct {
88
+	Name      string
89
+	Type      string
90
+	fn        *Fn
91
+	tmpVarIdx int
92
+}
93
+
94
+// tmpVar returns temp variable name that will be used to represent p during syscall.
95
+func (p *Param) tmpVar() string {
96
+	if p.tmpVarIdx < 0 {
97
+		p.tmpVarIdx = p.fn.curTmpVarIdx
98
+		p.fn.curTmpVarIdx++
99
+	}
100
+	return fmt.Sprintf("_p%d", p.tmpVarIdx)
101
+}
102
+
103
+// BoolTmpVarCode returns source code for bool temp variable.
104
+func (p *Param) BoolTmpVarCode() string {
105
+	const code = `var %s uint32
106
+	if %s {
107
+		%s = 1
108
+	} else {
109
+		%s = 0
110
+	}`
111
+	tmp := p.tmpVar()
112
+	return fmt.Sprintf(code, tmp, p.Name, tmp, tmp)
113
+}
114
+
115
+// SliceTmpVarCode returns source code for slice temp variable.
116
+func (p *Param) SliceTmpVarCode() string {
117
+	const code = `var %s *%s
118
+	if len(%s) > 0 {
119
+		%s = &%s[0]
120
+	}`
121
+	tmp := p.tmpVar()
122
+	return fmt.Sprintf(code, tmp, p.Type[2:], p.Name, tmp, p.Name)
123
+}
124
+
125
+// StringTmpVarCode returns source code for string temp variable.
126
+func (p *Param) StringTmpVarCode() string {
127
+	errvar := p.fn.Rets.ErrorVarName()
128
+	if errvar == "" {
129
+		errvar = "_"
130
+	}
131
+	tmp := p.tmpVar()
132
+	const code = `var %s %s
133
+	%s, %s = %s(%s)`
134
+	s := fmt.Sprintf(code, tmp, p.fn.StrconvType(), tmp, errvar, p.fn.StrconvFunc(), p.Name)
135
+	if errvar == "-" {
136
+		return s
137
+	}
138
+	const morecode = `
139
+	if %s != nil {
140
+		return
141
+	}`
142
+	return s + fmt.Sprintf(morecode, errvar)
143
+}
144
+
145
+// TmpVarCode returns source code for temp variable.
146
+func (p *Param) TmpVarCode() string {
147
+	switch {
148
+	case p.Type == "bool":
149
+		return p.BoolTmpVarCode()
150
+	case strings.HasPrefix(p.Type, "[]"):
151
+		return p.SliceTmpVarCode()
152
+	default:
153
+		return ""
154
+	}
155
+}
156
+
157
+// TmpVarHelperCode returns source code for helper's temp variable.
158
+func (p *Param) TmpVarHelperCode() string {
159
+	if p.Type != "string" {
160
+		return ""
161
+	}
162
+	return p.StringTmpVarCode()
163
+}
164
+
165
+// SyscallArgList returns source code fragments representing p parameter
166
+// in syscall. Slices are translated into 2 syscall parameters: pointer to
167
+// the first element and length.
168
+func (p *Param) SyscallArgList() []string {
169
+	t := p.HelperType()
170
+	var s string
171
+	switch {
172
+	case t[0] == '*':
173
+		s = fmt.Sprintf("unsafe.Pointer(%s)", p.Name)
174
+	case t == "bool":
175
+		s = p.tmpVar()
176
+	case strings.HasPrefix(t, "[]"):
177
+		return []string{
178
+			fmt.Sprintf("uintptr(unsafe.Pointer(%s))", p.tmpVar()),
179
+			fmt.Sprintf("uintptr(len(%s))", p.Name),
180
+		}
181
+	default:
182
+		s = p.Name
183
+	}
184
+	return []string{fmt.Sprintf("uintptr(%s)", s)}
185
+}
186
+
187
+// IsError determines if p parameter is used to return error.
188
+func (p *Param) IsError() bool {
189
+	return p.Name == "err" && p.Type == "error"
190
+}
191
+
192
+// HelperType returns type of parameter p used in helper function.
193
+func (p *Param) HelperType() string {
194
+	if p.Type == "string" {
195
+		return p.fn.StrconvType()
196
+	}
197
+	return p.Type
198
+}
199
+
200
+// join concatenates parameters ps into a string with sep separator.
201
+// Each parameter is converted into string by applying fn to it
202
+// before conversion.
203
+func join(ps []*Param, fn func(*Param) string, sep string) string {
204
+	if len(ps) == 0 {
205
+		return ""
206
+	}
207
+	a := make([]string, 0)
208
+	for _, p := range ps {
209
+		a = append(a, fn(p))
210
+	}
211
+	return strings.Join(a, sep)
212
+}
213
+
214
+// Rets describes function return parameters.
215
+type Rets struct {
216
+	Name         string
217
+	Type         string
218
+	ReturnsError bool
219
+	FailCond     string
220
+}
221
+
222
+// ErrorVarName returns error variable name for r.
223
+func (r *Rets) ErrorVarName() string {
224
+	if r.ReturnsError {
225
+		return "err"
226
+	}
227
+	if r.Type == "error" {
228
+		return r.Name
229
+	}
230
+	return ""
231
+}
232
+
233
+// ToParams converts r into slice of *Param.
234
+func (r *Rets) ToParams() []*Param {
235
+	ps := make([]*Param, 0)
236
+	if len(r.Name) > 0 {
237
+		ps = append(ps, &Param{Name: r.Name, Type: r.Type})
238
+	}
239
+	if r.ReturnsError {
240
+		ps = append(ps, &Param{Name: "err", Type: "error"})
241
+	}
242
+	return ps
243
+}
244
+
245
+// List returns source code of syscall return parameters.
246
+func (r *Rets) List() string {
247
+	s := join(r.ToParams(), func(p *Param) string { return p.Name + " " + p.Type }, ", ")
248
+	if len(s) > 0 {
249
+		s = "(" + s + ")"
250
+	}
251
+	return s
252
+}
253
+
254
+// PrintList returns source code of trace printing part correspondent
255
+// to syscall return values.
256
+func (r *Rets) PrintList() string {
257
+	return join(r.ToParams(), func(p *Param) string { return fmt.Sprintf(`"%s=", %s, `, p.Name, p.Name) }, `", ", `)
258
+}
259
+
260
+// SetReturnValuesCode returns source code that accepts syscall return values.
261
+func (r *Rets) SetReturnValuesCode() string {
262
+	if r.Name == "" && !r.ReturnsError {
263
+		return ""
264
+	}
265
+	retvar := "r0"
266
+	if r.Name == "" {
267
+		retvar = "r1"
268
+	}
269
+	errvar := "_"
270
+	if r.ReturnsError {
271
+		errvar = "e1"
272
+	}
273
+	return fmt.Sprintf("%s, _, %s := ", retvar, errvar)
274
+}
275
+
276
+func (r *Rets) useLongHandleErrorCode(retvar string) string {
277
+	const code = `if %s {
278
+		if e1 != 0 {
279
+			err = error(e1)
280
+		} else {
281
+			err = %sEINVAL
282
+		}
283
+	}`
284
+	cond := retvar + " == 0"
285
+	if r.FailCond != "" {
286
+		cond = strings.Replace(r.FailCond, "failretval", retvar, 1)
287
+	}
288
+	return fmt.Sprintf(code, cond, syscalldot())
289
+}
290
+
291
+// SetErrorCode returns source code that sets return parameters.
292
+func (r *Rets) SetErrorCode() string {
293
+	const code = `if r0 != 0 {
294
+		%s = %sErrno(r0)
295
+	}`
296
+	if r.Name == "" && !r.ReturnsError {
297
+		return ""
298
+	}
299
+	if r.Name == "" {
300
+		return r.useLongHandleErrorCode("r1")
301
+	}
302
+	if r.Type == "error" {
303
+		return fmt.Sprintf(code, r.Name, syscalldot())
304
+	}
305
+	s := ""
306
+	switch {
307
+	case r.Type[0] == '*':
308
+		s = fmt.Sprintf("%s = (%s)(unsafe.Pointer(r0))", r.Name, r.Type)
309
+	case r.Type == "bool":
310
+		s = fmt.Sprintf("%s = r0 != 0", r.Name)
311
+	default:
312
+		s = fmt.Sprintf("%s = %s(r0)", r.Name, r.Type)
313
+	}
314
+	if !r.ReturnsError {
315
+		return s
316
+	}
317
+	return s + "\n\t" + r.useLongHandleErrorCode(r.Name)
318
+}
319
+
320
+// Fn describes syscall function.
321
+type Fn struct {
322
+	Name        string
323
+	Params      []*Param
324
+	Rets        *Rets
325
+	PrintTrace  bool
326
+	confirmproc bool
327
+	dllname     string
328
+	dllfuncname string
329
+	src         string
330
+	// TODO: get rid of this field and just use parameter index instead
331
+	curTmpVarIdx int // insure tmp variables have uniq names
332
+}
333
+
334
+// extractParams parses s to extract function parameters.
335
+func extractParams(s string, f *Fn) ([]*Param, error) {
336
+	s = trim(s)
337
+	if s == "" {
338
+		return nil, nil
339
+	}
340
+	a := strings.Split(s, ",")
341
+	ps := make([]*Param, len(a))
342
+	for i := range ps {
343
+		s2 := trim(a[i])
344
+		b := strings.Split(s2, " ")
345
+		if len(b) != 2 {
346
+			b = strings.Split(s2, "\t")
347
+			if len(b) != 2 {
348
+				return nil, errors.New("Could not extract function parameter from \"" + s2 + "\"")
349
+			}
350
+		}
351
+		ps[i] = &Param{
352
+			Name:      trim(b[0]),
353
+			Type:      trim(b[1]),
354
+			fn:        f,
355
+			tmpVarIdx: -1,
356
+		}
357
+	}
358
+	return ps, nil
359
+}
360
+
361
+// extractSection extracts text out of string s starting after start
362
+// and ending just before end. found return value will indicate success,
363
+// and prefix, body and suffix will contain correspondent parts of string s.
364
+func extractSection(s string, start, end rune) (prefix, body, suffix string, found bool) {
365
+	s = trim(s)
366
+	if strings.HasPrefix(s, string(start)) {
367
+		// no prefix
368
+		body = s[1:]
369
+	} else {
370
+		a := strings.SplitN(s, string(start), 2)
371
+		if len(a) != 2 {
372
+			return "", "", s, false
373
+		}
374
+		prefix = a[0]
375
+		body = a[1]
376
+	}
377
+	a := strings.SplitN(body, string(end), 2)
378
+	if len(a) != 2 {
379
+		return "", "", "", false
380
+	}
381
+	return prefix, a[0], a[1], true
382
+}
383
+
384
+// newFn parses string s and return created function Fn.
385
+func newFn(s string) (*Fn, error) {
386
+	s = trim(s)
387
+	f := &Fn{
388
+		Rets:       &Rets{},
389
+		src:        s,
390
+		PrintTrace: *printTraceFlag,
391
+	}
392
+	// function name and args
393
+	prefix, body, s, found := extractSection(s, '(', ')')
394
+	if !found || prefix == "" {
395
+		return nil, errors.New("Could not extract function name and parameters from \"" + f.src + "\"")
396
+	}
397
+	f.Name = prefix
398
+	var err error
399
+	f.Params, err = extractParams(body, f)
400
+	if err != nil {
401
+		return nil, err
402
+	}
403
+	// return values
404
+	_, body, s, found = extractSection(s, '(', ')')
405
+	if found {
406
+		r, err := extractParams(body, f)
407
+		if err != nil {
408
+			return nil, err
409
+		}
410
+		switch len(r) {
411
+		case 0:
412
+		case 1:
413
+			if r[0].IsError() {
414
+				f.Rets.ReturnsError = true
415
+			} else {
416
+				f.Rets.Name = r[0].Name
417
+				f.Rets.Type = r[0].Type
418
+			}
419
+		case 2:
420
+			if !r[1].IsError() {
421
+				return nil, errors.New("Only last windows error is allowed as second return value in \"" + f.src + "\"")
422
+			}
423
+			f.Rets.ReturnsError = true
424
+			f.Rets.Name = r[0].Name
425
+			f.Rets.Type = r[0].Type
426
+		default:
427
+			return nil, errors.New("Too many return values in \"" + f.src + "\"")
428
+		}
429
+	}
430
+	// fail condition
431
+	_, body, s, found = extractSection(s, '[', ']')
432
+	if found {
433
+		f.Rets.FailCond = body
434
+	}
435
+	// dll and dll function names
436
+	s = trim(s)
437
+	if s == "" {
438
+		return f, nil
439
+	}
440
+	if !strings.HasPrefix(s, "=") {
441
+		return nil, errors.New("Could not extract dll name from \"" + f.src + "\"")
442
+	}
443
+	s = trim(s[1:])
444
+	a := strings.Split(s, ".")
445
+	switch len(a) {
446
+	case 1:
447
+		f.dllfuncname = a[0]
448
+	case 2:
449
+		f.dllname = a[0]
450
+		f.dllfuncname = a[1]
451
+	default:
452
+		return nil, errors.New("Could not extract dll name from \"" + f.src + "\"")
453
+	}
454
+	if f.dllfuncname[len(f.dllfuncname)-1] == '?' {
455
+		f.confirmproc = true
456
+		f.dllfuncname = f.dllfuncname[0 : len(f.dllfuncname)-1]
457
+	}
458
+	return f, nil
459
+}
460
+
461
+// DLLName returns DLL name for function f.
462
+func (f *Fn) DLLName() string {
463
+	if f.dllname == "" {
464
+		return "kernel32"
465
+	}
466
+	return f.dllname
467
+}
468
+
469
+// DLLName returns DLL function name for function f.
470
+func (f *Fn) DLLFuncName() string {
471
+	if f.dllfuncname == "" {
472
+		return f.Name
473
+	}
474
+	return f.dllfuncname
475
+}
476
+
477
+func (f *Fn) ConfirmProc() bool {
478
+	return f.confirmproc
479
+}
480
+
481
+// ParamList returns source code for function f parameters.
482
+func (f *Fn) ParamList() string {
483
+	return join(f.Params, func(p *Param) string { return p.Name + " " + p.Type }, ", ")
484
+}
485
+
486
+// HelperParamList returns source code for helper function f parameters.
487
+func (f *Fn) HelperParamList() string {
488
+	return join(f.Params, func(p *Param) string { return p.Name + " " + p.HelperType() }, ", ")
489
+}
490
+
491
+// ParamPrintList returns source code of trace printing part correspondent
492
+// to syscall input parameters.
493
+func (f *Fn) ParamPrintList() string {
494
+	return join(f.Params, func(p *Param) string { return fmt.Sprintf(`"%s=", %s, `, p.Name, p.Name) }, `", ", `)
495
+}
496
+
497
+// ParamCount return number of syscall parameters for function f.
498
+func (f *Fn) ParamCount() int {
499
+	n := 0
500
+	for _, p := range f.Params {
501
+		n += len(p.SyscallArgList())
502
+	}
503
+	return n
504
+}
505
+
506
+// SyscallParamCount determines which version of Syscall/Syscall6/Syscall9/...
507
+// to use. It returns parameter count for correspondent SyscallX function.
508
+func (f *Fn) SyscallParamCount() int {
509
+	n := f.ParamCount()
510
+	switch {
511
+	case n <= 3:
512
+		return 3
513
+	case n <= 6:
514
+		return 6
515
+	case n <= 9:
516
+		return 9
517
+	case n <= 12:
518
+		return 12
519
+	case n <= 15:
520
+		return 15
521
+	default:
522
+		panic("too many arguments to system call")
523
+	}
524
+}
525
+
526
+// Syscall determines which SyscallX function to use for function f.
527
+func (f *Fn) Syscall() string {
528
+	c := f.SyscallParamCount()
529
+	if c == 3 {
530
+		return syscalldot() + "Syscall"
531
+	}
532
+	return syscalldot() + "Syscall" + strconv.Itoa(c)
533
+}
534
+
535
+// SyscallParamList returns source code for SyscallX parameters for function f.
536
+func (f *Fn) SyscallParamList() string {
537
+	a := make([]string, 0)
538
+	for _, p := range f.Params {
539
+		a = append(a, p.SyscallArgList()...)
540
+	}
541
+	for len(a) < f.SyscallParamCount() {
542
+		a = append(a, "0")
543
+	}
544
+	return strings.Join(a, ", ")
545
+}
546
+
547
+// HelperCallParamList returns source code of call into function f helper.
548
+func (f *Fn) HelperCallParamList() string {
549
+	a := make([]string, 0, len(f.Params))
550
+	for _, p := range f.Params {
551
+		s := p.Name
552
+		if p.Type == "string" {
553
+			s = p.tmpVar()
554
+		}
555
+		a = append(a, s)
556
+	}
557
+	return strings.Join(a, ", ")
558
+}
559
+
560
+// IsUTF16 is true, if f is W (utf16) function. It is false
561
+// for all A (ascii) functions.
562
+func (_ *Fn) IsUTF16() bool {
563
+	return true
564
+}
565
+
566
+// StrconvFunc returns name of Go string to OS string function for f.
567
+func (f *Fn) StrconvFunc() string {
568
+	if f.IsUTF16() {
569
+		return syscalldot() + "UTF16PtrFromString"
570
+	}
571
+	return syscalldot() + "BytePtrFromString"
572
+}
573
+
574
+// StrconvType returns Go type name used for OS string for f.
575
+func (f *Fn) StrconvType() string {
576
+	if f.IsUTF16() {
577
+		return "*uint16"
578
+	}
579
+	return "*byte"
580
+}
581
+
582
+// HasStringParam is true, if f has at least one string parameter.
583
+// Otherwise it is false.
584
+func (f *Fn) HasStringParam() bool {
585
+	for _, p := range f.Params {
586
+		if p.Type == "string" {
587
+			return true
588
+		}
589
+	}
590
+	return false
591
+}
592
+
593
+// HelperName returns name of function f helper.
594
+func (f *Fn) HelperName() string {
595
+	if !f.HasStringParam() {
596
+		return f.Name
597
+	}
598
+	return "_" + f.Name
599
+}
600
+
601
+// Source files and functions.
602
+type Source struct {
603
+	Funcs []*Fn
604
+	Files []string
605
+}
606
+
607
+// ParseFiles parses files listed in fs and extracts all syscall
608
+// functions listed in  sys comments. It returns source files
609
+// and functions collection *Source if successful.
610
+func ParseFiles(fs []string) (*Source, error) {
611
+	src := &Source{
612
+		Funcs: make([]*Fn, 0),
613
+		Files: make([]string, 0),
614
+	}
615
+	for _, file := range fs {
616
+		if err := src.ParseFile(file); err != nil {
617
+			return nil, err
618
+		}
619
+	}
620
+	return src, nil
621
+}
622
+
623
+// DLLs return dll names for a source set src.
624
+func (src *Source) DLLs() []string {
625
+	uniq := make(map[string]bool)
626
+	r := make([]string, 0)
627
+	for _, f := range src.Funcs {
628
+		name := f.DLLName()
629
+		if _, found := uniq[name]; !found {
630
+			uniq[name] = true
631
+			r = append(r, name)
632
+		}
633
+	}
634
+	return r
635
+}
636
+
637
+// ParseFile adds additional file path to a source set src.
638
+func (src *Source) ParseFile(path string) error {
639
+	file, err := os.Open(path)
640
+	if err != nil {
641
+		return err
642
+	}
643
+	defer file.Close()
644
+
645
+	s := bufio.NewScanner(file)
646
+	for s.Scan() {
647
+		t := trim(s.Text())
648
+		if len(t) < 7 {
649
+			continue
650
+		}
651
+		if !strings.HasPrefix(t, "//sys") {
652
+			continue
653
+		}
654
+		t = t[5:]
655
+		if !(t[0] == ' ' || t[0] == '\t') {
656
+			continue
657
+		}
658
+		f, err := newFn(t[1:])
659
+		if err != nil {
660
+			return err
661
+		}
662
+		src.Funcs = append(src.Funcs, f)
663
+	}
664
+	if err := s.Err(); err != nil {
665
+		return err
666
+	}
667
+	src.Files = append(src.Files, path)
668
+
669
+	// get package name
670
+	fset := token.NewFileSet()
671
+	_, err = file.Seek(0, 0)
672
+	if err != nil {
673
+		return err
674
+	}
675
+	pkg, err := parser.ParseFile(fset, "", file, parser.PackageClauseOnly)
676
+	if err != nil {
677
+		return err
678
+	}
679
+	packageName = pkg.Name.Name
680
+
681
+	return nil
682
+}
683
+
684
+// Generate output source file from a source set src.
685
+func (src *Source) Generate(w io.Writer) error {
686
+	funcMap := template.FuncMap{
687
+		"packagename": packagename,
688
+		"syscalldot":  syscalldot,
689
+	}
690
+	t := template.Must(template.New("main").Funcs(funcMap).Parse(srcTemplate))
691
+	err := t.Execute(w, src)
692
+	if err != nil {
693
+		return errors.New("Failed to execute template: " + err.Error())
694
+	}
695
+	return nil
696
+}
697
+
698
+func usage() {
699
+	fmt.Fprintf(os.Stderr, "usage: mksyscall_windows [flags] [path ...]\n")
700
+	flag.PrintDefaults()
701
+	os.Exit(1)
702
+}
703
+
704
+func main() {
705
+	flag.Usage = usage
706
+	flag.Parse()
707
+	if len(flag.Args()) <= 0 {
708
+		fmt.Fprintf(os.Stderr, "no files to parse provided\n")
709
+		usage()
710
+	}
711
+
712
+	src, err := ParseFiles(flag.Args())
713
+	if err != nil {
714
+		log.Fatal(err)
715
+	}
716
+
717
+	var buf bytes.Buffer
718
+	if err := src.Generate(&buf); err != nil {
719
+		log.Fatal(err)
720
+	}
721
+
722
+	data, err := format.Source(buf.Bytes())
723
+	if err != nil {
724
+		log.Fatal(err)
725
+	}
726
+	if *filename == "" {
727
+		_, err = os.Stdout.Write(data)
728
+	} else {
729
+		err = ioutil.WriteFile(*filename, data, 0644)
730
+	}
731
+	if err != nil {
732
+		log.Fatal(err)
733
+	}
734
+}
735
+
736
+// TODO: use println instead to print in the following template
737
+const srcTemplate = `
738
+
739
+{{define "main"}}// MACHINE GENERATED BY 'go generate' COMMAND; DO NOT EDIT
740
+
741
+package {{packagename}}
742
+
743
+import "unsafe"{{if syscalldot}}
744
+import "syscall"{{end}}
745
+
746
+var _ unsafe.Pointer
747
+
748
+var (
749
+{{template "dlls" .}}
750
+{{template "funcnames" .}})
751
+{{range .Funcs}}{{if .HasStringParam}}{{template "helperbody" .}}{{end}}{{template "funcbody" .}}{{end}}
752
+{{end}}
753
+
754
+{{/* help functions */}}
755
+
756
+{{define "dlls"}}{{range .DLLs}}	mod{{.}} = {{syscalldot}}NewLazyDLL("{{.}}.dll")
757
+{{end}}{{end}}
758
+
759
+{{define "funcnames"}}{{range .Funcs}}	proc{{.DLLFuncName}} = mod{{.DLLName}}.NewProc("{{.DLLFuncName}}")
760
+{{end}}{{end}}
761
+
762
+{{define "helperbody"}}
763
+func {{.Name}}({{.ParamList}}) {{template "results" .}}{
764
+{{template "helpertmpvars" .}}	return {{.HelperName}}({{.HelperCallParamList}})
765
+}
766
+{{end}}
767
+
768
+{{define "funcbody"}}
769
+func {{.HelperName}}({{.HelperParamList}}) {{template "results" .}}{
770
+{{template "tmpvars" .}}	{{template "syscallcheck" .}}{{template "syscall" .}}
771
+{{template "seterror" .}}{{template "printtrace" .}}	return
772
+}
773
+{{end}}
774
+
775
+{{define "helpertmpvars"}}{{range .Params}}{{if .TmpVarHelperCode}}	{{.TmpVarHelperCode}}
776
+{{end}}{{end}}{{end}}
777
+
778
+{{define "tmpvars"}}{{range .Params}}{{if .TmpVarCode}}	{{.TmpVarCode}}
779
+{{end}}{{end}}{{end}}
780
+
781
+{{define "results"}}{{if .Rets.List}}{{.Rets.List}} {{end}}{{end}}
782
+
783
+{{define "syscallcheck"}}{{if .ConfirmProc}}if {{.Rets.ErrorVarName}} = proc{{.DLLFuncName}}.Find(); {{.Rets.ErrorVarName}} != nil {
784
+    return
785
+}
786
+{{end}}{{end}}
787
+
788
+{{define "syscall"}}{{.Rets.SetReturnValuesCode}}{{.Syscall}}(proc{{.DLLFuncName}}.Addr(), {{.ParamCount}}, {{.SyscallParamList}}){{end}}
789
+
790
+{{define "seterror"}}{{if .Rets.SetErrorCode}}	{{.Rets.SetErrorCode}}
791
+{{end}}{{end}}
792
+
793
+{{define "printtrace"}}{{if .PrintTrace}}	print("SYSCALL: {{.Name}}(", {{.ParamPrintList}}") (", {{.Rets.PrintList}}")\n")
794
+{{end}}{{end}}
795
+
796
+`
0 797
new file mode 100644
... ...
@@ -0,0 +1,20 @@
0
+package hcsshim
1
+
2
+import "github.com/Sirupsen/logrus"
3
+
4
+// NameToGuid converts the given string into a GUID using the algorithm in the
5
+// Host Compute Service, ensuring GUIDs generated with the same string are common
6
+// across all clients.
7
+func NameToGuid(name string) (id GUID, err error) {
8
+	title := "hcsshim::NameToGuid "
9
+	logrus.Debugf(title+"Name %s", name)
10
+
11
+	err = nameToGuid(name, &id)
12
+	if err != nil {
13
+		err = makeErrorf(err, title, "name=%s", name)
14
+		logrus.Error(err)
15
+		return
16
+	}
17
+
18
+	return
19
+}
0 20
new file mode 100644
... ...
@@ -0,0 +1,36 @@
0
+package hcsshim
1
+
2
+import "github.com/Sirupsen/logrus"
3
+
4
+// PrepareLayer finds a mounted read-write layer matching layerId and enables the
5
+// the filesystem filter for use on that layer.  This requires the paths to all
6
+// parent layers, and is necessary in order to view or interact with the layer
7
+// as an actual filesystem (reading and writing files, creating directories, etc).
8
+// Disabling the filter must be done via UnprepareLayer.
9
+func PrepareLayer(info DriverInfo, layerId string, parentLayerPaths []string) error {
10
+	title := "hcsshim::PrepareLayer "
11
+	logrus.Debugf(title+"flavour %d layerId %s", info.Flavour, layerId)
12
+
13
+	// Generate layer descriptors
14
+	layers, err := layerPathsToDescriptors(parentLayerPaths)
15
+	if err != nil {
16
+		return err
17
+	}
18
+
19
+	// Convert info to API calling convention
20
+	infop, err := convertDriverInfo(info)
21
+	if err != nil {
22
+		logrus.Error(err)
23
+		return err
24
+	}
25
+
26
+	err = prepareLayer(&infop, layerId, layers)
27
+	if err != nil {
28
+		err = makeErrorf(err, title, "layerId=%s flavour=%d", layerId, info.Flavour)
29
+		logrus.Error(err)
30
+		return err
31
+	}
32
+
33
+	logrus.Debugf(title+"succeeded flavour=%d layerId=%s", info.Flavour, layerId)
34
+	return nil
35
+}
0 36
new file mode 100644
... ...
@@ -0,0 +1,22 @@
0
+package hcsshim
1
+
2
+import "github.com/Sirupsen/logrus"
3
+
4
+// ResizeConsoleInComputeSystem updates the height and width of the console
5
+// session for the process with the given id in the container with the given id.
6
+func ResizeConsoleInComputeSystem(id string, processid uint32, h, w int) error {
7
+
8
+	title := "HCSShim::ResizeConsoleInComputeSystem"
9
+	logrus.Debugf(title+" id=%s processid=%d (%d,%d)", id, processid, h, w)
10
+
11
+	err := resizeConsoleInComputeSystem(id, processid, uint16(h), uint16(w), 0)
12
+	if err != nil {
13
+		err = makeErrorf(err, title, "id=%s pid=%d", id, processid)
14
+		logrus.Error(err)
15
+		return err
16
+	}
17
+
18
+	logrus.Debugf(title+" succeeded id=%s processid=%d (%d,%d)", id, processid, h, w)
19
+	return nil
20
+
21
+}
0 22
new file mode 100644
... ...
@@ -0,0 +1,44 @@
0
+package hcsshim
1
+
2
+import "github.com/Sirupsen/logrus"
3
+
4
+// TerminateComputeSystem force terminates a container.
5
+func TerminateComputeSystem(id string, timeout uint32, context string) (uint32, error) {
6
+	return shutdownTerminate(false, id, timeout, context)
7
+}
8
+
9
+// ShutdownComputeSystem shuts down a container by requesting a shutdown within
10
+// the container operating system.
11
+func ShutdownComputeSystem(id string, timeout uint32, context string) (uint32, error) {
12
+	return shutdownTerminate(true, id, timeout, context)
13
+}
14
+
15
+// shutdownTerminate is a wrapper for ShutdownComputeSystem and TerminateComputeSystem
16
+// which have very similar calling semantics
17
+func shutdownTerminate(shutdown bool, id string, timeout uint32, context string) (uint32, error) {
18
+
19
+	var (
20
+		title = "HCSShim::"
21
+	)
22
+	if shutdown {
23
+		title = title + "ShutdownComputeSystem"
24
+	} else {
25
+		title = title + "TerminateComputeSystem"
26
+	}
27
+	logrus.Debugf(title+" id=%s context=%s", id, context)
28
+
29
+	var err error
30
+	if shutdown {
31
+		err = shutdownComputeSystem(id, timeout)
32
+	} else {
33
+		err = terminateComputeSystem(id)
34
+	}
35
+
36
+	if err != nil {
37
+		err := makeErrorf(err, title, "id=%s context=%s", id, context)
38
+		return err.HResult(), err
39
+	}
40
+
41
+	logrus.Debugf(title+" succeeded id=%s context=%s", id, context)
42
+	return 0, nil
43
+}
0 44
new file mode 100644
... ...
@@ -0,0 +1,21 @@
0
+package hcsshim
1
+
2
+import "github.com/Sirupsen/logrus"
3
+
4
+// StartComputeSystem starts a container that has previously been created via
5
+// CreateComputeSystem.
6
+func StartComputeSystem(id string) error {
7
+
8
+	title := "HCSShim::StartComputeSystem"
9
+	logrus.Debugf(title+" id=%s", id)
10
+
11
+	err := startComputeSystem(id)
12
+	if err != nil {
13
+		err = makeErrorf(err, title, "id=%s", id)
14
+		logrus.Error(err)
15
+		return err
16
+	}
17
+
18
+	logrus.Debugf(title+" succeeded id=%s", id)
19
+	return nil
20
+}
0 21
new file mode 100644
... ...
@@ -0,0 +1,20 @@
0
+package hcsshim
1
+
2
+import "github.com/Sirupsen/logrus"
3
+
4
+// TerminateProcessInComputeSystem kills a process in a running container.
5
+func TerminateProcessInComputeSystem(id string, processid uint32) (err error) {
6
+
7
+	title := "HCSShim::TerminateProcessInComputeSystem"
8
+	logrus.Debugf(title+" id=%s processid=%d", id, processid)
9
+
10
+	err = terminateProcessInComputeSystem(id, processid)
11
+	if err != nil {
12
+		err = makeErrorf(err, title, "err=%s id=%s", id)
13
+		logrus.Error(err)
14
+		return err
15
+	}
16
+
17
+	logrus.Debugf(title+" succeeded id=%s", id)
18
+	return nil
19
+}
0 20
new file mode 100644
... ...
@@ -0,0 +1,27 @@
0
+package hcsshim
1
+
2
+import "github.com/Sirupsen/logrus"
3
+
4
+// UnprepareLayer disables the filesystem filter for the read-write layer with
5
+// the given id.
6
+func UnprepareLayer(info DriverInfo, layerId string) error {
7
+	title := "hcsshim::UnprepareLayer "
8
+	logrus.Debugf(title+"flavour %d layerId %s", info.Flavour, layerId)
9
+
10
+	// Convert info to API calling convention
11
+	infop, err := convertDriverInfo(info)
12
+	if err != nil {
13
+		logrus.Error(err)
14
+		return err
15
+	}
16
+
17
+	err = unprepareLayer(&infop, layerId)
18
+	if err != nil {
19
+		err = makeErrorf(err, title, "layerId=%s flavour=%d", layerId, info.Flavour)
20
+		logrus.Error(err)
21
+		return err
22
+	}
23
+
24
+	logrus.Debugf(title+"succeeded flavour %d layerId=%s", info.Flavour, layerId)
25
+	return nil
26
+}
0 27
new file mode 100644
... ...
@@ -0,0 +1,21 @@
0
+package hcsshim
1
+
2
+import "github.com/Sirupsen/logrus"
3
+
4
+// WaitForProcessInComputeSystem waits for a process ID to terminate and returns
5
+// the exit code. Returns exitcode, errno, error
6
+func WaitForProcessInComputeSystem(id string, processid uint32, timeout uint32) (int32, uint32, error) {
7
+
8
+	title := "HCSShim::WaitForProcessInComputeSystem"
9
+	logrus.Debugf(title+" id=%s processid=%d", id, processid)
10
+
11
+	var exitCode uint32
12
+	err := waitForProcessInComputeSystem(id, processid, timeout, &exitCode)
13
+	if err != nil {
14
+		err := makeErrorf(err, title, "id=%s", id)
15
+		return 0, err.HResult(), err
16
+	}
17
+
18
+	logrus.Debugf(title+" succeeded id=%s processid=%d exitcode=%d", id, processid, exitCode)
19
+	return int32(exitCode), 0, nil
20
+}
0 21
new file mode 100644
... ...
@@ -0,0 +1,559 @@
0
+// MACHINE GENERATED BY 'go generate' COMMAND; DO NOT EDIT
1
+
2
+package hcsshim
3
+
4
+import "unsafe"
5
+import "syscall"
6
+
7
+var _ unsafe.Pointer
8
+
9
+var (
10
+	modole32     = syscall.NewLazyDLL("ole32.dll")
11
+	modvmcompute = syscall.NewLazyDLL("vmcompute.dll")
12
+
13
+	procCoTaskMemFree                              = modole32.NewProc("CoTaskMemFree")
14
+	procActivateLayer                              = modvmcompute.NewProc("ActivateLayer")
15
+	procCopyLayer                                  = modvmcompute.NewProc("CopyLayer")
16
+	procCreateLayer                                = modvmcompute.NewProc("CreateLayer")
17
+	procCreateSandboxLayer                         = modvmcompute.NewProc("CreateSandboxLayer")
18
+	procDeactivateLayer                            = modvmcompute.NewProc("DeactivateLayer")
19
+	procDestroyLayer                               = modvmcompute.NewProc("DestroyLayer")
20
+	procExportLayer                                = modvmcompute.NewProc("ExportLayer")
21
+	procGetLayerMountPath                          = modvmcompute.NewProc("GetLayerMountPath")
22
+	procGetBaseImages                              = modvmcompute.NewProc("GetBaseImages")
23
+	procImportLayer                                = modvmcompute.NewProc("ImportLayer")
24
+	procLayerExists                                = modvmcompute.NewProc("LayerExists")
25
+	procNameToGuid                                 = modvmcompute.NewProc("NameToGuid")
26
+	procPrepareLayer                               = modvmcompute.NewProc("PrepareLayer")
27
+	procUnprepareLayer                             = modvmcompute.NewProc("UnprepareLayer")
28
+	procCreateComputeSystem                        = modvmcompute.NewProc("CreateComputeSystem")
29
+	procCreateProcessWithStdHandlesInComputeSystem = modvmcompute.NewProc("CreateProcessWithStdHandlesInComputeSystem")
30
+	procResizeConsoleInComputeSystem               = modvmcompute.NewProc("ResizeConsoleInComputeSystem")
31
+	procShutdownComputeSystem                      = modvmcompute.NewProc("ShutdownComputeSystem")
32
+	procStartComputeSystem                         = modvmcompute.NewProc("StartComputeSystem")
33
+	procTerminateComputeSystem                     = modvmcompute.NewProc("TerminateComputeSystem")
34
+	procTerminateProcessInComputeSystem            = modvmcompute.NewProc("TerminateProcessInComputeSystem")
35
+	procWaitForProcessInComputeSystem              = modvmcompute.NewProc("WaitForProcessInComputeSystem")
36
+	procHNSCall                                    = modvmcompute.NewProc("HNSCall")
37
+)
38
+
39
+func coTaskMemFree(buffer unsafe.Pointer) {
40
+	syscall.Syscall(procCoTaskMemFree.Addr(), 1, uintptr(buffer), 0, 0)
41
+	return
42
+}
43
+
44
+func activateLayer(info *driverInfo, id string) (hr error) {
45
+	var _p0 *uint16
46
+	_p0, hr = syscall.UTF16PtrFromString(id)
47
+	if hr != nil {
48
+		return
49
+	}
50
+	return _activateLayer(info, _p0)
51
+}
52
+
53
+func _activateLayer(info *driverInfo, id *uint16) (hr error) {
54
+	if hr = procActivateLayer.Find(); hr != nil {
55
+		return
56
+	}
57
+	r0, _, _ := syscall.Syscall(procActivateLayer.Addr(), 2, uintptr(unsafe.Pointer(info)), uintptr(unsafe.Pointer(id)), 0)
58
+	if r0 != 0 {
59
+		hr = syscall.Errno(r0)
60
+	}
61
+	return
62
+}
63
+
64
+func copyLayer(info *driverInfo, srcId string, dstId string, descriptors []WC_LAYER_DESCRIPTOR) (hr error) {
65
+	var _p0 *uint16
66
+	_p0, hr = syscall.UTF16PtrFromString(srcId)
67
+	if hr != nil {
68
+		return
69
+	}
70
+	var _p1 *uint16
71
+	_p1, hr = syscall.UTF16PtrFromString(dstId)
72
+	if hr != nil {
73
+		return
74
+	}
75
+	return _copyLayer(info, _p0, _p1, descriptors)
76
+}
77
+
78
+func _copyLayer(info *driverInfo, srcId *uint16, dstId *uint16, descriptors []WC_LAYER_DESCRIPTOR) (hr error) {
79
+	var _p2 *WC_LAYER_DESCRIPTOR
80
+	if len(descriptors) > 0 {
81
+		_p2 = &descriptors[0]
82
+	}
83
+	if hr = procCopyLayer.Find(); hr != nil {
84
+		return
85
+	}
86
+	r0, _, _ := syscall.Syscall6(procCopyLayer.Addr(), 5, uintptr(unsafe.Pointer(info)), uintptr(unsafe.Pointer(srcId)), uintptr(unsafe.Pointer(dstId)), uintptr(unsafe.Pointer(_p2)), uintptr(len(descriptors)), 0)
87
+	if r0 != 0 {
88
+		hr = syscall.Errno(r0)
89
+	}
90
+	return
91
+}
92
+
93
+func createLayer(info *driverInfo, id string, parent string) (hr error) {
94
+	var _p0 *uint16
95
+	_p0, hr = syscall.UTF16PtrFromString(id)
96
+	if hr != nil {
97
+		return
98
+	}
99
+	var _p1 *uint16
100
+	_p1, hr = syscall.UTF16PtrFromString(parent)
101
+	if hr != nil {
102
+		return
103
+	}
104
+	return _createLayer(info, _p0, _p1)
105
+}
106
+
107
+func _createLayer(info *driverInfo, id *uint16, parent *uint16) (hr error) {
108
+	if hr = procCreateLayer.Find(); hr != nil {
109
+		return
110
+	}
111
+	r0, _, _ := syscall.Syscall(procCreateLayer.Addr(), 3, uintptr(unsafe.Pointer(info)), uintptr(unsafe.Pointer(id)), uintptr(unsafe.Pointer(parent)))
112
+	if r0 != 0 {
113
+		hr = syscall.Errno(r0)
114
+	}
115
+	return
116
+}
117
+
118
+func createSandboxLayer(info *driverInfo, id string, parent string, descriptors []WC_LAYER_DESCRIPTOR) (hr error) {
119
+	var _p0 *uint16
120
+	_p0, hr = syscall.UTF16PtrFromString(id)
121
+	if hr != nil {
122
+		return
123
+	}
124
+	var _p1 *uint16
125
+	_p1, hr = syscall.UTF16PtrFromString(parent)
126
+	if hr != nil {
127
+		return
128
+	}
129
+	return _createSandboxLayer(info, _p0, _p1, descriptors)
130
+}
131
+
132
+func _createSandboxLayer(info *driverInfo, id *uint16, parent *uint16, descriptors []WC_LAYER_DESCRIPTOR) (hr error) {
133
+	var _p2 *WC_LAYER_DESCRIPTOR
134
+	if len(descriptors) > 0 {
135
+		_p2 = &descriptors[0]
136
+	}
137
+	if hr = procCreateSandboxLayer.Find(); hr != nil {
138
+		return
139
+	}
140
+	r0, _, _ := syscall.Syscall6(procCreateSandboxLayer.Addr(), 5, uintptr(unsafe.Pointer(info)), uintptr(unsafe.Pointer(id)), uintptr(unsafe.Pointer(parent)), uintptr(unsafe.Pointer(_p2)), uintptr(len(descriptors)), 0)
141
+	if r0 != 0 {
142
+		hr = syscall.Errno(r0)
143
+	}
144
+	return
145
+}
146
+
147
+func deactivateLayer(info *driverInfo, id string) (hr error) {
148
+	var _p0 *uint16
149
+	_p0, hr = syscall.UTF16PtrFromString(id)
150
+	if hr != nil {
151
+		return
152
+	}
153
+	return _deactivateLayer(info, _p0)
154
+}
155
+
156
+func _deactivateLayer(info *driverInfo, id *uint16) (hr error) {
157
+	if hr = procDeactivateLayer.Find(); hr != nil {
158
+		return
159
+	}
160
+	r0, _, _ := syscall.Syscall(procDeactivateLayer.Addr(), 2, uintptr(unsafe.Pointer(info)), uintptr(unsafe.Pointer(id)), 0)
161
+	if r0 != 0 {
162
+		hr = syscall.Errno(r0)
163
+	}
164
+	return
165
+}
166
+
167
+func destroyLayer(info *driverInfo, id string) (hr error) {
168
+	var _p0 *uint16
169
+	_p0, hr = syscall.UTF16PtrFromString(id)
170
+	if hr != nil {
171
+		return
172
+	}
173
+	return _destroyLayer(info, _p0)
174
+}
175
+
176
+func _destroyLayer(info *driverInfo, id *uint16) (hr error) {
177
+	if hr = procDestroyLayer.Find(); hr != nil {
178
+		return
179
+	}
180
+	r0, _, _ := syscall.Syscall(procDestroyLayer.Addr(), 2, uintptr(unsafe.Pointer(info)), uintptr(unsafe.Pointer(id)), 0)
181
+	if r0 != 0 {
182
+		hr = syscall.Errno(r0)
183
+	}
184
+	return
185
+}
186
+
187
+func exportLayer(info *driverInfo, id string, path string, descriptors []WC_LAYER_DESCRIPTOR) (hr error) {
188
+	var _p0 *uint16
189
+	_p0, hr = syscall.UTF16PtrFromString(id)
190
+	if hr != nil {
191
+		return
192
+	}
193
+	var _p1 *uint16
194
+	_p1, hr = syscall.UTF16PtrFromString(path)
195
+	if hr != nil {
196
+		return
197
+	}
198
+	return _exportLayer(info, _p0, _p1, descriptors)
199
+}
200
+
201
+func _exportLayer(info *driverInfo, id *uint16, path *uint16, descriptors []WC_LAYER_DESCRIPTOR) (hr error) {
202
+	var _p2 *WC_LAYER_DESCRIPTOR
203
+	if len(descriptors) > 0 {
204
+		_p2 = &descriptors[0]
205
+	}
206
+	if hr = procExportLayer.Find(); hr != nil {
207
+		return
208
+	}
209
+	r0, _, _ := syscall.Syscall6(procExportLayer.Addr(), 5, uintptr(unsafe.Pointer(info)), uintptr(unsafe.Pointer(id)), uintptr(unsafe.Pointer(path)), uintptr(unsafe.Pointer(_p2)), uintptr(len(descriptors)), 0)
210
+	if r0 != 0 {
211
+		hr = syscall.Errno(r0)
212
+	}
213
+	return
214
+}
215
+
216
+func getLayerMountPath(info *driverInfo, id string, length *uintptr, buffer *uint16) (hr error) {
217
+	var _p0 *uint16
218
+	_p0, hr = syscall.UTF16PtrFromString(id)
219
+	if hr != nil {
220
+		return
221
+	}
222
+	return _getLayerMountPath(info, _p0, length, buffer)
223
+}
224
+
225
+func _getLayerMountPath(info *driverInfo, id *uint16, length *uintptr, buffer *uint16) (hr error) {
226
+	if hr = procGetLayerMountPath.Find(); hr != nil {
227
+		return
228
+	}
229
+	r0, _, _ := syscall.Syscall6(procGetLayerMountPath.Addr(), 4, uintptr(unsafe.Pointer(info)), uintptr(unsafe.Pointer(id)), uintptr(unsafe.Pointer(length)), uintptr(unsafe.Pointer(buffer)), 0, 0)
230
+	if r0 != 0 {
231
+		hr = syscall.Errno(r0)
232
+	}
233
+	return
234
+}
235
+
236
+func getBaseImages(buffer **uint16) (hr error) {
237
+	if hr = procGetBaseImages.Find(); hr != nil {
238
+		return
239
+	}
240
+	r0, _, _ := syscall.Syscall(procGetBaseImages.Addr(), 1, uintptr(unsafe.Pointer(buffer)), 0, 0)
241
+	if r0 != 0 {
242
+		hr = syscall.Errno(r0)
243
+	}
244
+	return
245
+}
246
+
247
+func importLayer(info *driverInfo, id string, path string, descriptors []WC_LAYER_DESCRIPTOR) (hr error) {
248
+	var _p0 *uint16
249
+	_p0, hr = syscall.UTF16PtrFromString(id)
250
+	if hr != nil {
251
+		return
252
+	}
253
+	var _p1 *uint16
254
+	_p1, hr = syscall.UTF16PtrFromString(path)
255
+	if hr != nil {
256
+		return
257
+	}
258
+	return _importLayer(info, _p0, _p1, descriptors)
259
+}
260
+
261
+func _importLayer(info *driverInfo, id *uint16, path *uint16, descriptors []WC_LAYER_DESCRIPTOR) (hr error) {
262
+	var _p2 *WC_LAYER_DESCRIPTOR
263
+	if len(descriptors) > 0 {
264
+		_p2 = &descriptors[0]
265
+	}
266
+	if hr = procImportLayer.Find(); hr != nil {
267
+		return
268
+	}
269
+	r0, _, _ := syscall.Syscall6(procImportLayer.Addr(), 5, uintptr(unsafe.Pointer(info)), uintptr(unsafe.Pointer(id)), uintptr(unsafe.Pointer(path)), uintptr(unsafe.Pointer(_p2)), uintptr(len(descriptors)), 0)
270
+	if r0 != 0 {
271
+		hr = syscall.Errno(r0)
272
+	}
273
+	return
274
+}
275
+
276
+func layerExists(info *driverInfo, id string, exists *uint32) (hr error) {
277
+	var _p0 *uint16
278
+	_p0, hr = syscall.UTF16PtrFromString(id)
279
+	if hr != nil {
280
+		return
281
+	}
282
+	return _layerExists(info, _p0, exists)
283
+}
284
+
285
+func _layerExists(info *driverInfo, id *uint16, exists *uint32) (hr error) {
286
+	if hr = procLayerExists.Find(); hr != nil {
287
+		return
288
+	}
289
+	r0, _, _ := syscall.Syscall(procLayerExists.Addr(), 3, uintptr(unsafe.Pointer(info)), uintptr(unsafe.Pointer(id)), uintptr(unsafe.Pointer(exists)))
290
+	if r0 != 0 {
291
+		hr = syscall.Errno(r0)
292
+	}
293
+	return
294
+}
295
+
296
+func nameToGuid(name string, guid *GUID) (hr error) {
297
+	var _p0 *uint16
298
+	_p0, hr = syscall.UTF16PtrFromString(name)
299
+	if hr != nil {
300
+		return
301
+	}
302
+	return _nameToGuid(_p0, guid)
303
+}
304
+
305
+func _nameToGuid(name *uint16, guid *GUID) (hr error) {
306
+	if hr = procNameToGuid.Find(); hr != nil {
307
+		return
308
+	}
309
+	r0, _, _ := syscall.Syscall(procNameToGuid.Addr(), 2, uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(guid)), 0)
310
+	if r0 != 0 {
311
+		hr = syscall.Errno(r0)
312
+	}
313
+	return
314
+}
315
+
316
+func prepareLayer(info *driverInfo, id string, descriptors []WC_LAYER_DESCRIPTOR) (hr error) {
317
+	var _p0 *uint16
318
+	_p0, hr = syscall.UTF16PtrFromString(id)
319
+	if hr != nil {
320
+		return
321
+	}
322
+	return _prepareLayer(info, _p0, descriptors)
323
+}
324
+
325
+func _prepareLayer(info *driverInfo, id *uint16, descriptors []WC_LAYER_DESCRIPTOR) (hr error) {
326
+	var _p1 *WC_LAYER_DESCRIPTOR
327
+	if len(descriptors) > 0 {
328
+		_p1 = &descriptors[0]
329
+	}
330
+	if hr = procPrepareLayer.Find(); hr != nil {
331
+		return
332
+	}
333
+	r0, _, _ := syscall.Syscall6(procPrepareLayer.Addr(), 4, uintptr(unsafe.Pointer(info)), uintptr(unsafe.Pointer(id)), uintptr(unsafe.Pointer(_p1)), uintptr(len(descriptors)), 0, 0)
334
+	if r0 != 0 {
335
+		hr = syscall.Errno(r0)
336
+	}
337
+	return
338
+}
339
+
340
+func unprepareLayer(info *driverInfo, id string) (hr error) {
341
+	var _p0 *uint16
342
+	_p0, hr = syscall.UTF16PtrFromString(id)
343
+	if hr != nil {
344
+		return
345
+	}
346
+	return _unprepareLayer(info, _p0)
347
+}
348
+
349
+func _unprepareLayer(info *driverInfo, id *uint16) (hr error) {
350
+	if hr = procUnprepareLayer.Find(); hr != nil {
351
+		return
352
+	}
353
+	r0, _, _ := syscall.Syscall(procUnprepareLayer.Addr(), 2, uintptr(unsafe.Pointer(info)), uintptr(unsafe.Pointer(id)), 0)
354
+	if r0 != 0 {
355
+		hr = syscall.Errno(r0)
356
+	}
357
+	return
358
+}
359
+
360
+func createComputeSystem(id string, configuration string) (hr error) {
361
+	var _p0 *uint16
362
+	_p0, hr = syscall.UTF16PtrFromString(id)
363
+	if hr != nil {
364
+		return
365
+	}
366
+	var _p1 *uint16
367
+	_p1, hr = syscall.UTF16PtrFromString(configuration)
368
+	if hr != nil {
369
+		return
370
+	}
371
+	return _createComputeSystem(_p0, _p1)
372
+}
373
+
374
+func _createComputeSystem(id *uint16, configuration *uint16) (hr error) {
375
+	if hr = procCreateComputeSystem.Find(); hr != nil {
376
+		return
377
+	}
378
+	r0, _, _ := syscall.Syscall(procCreateComputeSystem.Addr(), 2, uintptr(unsafe.Pointer(id)), uintptr(unsafe.Pointer(configuration)), 0)
379
+	if r0 != 0 {
380
+		hr = syscall.Errno(r0)
381
+	}
382
+	return
383
+}
384
+
385
+func createProcessWithStdHandlesInComputeSystem(id string, paramsJson string, pid *uint32, stdin *syscall.Handle, stdout *syscall.Handle, stderr *syscall.Handle) (hr error) {
386
+	var _p0 *uint16
387
+	_p0, hr = syscall.UTF16PtrFromString(id)
388
+	if hr != nil {
389
+		return
390
+	}
391
+	var _p1 *uint16
392
+	_p1, hr = syscall.UTF16PtrFromString(paramsJson)
393
+	if hr != nil {
394
+		return
395
+	}
396
+	return _createProcessWithStdHandlesInComputeSystem(_p0, _p1, pid, stdin, stdout, stderr)
397
+}
398
+
399
+func _createProcessWithStdHandlesInComputeSystem(id *uint16, paramsJson *uint16, pid *uint32, stdin *syscall.Handle, stdout *syscall.Handle, stderr *syscall.Handle) (hr error) {
400
+	if hr = procCreateProcessWithStdHandlesInComputeSystem.Find(); hr != nil {
401
+		return
402
+	}
403
+	r0, _, _ := syscall.Syscall6(procCreateProcessWithStdHandlesInComputeSystem.Addr(), 6, uintptr(unsafe.Pointer(id)), uintptr(unsafe.Pointer(paramsJson)), uintptr(unsafe.Pointer(pid)), uintptr(unsafe.Pointer(stdin)), uintptr(unsafe.Pointer(stdout)), uintptr(unsafe.Pointer(stderr)))
404
+	if r0 != 0 {
405
+		hr = syscall.Errno(r0)
406
+	}
407
+	return
408
+}
409
+
410
+func resizeConsoleInComputeSystem(id string, pid uint32, height uint16, width uint16, flags uint32) (hr error) {
411
+	var _p0 *uint16
412
+	_p0, hr = syscall.UTF16PtrFromString(id)
413
+	if hr != nil {
414
+		return
415
+	}
416
+	return _resizeConsoleInComputeSystem(_p0, pid, height, width, flags)
417
+}
418
+
419
+func _resizeConsoleInComputeSystem(id *uint16, pid uint32, height uint16, width uint16, flags uint32) (hr error) {
420
+	if hr = procResizeConsoleInComputeSystem.Find(); hr != nil {
421
+		return
422
+	}
423
+	r0, _, _ := syscall.Syscall6(procResizeConsoleInComputeSystem.Addr(), 5, uintptr(unsafe.Pointer(id)), uintptr(pid), uintptr(height), uintptr(width), uintptr(flags), 0)
424
+	if r0 != 0 {
425
+		hr = syscall.Errno(r0)
426
+	}
427
+	return
428
+}
429
+
430
+func shutdownComputeSystem(id string, timeout uint32) (hr error) {
431
+	var _p0 *uint16
432
+	_p0, hr = syscall.UTF16PtrFromString(id)
433
+	if hr != nil {
434
+		return
435
+	}
436
+	return _shutdownComputeSystem(_p0, timeout)
437
+}
438
+
439
+func _shutdownComputeSystem(id *uint16, timeout uint32) (hr error) {
440
+	if hr = procShutdownComputeSystem.Find(); hr != nil {
441
+		return
442
+	}
443
+	r0, _, _ := syscall.Syscall(procShutdownComputeSystem.Addr(), 2, uintptr(unsafe.Pointer(id)), uintptr(timeout), 0)
444
+	if r0 != 0 {
445
+		hr = syscall.Errno(r0)
446
+	}
447
+	return
448
+}
449
+
450
+func startComputeSystem(id string) (hr error) {
451
+	var _p0 *uint16
452
+	_p0, hr = syscall.UTF16PtrFromString(id)
453
+	if hr != nil {
454
+		return
455
+	}
456
+	return _startComputeSystem(_p0)
457
+}
458
+
459
+func _startComputeSystem(id *uint16) (hr error) {
460
+	if hr = procStartComputeSystem.Find(); hr != nil {
461
+		return
462
+	}
463
+	r0, _, _ := syscall.Syscall(procStartComputeSystem.Addr(), 1, uintptr(unsafe.Pointer(id)), 0, 0)
464
+	if r0 != 0 {
465
+		hr = syscall.Errno(r0)
466
+	}
467
+	return
468
+}
469
+
470
+func terminateComputeSystem(id string) (hr error) {
471
+	var _p0 *uint16
472
+	_p0, hr = syscall.UTF16PtrFromString(id)
473
+	if hr != nil {
474
+		return
475
+	}
476
+	return _terminateComputeSystem(_p0)
477
+}
478
+
479
+func _terminateComputeSystem(id *uint16) (hr error) {
480
+	if hr = procTerminateComputeSystem.Find(); hr != nil {
481
+		return
482
+	}
483
+	r0, _, _ := syscall.Syscall(procTerminateComputeSystem.Addr(), 1, uintptr(unsafe.Pointer(id)), 0, 0)
484
+	if r0 != 0 {
485
+		hr = syscall.Errno(r0)
486
+	}
487
+	return
488
+}
489
+
490
+func terminateProcessInComputeSystem(id string, pid uint32) (hr error) {
491
+	var _p0 *uint16
492
+	_p0, hr = syscall.UTF16PtrFromString(id)
493
+	if hr != nil {
494
+		return
495
+	}
496
+	return _terminateProcessInComputeSystem(_p0, pid)
497
+}
498
+
499
+func _terminateProcessInComputeSystem(id *uint16, pid uint32) (hr error) {
500
+	if hr = procTerminateProcessInComputeSystem.Find(); hr != nil {
501
+		return
502
+	}
503
+	r0, _, _ := syscall.Syscall(procTerminateProcessInComputeSystem.Addr(), 2, uintptr(unsafe.Pointer(id)), uintptr(pid), 0)
504
+	if r0 != 0 {
505
+		hr = syscall.Errno(r0)
506
+	}
507
+	return
508
+}
509
+
510
+func waitForProcessInComputeSystem(id string, pid uint32, timeout uint32, exitCode *uint32) (hr error) {
511
+	var _p0 *uint16
512
+	_p0, hr = syscall.UTF16PtrFromString(id)
513
+	if hr != nil {
514
+		return
515
+	}
516
+	return _waitForProcessInComputeSystem(_p0, pid, timeout, exitCode)
517
+}
518
+
519
+func _waitForProcessInComputeSystem(id *uint16, pid uint32, timeout uint32, exitCode *uint32) (hr error) {
520
+	if hr = procWaitForProcessInComputeSystem.Find(); hr != nil {
521
+		return
522
+	}
523
+	r0, _, _ := syscall.Syscall6(procWaitForProcessInComputeSystem.Addr(), 4, uintptr(unsafe.Pointer(id)), uintptr(pid), uintptr(timeout), uintptr(unsafe.Pointer(exitCode)), 0, 0)
524
+	if r0 != 0 {
525
+		hr = syscall.Errno(r0)
526
+	}
527
+	return
528
+}
529
+
530
+func _hnsCall(method string, path string, object string, response **uint16) (hr error) {
531
+	var _p0 *uint16
532
+	_p0, hr = syscall.UTF16PtrFromString(method)
533
+	if hr != nil {
534
+		return
535
+	}
536
+	var _p1 *uint16
537
+	_p1, hr = syscall.UTF16PtrFromString(path)
538
+	if hr != nil {
539
+		return
540
+	}
541
+	var _p2 *uint16
542
+	_p2, hr = syscall.UTF16PtrFromString(object)
543
+	if hr != nil {
544
+		return
545
+	}
546
+	return __hnsCall(_p0, _p1, _p2, response)
547
+}
548
+
549
+func __hnsCall(method *uint16, path *uint16, object *uint16, response **uint16) (hr error) {
550
+	if hr = procHNSCall.Find(); hr != nil {
551
+		return
552
+	}
553
+	r0, _, _ := syscall.Syscall6(procHNSCall.Addr(), 4, uintptr(unsafe.Pointer(method)), uintptr(unsafe.Pointer(path)), uintptr(unsafe.Pointer(object)), uintptr(unsafe.Pointer(response)), 0, 0)
554
+	if r0 != 0 {
555
+		hr = syscall.Errno(r0)
556
+	}
557
+	return
558
+}
0 559
deleted file mode 100644
... ...
@@ -1,22 +0,0 @@
1
-The MIT License (MIT)
2
-
3
-Copyright (c) 2015 Microsoft
4
-
5
-Permission is hereby granted, free of charge, to any person obtaining a copy
6
-of this software and associated documentation files (the "Software"), to deal
7
-in the Software without restriction, including without limitation the rights
8
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
-copies of the Software, and to permit persons to whom the Software is
10
-furnished to do so, subject to the following conditions:
11
-
12
-The above copyright notice and this permission notice shall be included in all
13
-copies or substantial portions of the Software.
14
-
15
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
-SOFTWARE.
22
-
23 1
deleted file mode 100644
... ...
@@ -1,28 +0,0 @@
1
-package hcsshim
2
-
3
-import "github.com/Sirupsen/logrus"
4
-
5
-// ActivateLayer will find the layer with the given id and mount it's filesystem.
6
-// For a read/write layer, the mounted filesystem will appear as a volume on the
7
-// host, while a read-only layer is generally expected to be a no-op.
8
-// An activated layer must later be deactivated via DeactivateLayer.
9
-func ActivateLayer(info DriverInfo, id string) error {
10
-	title := "hcsshim::ActivateLayer "
11
-	logrus.Debugf(title+"Flavour %d ID %s", info.Flavour, id)
12
-
13
-	infop, err := convertDriverInfo(info)
14
-	if err != nil {
15
-		logrus.Error(err)
16
-		return err
17
-	}
18
-
19
-	err = activateLayer(&infop, id)
20
-	if err != nil {
21
-		err = makeErrorf(err, title, "id=%s flavour=%d", id, info.Flavour)
22
-		logrus.Error(err)
23
-		return err
24
-	}
25
-
26
-	logrus.Debugf(title+" - succeeded id=%s flavour=%d", id, info.Flavour)
27
-	return nil
28
-}
29 1
deleted file mode 100644
... ...
@@ -1,34 +0,0 @@
1
-package hcsshim
2
-
3
-import "github.com/Sirupsen/logrus"
4
-
5
-// CopyLayer performs a commit of the srcId (which is expected to be a read-write
6
-// layer) into a new read-only layer at dstId.  This requires the full list of
7
-// on-disk paths to parent layers, provided in parentLayerPaths, in order to
8
-// complete the commit.
9
-func CopyLayer(info DriverInfo, srcId, dstId string, parentLayerPaths []string) error {
10
-	title := "hcsshim::CopyLayer "
11
-	logrus.Debugf(title+"srcId %s dstId", srcId, dstId)
12
-
13
-	// Generate layer descriptors
14
-	layers, err := layerPathsToDescriptors(parentLayerPaths)
15
-	if err != nil {
16
-		return err
17
-	}
18
-
19
-	// Convert info to API calling convention
20
-	infop, err := convertDriverInfo(info)
21
-	if err != nil {
22
-		return err
23
-	}
24
-
25
-	err = copyLayer(&infop, srcId, dstId, layers)
26
-	if err != nil {
27
-		err = makeErrorf(err, title, "srcId=%s dstId=%d", srcId, dstId)
28
-		logrus.Error(err)
29
-		return err
30
-	}
31
-
32
-	logrus.Debugf(title+" - succeeded srcId=%s dstId=%s", srcId, dstId)
33
-	return nil
34
-}
35 1
deleted file mode 100644
... ...
@@ -1,22 +0,0 @@
1
-package hcsshim
2
-
3
-import "github.com/Sirupsen/logrus"
4
-
5
-// CreateComputeSystem creates a container, initializing its configuration in
6
-// the Host Compute Service such that it can be started by a call to the
7
-// StartComputeSystem method.
8
-func CreateComputeSystem(id string, configuration string) error {
9
-
10
-	title := "HCSShim::CreateComputeSystem"
11
-	logrus.Debugln(title+" id=%s, configuration=%s", id, configuration)
12
-
13
-	err := createComputeSystem(id, configuration)
14
-	if err != nil {
15
-		err = makeErrorf(err, title, "id=%s configuration=%s", id, configuration)
16
-		logrus.Error(err)
17
-		return err
18
-	}
19
-
20
-	logrus.Debugf(title+"- succeeded %s", id)
21
-	return nil
22
-}
23 1
deleted file mode 100644
... ...
@@ -1,27 +0,0 @@
1
-package hcsshim
2
-
3
-import "github.com/Sirupsen/logrus"
4
-
5
-// CreateLayer creates a new, empty, read-only layer on the filesystem based on
6
-// the parent layer provided.
7
-func CreateLayer(info DriverInfo, id, parent string) error {
8
-	title := "hcsshim::CreateLayer "
9
-	logrus.Debugf(title+"Flavour %d ID %s parent %s", info.Flavour, id, parent)
10
-
11
-	// Convert info to API calling convention
12
-	infop, err := convertDriverInfo(info)
13
-	if err != nil {
14
-		logrus.Error(err)
15
-		return err
16
-	}
17
-
18
-	err = createLayer(&infop, id, parent)
19
-	if err != nil {
20
-		err = makeErrorf(err, title, "id=%s parent=%s flavour=%d", id, parent, info.Flavour)
21
-		logrus.Error(err)
22
-		return err
23
-	}
24
-
25
-	logrus.Debugf(title+" - succeeded id=%s parent=%s flavour=%d", id, parent, info.Flavour)
26
-	return nil
27
-}
28 1
deleted file mode 100644
... ...
@@ -1,103 +0,0 @@
1
-package hcsshim
2
-
3
-import (
4
-	"encoding/json"
5
-	"io"
6
-	"syscall"
7
-
8
-	"github.com/Microsoft/go-winio"
9
-	"github.com/Sirupsen/logrus"
10
-)
11
-
12
-// CreateProcessParams is used as both the input of CreateProcessInComputeSystem
13
-// and to convert the parameters to JSON for passing onto the HCS
14
-type CreateProcessParams struct {
15
-	ApplicationName  string
16
-	CommandLine      string
17
-	WorkingDirectory string
18
-	Environment      map[string]string
19
-	EmulateConsole   bool
20
-	ConsoleSize      [2]int
21
-}
22
-
23
-// makeOpenFiles calls winio.MakeOpenFile for each handle in a slice but closes all the handles
24
-// if there is an error.
25
-func makeOpenFiles(hs []syscall.Handle) (_ []io.ReadWriteCloser, err error) {
26
-	fs := make([]io.ReadWriteCloser, len(hs))
27
-	for i, h := range hs {
28
-		if h != syscall.Handle(0) {
29
-			if err == nil {
30
-				fs[i], err = winio.MakeOpenFile(h)
31
-			}
32
-			if err != nil {
33
-				syscall.Close(h)
34
-			}
35
-		}
36
-	}
37
-	if err != nil {
38
-		for _, f := range fs {
39
-			if f != nil {
40
-				f.Close()
41
-			}
42
-		}
43
-		return nil, err
44
-	}
45
-	return fs, nil
46
-}
47
-
48
-// CreateProcessInComputeSystem starts a process in a container. This is invoked, for example,
49
-// as a result of docker run, docker exec, or RUN in Dockerfile. If successful,
50
-// it returns the PID of the process.
51
-func CreateProcessInComputeSystem(id string, useStdin bool, useStdout bool, useStderr bool, params CreateProcessParams) (_ uint32, _ io.WriteCloser, _ io.ReadCloser, _ io.ReadCloser, hr uint32, err error) {
52
-	title := "HCSShim::CreateProcessInComputeSystem"
53
-	logrus.Debugf(title+" id=%s", id)
54
-	hr = 0xFFFFFFFF
55
-
56
-	// If we are not emulating a console, ignore any console size passed to us
57
-	if !params.EmulateConsole {
58
-		params.ConsoleSize[0] = 0
59
-		params.ConsoleSize[1] = 0
60
-	}
61
-
62
-	paramsJson, err := json.Marshal(params)
63
-	if err != nil {
64
-		return
65
-	}
66
-
67
-	logrus.Debugf(title+" - Calling Win32 %s %s", id, paramsJson)
68
-
69
-	var pid uint32
70
-
71
-	handles := make([]syscall.Handle, 3)
72
-	var stdinParam, stdoutParam, stderrParam *syscall.Handle
73
-	if useStdin {
74
-		stdinParam = &handles[0]
75
-	}
76
-	if useStdout {
77
-		stdoutParam = &handles[1]
78
-	}
79
-	if useStderr {
80
-		stderrParam = &handles[2]
81
-	}
82
-
83
-	err = createProcessWithStdHandlesInComputeSystem(id, string(paramsJson), &pid, stdinParam, stdoutParam, stderrParam)
84
-	if err != nil {
85
-		winerr := makeErrorf(err, title, "id=%s params=%v", id, params)
86
-		hr = winerr.HResult()
87
-		// Windows TP4: Hyper-V Containers may return this error with more than one
88
-		// concurrent exec. Do not log it as an error
89
-		if hr != Win32InvalidArgument {
90
-			logrus.Error(winerr)
91
-		}
92
-		err = winerr
93
-		return
94
-	}
95
-
96
-	pipes, err := makeOpenFiles(handles)
97
-	if err != nil {
98
-		return
99
-	}
100
-
101
-	logrus.Debugf(title+" - succeeded id=%s params=%s pid=%d", id, paramsJson, pid)
102
-	return pid, pipes[0], pipes[1], pipes[2], 0, nil
103
-}
104 1
deleted file mode 100644
... ...
@@ -1,35 +0,0 @@
1
-package hcsshim
2
-
3
-import "github.com/Sirupsen/logrus"
4
-
5
-// CreateSandboxLayer creates and populates new read-write layer for use by a container.
6
-// This requires both the id of the direct parent layer, as well as the full list
7
-// of paths to all parent layers up to the base (and including the direct parent
8
-// whose id was provided).
9
-func CreateSandboxLayer(info DriverInfo, layerId, parentId string, parentLayerPaths []string) error {
10
-	title := "hcsshim::CreateSandboxLayer "
11
-	logrus.Debugf(title+"layerId %s parentId %s", layerId, parentId)
12
-
13
-	// Generate layer descriptors
14
-	layers, err := layerPathsToDescriptors(parentLayerPaths)
15
-	if err != nil {
16
-		return err
17
-	}
18
-
19
-	// Convert info to API calling convention
20
-	infop, err := convertDriverInfo(info)
21
-	if err != nil {
22
-		logrus.Error(err)
23
-		return err
24
-	}
25
-
26
-	err = createSandboxLayer(&infop, layerId, parentId, layers)
27
-	if err != nil {
28
-		err = makeErrorf(err, title, "layerId=%s parentId=%s", layerId, parentId)
29
-		logrus.Error(err)
30
-		return err
31
-	}
32
-
33
-	logrus.Debugf(title+"- succeeded layerId=%s parentId=%s", layerId, parentId)
34
-	return nil
35
-}
36 1
deleted file mode 100644
... ...
@@ -1,26 +0,0 @@
1
-package hcsshim
2
-
3
-import "github.com/Sirupsen/logrus"
4
-
5
-// DeactivateLayer will dismount a layer that was mounted via ActivateLayer.
6
-func DeactivateLayer(info DriverInfo, id string) error {
7
-	title := "hcsshim::DeactivateLayer "
8
-	logrus.Debugf(title+"Flavour %d ID %s", info.Flavour, id)
9
-
10
-	// Convert info to API calling convention
11
-	infop, err := convertDriverInfo(info)
12
-	if err != nil {
13
-		logrus.Error(err)
14
-		return err
15
-	}
16
-
17
-	err = deactivateLayer(&infop, id)
18
-	if err != nil {
19
-		err = makeErrorf(err, title, "id=%s flavour=%d", id, info.Flavour)
20
-		logrus.Error(err)
21
-		return err
22
-	}
23
-
24
-	logrus.Debugf(title+"succeeded flavour=%d id=%s", info.Flavour, id)
25
-	return nil
26
-}
27 1
deleted file mode 100644
... ...
@@ -1,27 +0,0 @@
1
-package hcsshim
2
-
3
-import "github.com/Sirupsen/logrus"
4
-
5
-// DestroyLayer will remove the on-disk files representing the layer with the given
6
-// id, including that layer's containing folder, if any.
7
-func DestroyLayer(info DriverInfo, id string) error {
8
-	title := "hcsshim::DestroyLayer "
9
-	logrus.Debugf(title+"Flavour %d ID %s", info.Flavour, id)
10
-
11
-	// Convert info to API calling convention
12
-	infop, err := convertDriverInfo(info)
13
-	if err != nil {
14
-		logrus.Error(err)
15
-		return err
16
-	}
17
-
18
-	err = destroyLayer(&infop, id)
19
-	if err != nil {
20
-		err = makeErrorf(err, title, "id=%s flavour=%d", id, info.Flavour)
21
-		logrus.Error(err)
22
-		return err
23
-	}
24
-
25
-	logrus.Debugf(title+"succeeded flavour=%d id=%s", info.Flavour, id)
26
-	return nil
27
-}
28 1
deleted file mode 100644
... ...
@@ -1,36 +0,0 @@
1
-package hcsshim
2
-
3
-import "github.com/Sirupsen/logrus"
4
-
5
-// ExportLayer will create a folder at exportFolderPath and fill that folder with
6
-// the transport format version of the layer identified by layerId. This transport
7
-// format includes any metadata required for later importing the layer (using
8
-// ImportLayer), and requires the full list of parent layer paths in order to
9
-// perform the export.
10
-func ExportLayer(info DriverInfo, layerId string, exportFolderPath string, parentLayerPaths []string) error {
11
-	title := "hcsshim::ExportLayer "
12
-	logrus.Debugf(title+"flavour %d layerId %s folder %s", info.Flavour, layerId, exportFolderPath)
13
-
14
-	// Generate layer descriptors
15
-	layers, err := layerPathsToDescriptors(parentLayerPaths)
16
-	if err != nil {
17
-		return err
18
-	}
19
-
20
-	// Convert info to API calling convention
21
-	infop, err := convertDriverInfo(info)
22
-	if err != nil {
23
-		logrus.Error(err)
24
-		return err
25
-	}
26
-
27
-	err = exportLayer(&infop, layerId, exportFolderPath, layers)
28
-	if err != nil {
29
-		err = makeErrorf(err, title, "layerId=%s flavour=%d folder=%s", layerId, info.Flavour, exportFolderPath)
30
-		logrus.Error(err)
31
-		return err
32
-	}
33
-
34
-	logrus.Debugf(title+"succeeded flavour=%d layerId=%s folder=%s", info.Flavour, layerId, exportFolderPath)
35
-	return nil
36
-}
37 1
deleted file mode 100644
... ...
@@ -1,55 +0,0 @@
1
-package hcsshim
2
-
3
-import (
4
-	"syscall"
5
-
6
-	"github.com/Sirupsen/logrus"
7
-)
8
-
9
-// GetLayerMountPath will look for a mounted layer with the given id and return
10
-// the path at which that layer can be accessed.  This path may be a volume path
11
-// if the layer is a mounted read-write layer, otherwise it is expected to be the
12
-// folder path at which the layer is stored.
13
-func GetLayerMountPath(info DriverInfo, id string) (string, error) {
14
-	title := "hcsshim::GetLayerMountPath "
15
-	logrus.Debugf(title+"Flavour %d ID %s", info.Flavour, id)
16
-
17
-	// Convert info to API calling convention
18
-	infop, err := convertDriverInfo(info)
19
-	if err != nil {
20
-		logrus.Error(err)
21
-		return "", err
22
-	}
23
-
24
-	var mountPathLength uintptr
25
-	mountPathLength = 0
26
-
27
-	// Call the procedure itself.
28
-	logrus.Debugf("Calling proc (1)")
29
-	err = getLayerMountPath(&infop, id, &mountPathLength, nil)
30
-	if err != nil {
31
-		err = makeErrorf(err, title, "(first call) id=%s flavour=%d", id, info.Flavour)
32
-		logrus.Error(err)
33
-		return "", err
34
-	}
35
-
36
-	// Allocate a mount path of the returned length.
37
-	if mountPathLength == 0 {
38
-		return "", nil
39
-	}
40
-	mountPathp := make([]uint16, mountPathLength)
41
-	mountPathp[0] = 0
42
-
43
-	// Call the procedure again
44
-	logrus.Debugf("Calling proc (2)")
45
-	err = getLayerMountPath(&infop, id, &mountPathLength, &mountPathp[0])
46
-	if err != nil {
47
-		err = makeErrorf(err, title, "(second call) id=%s flavour=%d", id, info.Flavour)
48
-		logrus.Error(err)
49
-		return "", err
50
-	}
51
-
52
-	path := syscall.UTF16ToString(mountPathp[0:])
53
-	logrus.Debugf(title+"succeeded flavour=%d id=%s path=%s", info.Flavour, id, path)
54
-	return path, nil
55
-}
56 1
deleted file mode 100644
... ...
@@ -1,22 +0,0 @@
1
-package hcsshim
2
-
3
-import "github.com/Sirupsen/logrus"
4
-
5
-// GetSharedBaseImages will enumerate the images stored in the common central
6
-// image store and return descriptive info about those images for the purpose
7
-// of registering them with the graphdriver, graph, and tagstore.
8
-func GetSharedBaseImages() (imageData string, err error) {
9
-	title := "hcsshim::GetSharedBaseImages "
10
-
11
-	logrus.Debugf("Calling proc")
12
-	var buffer *uint16
13
-	err = getBaseImages(&buffer)
14
-	if err != nil {
15
-		err = makeError(err, title, "")
16
-		logrus.Error(err)
17
-		return
18
-	}
19
-	imageData = convertAndFreeCoTaskMemString(buffer)
20
-	logrus.Debugf(title+" - succeeded output=%s", imageData)
21
-	return
22
-}
23 1
deleted file mode 100644
... ...
@@ -1,19 +0,0 @@
1
-package hcsshim
2
-
3
-import (
4
-	"crypto/sha1"
5
-	"fmt"
6
-)
7
-
8
-type GUID [16]byte
9
-
10
-func NewGUID(source string) *GUID {
11
-	h := sha1.Sum([]byte(source))
12
-	var g GUID
13
-	copy(g[0:], h[0:16])
14
-	return &g
15
-}
16
-
17
-func (g *GUID) ToString() string {
18
-	return fmt.Sprintf("%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x-%02x", g[3], g[2], g[1], g[0], g[5], g[4], g[7], g[6], g[8:10], g[10:])
19
-}
20 1
deleted file mode 100644
... ...
@@ -1,93 +0,0 @@
1
-// Shim for the Host Compute Service (HSC) to manage Windows Server
2
-// containers and Hyper-V containers.
3
-
4
-package hcsshim
5
-
6
-import (
7
-	"fmt"
8
-	"syscall"
9
-	"unsafe"
10
-)
11
-
12
-//go:generate go run mksyscall_windows.go -output zhcsshim.go hcsshim.go
13
-
14
-//sys coTaskMemFree(buffer unsafe.Pointer) = ole32.CoTaskMemFree
15
-
16
-//sys activateLayer(info *driverInfo, id string) (hr error) = vmcompute.ActivateLayer?
17
-//sys copyLayer(info *driverInfo, srcId string, dstId string, descriptors []WC_LAYER_DESCRIPTOR) (hr error) = vmcompute.CopyLayer?
18
-//sys createLayer(info *driverInfo, id string, parent string) (hr error) = vmcompute.CreateLayer?
19
-//sys createSandboxLayer(info *driverInfo, id string, parent string, descriptors []WC_LAYER_DESCRIPTOR) (hr error) = vmcompute.CreateSandboxLayer?
20
-//sys deactivateLayer(info *driverInfo, id string) (hr error) = vmcompute.DeactivateLayer?
21
-//sys destroyLayer(info *driverInfo, id string) (hr error) = vmcompute.DestroyLayer?
22
-//sys exportLayer(info *driverInfo, id string, path string, descriptors []WC_LAYER_DESCRIPTOR) (hr error) = vmcompute.ExportLayer?
23
-//sys getLayerMountPath(info *driverInfo, id string, length *uintptr, buffer *uint16) (hr error) = vmcompute.GetLayerMountPath?
24
-//sys getBaseImages(buffer **uint16) (hr error) = vmcompute.GetBaseImages?
25
-//sys importLayer(info *driverInfo, id string, path string, descriptors []WC_LAYER_DESCRIPTOR) (hr error) = vmcompute.ImportLayer?
26
-//sys layerExists(info *driverInfo, id string, exists *uint32) (hr error) = vmcompute.LayerExists?
27
-//sys nameToGuid(name string, guid *GUID) (hr error) = vmcompute.NameToGuid?
28
-//sys prepareLayer(info *driverInfo, id string, descriptors []WC_LAYER_DESCRIPTOR) (hr error) = vmcompute.PrepareLayer?
29
-//sys unprepareLayer(info *driverInfo, id string) (hr error) = vmcompute.UnprepareLayer?
30
-
31
-//sys createComputeSystem(id string, configuration string) (hr error) = vmcompute.CreateComputeSystem?
32
-//sys createProcessWithStdHandlesInComputeSystem(id string, paramsJson string, pid *uint32, stdin *syscall.Handle, stdout *syscall.Handle, stderr *syscall.Handle) (hr error) = vmcompute.CreateProcessWithStdHandlesInComputeSystem?
33
-//sys resizeConsoleInComputeSystem(id string, pid uint32, height uint16, width uint16, flags uint32) (hr error) = vmcompute.ResizeConsoleInComputeSystem?
34
-//sys shutdownComputeSystem(id string, timeout uint32) (hr error) = vmcompute.ShutdownComputeSystem?
35
-//sys startComputeSystem(id string) (hr error) = vmcompute.StartComputeSystem?
36
-//sys terminateComputeSystem(id string) (hr error) = vmcompute.TerminateComputeSystem?
37
-//sys terminateProcessInComputeSystem(id string, pid uint32) (hr error) = vmcompute.TerminateProcessInComputeSystem?
38
-//sys waitForProcessInComputeSystem(id string, pid uint32, timeout uint32, exitCode *uint32) (hr error) = vmcompute.WaitForProcessInComputeSystem?
39
-
40
-//sys _hnsCall(method string, path string, object string, response **uint16) (hr error) = vmcompute.HNSCall?
41
-
42
-const (
43
-	// Specific user-visible exit codes
44
-	WaitErrExecFailed = 32767
45
-
46
-	// Known Win32 RC values which should be trapped
47
-	Win32PipeHasBeenEnded                 = 0x8007006d // WaitForProcessInComputeSystem: The pipe has been ended
48
-	Win32SystemShutdownIsInProgress       = 0x8007045B // ShutdownComputeSystem: A system shutdown is in progress
49
-	Win32SpecifiedPathInvalid             = 0x800700A1 // ShutdownComputeSystem: The specified path is invalid
50
-	Win32SystemCannotFindThePathSpecified = 0x80070003 // ShutdownComputeSystem: The system cannot find the path specified
51
-	Win32InvalidArgument                  = 0x80072726 // CreateProcessInComputeSystem: An invalid argument was supplied
52
-	EFail                                 = 0x80004005
53
-
54
-	// Timeout on wait calls
55
-	TimeoutInfinite = 0xFFFFFFFF
56
-)
57
-
58
-type hcsError struct {
59
-	title string
60
-	rest  string
61
-	err   error
62
-}
63
-
64
-type Win32Error interface {
65
-	error
66
-	HResult() uint32
67
-}
68
-
69
-func makeError(err error, title, rest string) Win32Error {
70
-	return &hcsError{title, rest, err}
71
-}
72
-
73
-func makeErrorf(err error, title, format string, a ...interface{}) Win32Error {
74
-	return makeError(err, title, fmt.Sprintf(format, a...))
75
-}
76
-
77
-func (e *hcsError) HResult() uint32 {
78
-	if hr, ok := e.err.(syscall.Errno); ok {
79
-		return uint32(hr)
80
-	} else {
81
-		return EFail
82
-	}
83
-}
84
-
85
-func (e *hcsError) Error() string {
86
-	return fmt.Sprintf("%s- Win32 API call returned error r1=0x%x err=%s%s", e.title, e.HResult(), e.err, e.rest)
87
-}
88
-
89
-func convertAndFreeCoTaskMemString(buffer *uint16) string {
90
-	str := syscall.UTF16ToString((*[1 << 30]uint16)(unsafe.Pointer(buffer))[:])
91
-	coTaskMemFree(unsafe.Pointer(buffer))
92
-	return str
93
-}
94 1
deleted file mode 100644
... ...
@@ -1,131 +0,0 @@
1
-package hcsshim
2
-
3
-import (
4
-	"encoding/json"
5
-	"fmt"
6
-	"net"
7
-
8
-	"github.com/Sirupsen/logrus"
9
-)
10
-
11
-type NatPolicy struct {
12
-	Type         string
13
-	Protocol     string
14
-	InternalPort uint16
15
-	ExternalPort uint16
16
-}
17
-
18
-type QosPolicy struct {
19
-	Type                            string
20
-	MaximumOutgoingBandwidthInBytes uint64
21
-}
22
-
23
-// Subnet is assoicated with a network and represents a list
24
-// of subnets available to the network
25
-type Subnet struct {
26
-	AddressPrefix  string `json:",omitempty"`
27
-	GatewayAddress string `json:",omitempty"`
28
-}
29
-
30
-// MacPool is assoicated with a network and represents a list
31
-// of macaddresses available to the network
32
-type MacPool struct {
33
-	StartMacAddress string `json:",omitempty"`
34
-	EndMacAddress   string `json:",omitempty"`
35
-}
36
-
37
-// HNSNetwork represents a network in HNS
38
-type HNSNetwork struct {
39
-	Id       string            `json:",omitempty"`
40
-	Name     string            `json:",omitempty"`
41
-	Type     string            `json:",omitempty"`
42
-	Policies []json.RawMessage `json:",omitempty"`
43
-	MacPools []MacPool         `json:",omitempty"`
44
-	Subnets  []Subnet          `json:",omitempty"`
45
-}
46
-
47
-// HNSEndpoint represents a network endpoint in HNS
48
-type HNSEndpoint struct {
49
-	Id                 string            `json:",omitempty"`
50
-	Name               string            `json:",omitempty"`
51
-	VirtualNetwork     string            `json:",omitempty"`
52
-	VirtualNetworkName string            `json:",omitempty"`
53
-	Policies           []json.RawMessage `json:",omitempty"`
54
-	MacAddress         string            `json:",omitempty"`
55
-	IPAddress          net.IP            `json:",omitempty"`
56
-}
57
-
58
-type hnsNetworkResponse struct {
59
-	Success bool
60
-	Error   string
61
-	Output  HNSNetwork
62
-}
63
-
64
-type hnsResponse struct {
65
-	Success bool
66
-	Error   string
67
-	Output  json.RawMessage
68
-}
69
-
70
-func hnsCall(method, path, request string, returnResponse interface{}) error {
71
-	var responseBuffer *uint16
72
-	err := _hnsCall(method, path, request, &responseBuffer)
73
-	if err != nil {
74
-		return makeError(err, "hnsCall ", "")
75
-	}
76
-	response := convertAndFreeCoTaskMemString(responseBuffer)
77
-
78
-	hnsresponse := &hnsResponse{}
79
-	if err = json.Unmarshal([]byte(response), &hnsresponse); err != nil {
80
-		return err
81
-	}
82
-
83
-	if !hnsresponse.Success {
84
-		return fmt.Errorf("HNS failed with error : %s", hnsresponse.Error)
85
-	}
86
-
87
-	if len(hnsresponse.Output) == 0 {
88
-		return nil
89
-	}
90
-
91
-	logrus.Debugf("Network Response : %s", hnsresponse.Output)
92
-	err = json.Unmarshal(hnsresponse.Output, returnResponse)
93
-	if err != nil {
94
-		return err
95
-	}
96
-
97
-	return nil
98
-}
99
-
100
-// HNSNetworkRequest makes a call into HNS to update/query a single network
101
-func HNSNetworkRequest(method, path, request string) (*HNSNetwork, error) {
102
-	var network HNSNetwork
103
-	err := hnsCall(method, "/networks/"+path, request, &network)
104
-	if err != nil {
105
-		return nil, err
106
-	}
107
-
108
-	return &network, nil
109
-}
110
-
111
-// HNSListNetworkRequest makes a HNS call to query the list of available networks
112
-func HNSListNetworkRequest(method, path, request string) ([]HNSNetwork, error) {
113
-	var network []HNSNetwork
114
-	err := hnsCall(method, "/networks/"+path, request, &network)
115
-	if err != nil {
116
-		return nil, err
117
-	}
118
-
119
-	return network, nil
120
-}
121
-
122
-// HNSEndpointRequest makes a HNS call to modify/query a network endpoint
123
-func HNSEndpointRequest(method, path, request string) (*HNSEndpoint, error) {
124
-	endpoint := &HNSEndpoint{}
125
-	err := hnsCall(method, "/endpoints/"+path, request, &endpoint)
126
-	if err != nil {
127
-		return nil, err
128
-	}
129
-
130
-	return endpoint, nil
131
-}
132 1
deleted file mode 100644
... ...
@@ -1,35 +0,0 @@
1
-package hcsshim
2
-
3
-import "github.com/Sirupsen/logrus"
4
-
5
-// ImportLayer will take the contents of the folder at importFolderPath and import
6
-// that into a layer with the id layerId.  Note that in order to correctly populate
7
-// the layer and interperet the transport format, all parent layers must already
8
-// be present on the system at the paths provided in parentLayerPaths.
9
-func ImportLayer(info DriverInfo, layerId string, importFolderPath string, parentLayerPaths []string) error {
10
-	title := "hcsshim::ImportLayer "
11
-	logrus.Debugf(title+"flavour %d layerId %s folder %s", info.Flavour, layerId, importFolderPath)
12
-
13
-	// Generate layer descriptors
14
-	layers, err := layerPathsToDescriptors(parentLayerPaths)
15
-	if err != nil {
16
-		return err
17
-	}
18
-
19
-	// Convert info to API calling convention
20
-	infop, err := convertDriverInfo(info)
21
-	if err != nil {
22
-		logrus.Error(err)
23
-		return err
24
-	}
25
-
26
-	err = importLayer(&infop, layerId, importFolderPath, layers)
27
-	if err != nil {
28
-		err = makeErrorf(err, title, "layerId=%s flavour=%d folder=%s", layerId, info.Flavour, importFolderPath)
29
-		logrus.Error(err)
30
-		return err
31
-	}
32
-
33
-	logrus.Debugf(title+"succeeded flavour=%d layerId=%s folder=%s", info.Flavour, layerId, importFolderPath)
34
-	return nil
35
-}
36 1
deleted file mode 100644
... ...
@@ -1,30 +0,0 @@
1
-package hcsshim
2
-
3
-import "github.com/Sirupsen/logrus"
4
-
5
-// LayerExists will return true if a layer with the given id exists and is known
6
-// to the system.
7
-func LayerExists(info DriverInfo, id string) (bool, error) {
8
-	title := "hcsshim::LayerExists "
9
-	logrus.Debugf(title+"Flavour %d ID %s", info.Flavour, id)
10
-
11
-	// Convert info to API calling convention
12
-	infop, err := convertDriverInfo(info)
13
-	if err != nil {
14
-		logrus.Error(err)
15
-		return false, err
16
-	}
17
-
18
-	// Call the procedure itself.
19
-	var exists uint32
20
-
21
-	err = layerExists(&infop, id, &exists)
22
-	if err != nil {
23
-		err = makeErrorf(err, title, "id=%s flavour=%d", id, info.Flavour)
24
-		logrus.Error(err)
25
-		return false, err
26
-	}
27
-
28
-	logrus.Debugf(title+"succeeded flavour=%d id=%s exists=%d", info.Flavour, id, exists)
29
-	return exists != 0, nil
30
-}
31 1
deleted file mode 100644
... ...
@@ -1,111 +0,0 @@
1
-package hcsshim
2
-
3
-// This file contains utility functions to support storage (graph) related
4
-// functionality.
5
-
6
-import (
7
-	"path/filepath"
8
-	"syscall"
9
-
10
-	"github.com/Sirupsen/logrus"
11
-)
12
-
13
-/* To pass into syscall, we need a struct matching the following:
14
-enum GraphDriverType
15
-{
16
-    DiffDriver,
17
-    FilterDriver
18
-};
19
-
20
-struct DriverInfo {
21
-    GraphDriverType Flavour;
22
-    LPCWSTR HomeDir;
23
-};
24
-*/
25
-type DriverInfo struct {
26
-	Flavour int
27
-	HomeDir string
28
-}
29
-
30
-type driverInfo struct {
31
-	Flavour  int
32
-	HomeDirp *uint16
33
-}
34
-
35
-func convertDriverInfo(info DriverInfo) (driverInfo, error) {
36
-	homedirp, err := syscall.UTF16PtrFromString(info.HomeDir)
37
-	if err != nil {
38
-		logrus.Debugf("Failed conversion of home to pointer for driver info: %s", err.Error())
39
-		return driverInfo{}, err
40
-	}
41
-
42
-	return driverInfo{
43
-		Flavour:  info.Flavour,
44
-		HomeDirp: homedirp,
45
-	}, nil
46
-}
47
-
48
-/* To pass into syscall, we need a struct matching the following:
49
-typedef struct _WC_LAYER_DESCRIPTOR {
50
-
51
-    //
52
-    // The ID of the layer
53
-    //
54
-
55
-    GUID LayerId;
56
-
57
-    //
58
-    // Additional flags
59
-    //
60
-
61
-    union {
62
-        struct {
63
-            ULONG Reserved : 31;
64
-            ULONG Dirty : 1;    // Created from sandbox as a result of snapshot
65
-        };
66
-        ULONG Value;
67
-    } Flags;
68
-
69
-    //
70
-    // Path to the layer root directory, null-terminated
71
-    //
72
-
73
-    PCWSTR Path;
74
-
75
-} WC_LAYER_DESCRIPTOR, *PWC_LAYER_DESCRIPTOR;
76
-*/
77
-type WC_LAYER_DESCRIPTOR struct {
78
-	LayerId GUID
79
-	Flags   uint32
80
-	Pathp   *uint16
81
-}
82
-
83
-func layerPathsToDescriptors(parentLayerPaths []string) ([]WC_LAYER_DESCRIPTOR, error) {
84
-	// Array of descriptors that gets constructed.
85
-	var layers []WC_LAYER_DESCRIPTOR
86
-
87
-	for i := 0; i < len(parentLayerPaths); i++ {
88
-		// Create a layer descriptor, using the folder name
89
-		// as the source for a GUID LayerId
90
-		_, folderName := filepath.Split(parentLayerPaths[i])
91
-		g, err := NameToGuid(folderName)
92
-		if err != nil {
93
-			logrus.Debugf("Failed to convert name to guid %s", err)
94
-			return nil, err
95
-		}
96
-
97
-		p, err := syscall.UTF16PtrFromString(parentLayerPaths[i])
98
-		if err != nil {
99
-			logrus.Debugf("Failed conversion of parentLayerPath to pointer %s", err)
100
-			return nil, err
101
-		}
102
-
103
-		layers = append(layers, WC_LAYER_DESCRIPTOR{
104
-			LayerId: g,
105
-			Flags:   0,
106
-			Pathp:   p,
107
-		})
108
-	}
109
-
110
-	return layers, nil
111
-}
112 1
deleted file mode 100644
... ...
@@ -1,797 +0,0 @@
1
-// Copyright 2013 The Go Authors. All rights reserved.
2
-// Use of this source code is governed by a BSD-style
3
-// license that can be found in the LICENSE file.
4
-
5
-// +build ignore
6
-
7
-/*
8
-mksyscall_windows generates windows system call bodies
9
-
10
-It parses all files specified on command line containing function
11
-prototypes (like syscall_windows.go) and prints system call bodies
12
-to standard output.
13
-
14
-The prototypes are marked by lines beginning with "//sys" and read
15
-like func declarations if //sys is replaced by func, but:
16
-
17
-* The parameter lists must give a name for each argument. This
18
-  includes return parameters.
19
-
20
-* The parameter lists must give a type for each argument:
21
-  the (x, y, z int) shorthand is not allowed.
22
-
23
-* If the return parameter is an error number, it must be named err.
24
-
25
-* If go func name needs to be different from it's winapi dll name,
26
-  the winapi name could be specified at the end, after "=" sign, like
27
-  //sys LoadLibrary(libname string) (handle uint32, err error) = LoadLibraryA
28
-
29
-* Each function that returns err needs to supply a condition, that
30
-  return value of winapi will be tested against to detect failure.
31
-  This would set err to windows "last-error", otherwise it will be nil.
32
-  The value can be provided at end of //sys declaration, like
33
-  //sys LoadLibrary(libname string) (handle uint32, err error) [failretval==-1] = LoadLibraryA
34
-  and is [failretval==0] by default.
35
-
36
-Usage:
37
-	mksyscall_windows [flags] [path ...]
38
-
39
-The flags are:
40
-	-output
41
-		Specify output file name (outputs to console if blank).
42
-	-trace
43
-		Generate print statement after every syscall.
44
-*/
45
-package main
46
-
47
-import (
48
-	"bufio"
49
-	"bytes"
50
-	"errors"
51
-	"flag"
52
-	"fmt"
53
-	"go/format"
54
-	"go/parser"
55
-	"go/token"
56
-	"io"
57
-	"io/ioutil"
58
-	"log"
59
-	"os"
60
-	"strconv"
61
-	"strings"
62
-	"text/template"
63
-)
64
-
65
-var (
66
-	filename       = flag.String("output", "", "output file name (standard output if omitted)")
67
-	printTraceFlag = flag.Bool("trace", false, "generate print statement after every syscall")
68
-)
69
-
70
-func trim(s string) string {
71
-	return strings.Trim(s, " \t")
72
-}
73
-
74
-var packageName string
75
-
76
-func packagename() string {
77
-	return packageName
78
-}
79
-
80
-func syscalldot() string {
81
-	if packageName == "syscall" {
82
-		return ""
83
-	}
84
-	return "syscall."
85
-}
86
-
87
-// Param is function parameter
88
-type Param struct {
89
-	Name      string
90
-	Type      string
91
-	fn        *Fn
92
-	tmpVarIdx int
93
-}
94
-
95
-// tmpVar returns temp variable name that will be used to represent p during syscall.
96
-func (p *Param) tmpVar() string {
97
-	if p.tmpVarIdx < 0 {
98
-		p.tmpVarIdx = p.fn.curTmpVarIdx
99
-		p.fn.curTmpVarIdx++
100
-	}
101
-	return fmt.Sprintf("_p%d", p.tmpVarIdx)
102
-}
103
-
104
-// BoolTmpVarCode returns source code for bool temp variable.
105
-func (p *Param) BoolTmpVarCode() string {
106
-	const code = `var %s uint32
107
-	if %s {
108
-		%s = 1
109
-	} else {
110
-		%s = 0
111
-	}`
112
-	tmp := p.tmpVar()
113
-	return fmt.Sprintf(code, tmp, p.Name, tmp, tmp)
114
-}
115
-
116
-// SliceTmpVarCode returns source code for slice temp variable.
117
-func (p *Param) SliceTmpVarCode() string {
118
-	const code = `var %s *%s
119
-	if len(%s) > 0 {
120
-		%s = &%s[0]
121
-	}`
122
-	tmp := p.tmpVar()
123
-	return fmt.Sprintf(code, tmp, p.Type[2:], p.Name, tmp, p.Name)
124
-}
125
-
126
-// StringTmpVarCode returns source code for string temp variable.
127
-func (p *Param) StringTmpVarCode() string {
128
-	errvar := p.fn.Rets.ErrorVarName()
129
-	if errvar == "" {
130
-		errvar = "_"
131
-	}
132
-	tmp := p.tmpVar()
133
-	const code = `var %s %s
134
-	%s, %s = %s(%s)`
135
-	s := fmt.Sprintf(code, tmp, p.fn.StrconvType(), tmp, errvar, p.fn.StrconvFunc(), p.Name)
136
-	if errvar == "-" {
137
-		return s
138
-	}
139
-	const morecode = `
140
-	if %s != nil {
141
-		return
142
-	}`
143
-	return s + fmt.Sprintf(morecode, errvar)
144
-}
145
-
146
-// TmpVarCode returns source code for temp variable.
147
-func (p *Param) TmpVarCode() string {
148
-	switch {
149
-	case p.Type == "bool":
150
-		return p.BoolTmpVarCode()
151
-	case strings.HasPrefix(p.Type, "[]"):
152
-		return p.SliceTmpVarCode()
153
-	default:
154
-		return ""
155
-	}
156
-}
157
-
158
-// TmpVarHelperCode returns source code for helper's temp variable.
159
-func (p *Param) TmpVarHelperCode() string {
160
-	if p.Type != "string" {
161
-		return ""
162
-	}
163
-	return p.StringTmpVarCode()
164
-}
165
-
166
-// SyscallArgList returns source code fragments representing p parameter
167
-// in syscall. Slices are translated into 2 syscall parameters: pointer to
168
-// the first element and length.
169
-func (p *Param) SyscallArgList() []string {
170
-	t := p.HelperType()
171
-	var s string
172
-	switch {
173
-	case t[0] == '*':
174
-		s = fmt.Sprintf("unsafe.Pointer(%s)", p.Name)
175
-	case t == "bool":
176
-		s = p.tmpVar()
177
-	case strings.HasPrefix(t, "[]"):
178
-		return []string{
179
-			fmt.Sprintf("uintptr(unsafe.Pointer(%s))", p.tmpVar()),
180
-			fmt.Sprintf("uintptr(len(%s))", p.Name),
181
-		}
182
-	default:
183
-		s = p.Name
184
-	}
185
-	return []string{fmt.Sprintf("uintptr(%s)", s)}
186
-}
187
-
188
-// IsError determines if p parameter is used to return error.
189
-func (p *Param) IsError() bool {
190
-	return p.Name == "err" && p.Type == "error"
191
-}
192
-
193
-// HelperType returns type of parameter p used in helper function.
194
-func (p *Param) HelperType() string {
195
-	if p.Type == "string" {
196
-		return p.fn.StrconvType()
197
-	}
198
-	return p.Type
199
-}
200
-
201
-// join concatenates parameters ps into a string with sep separator.
202
-// Each parameter is converted into string by applying fn to it
203
-// before conversion.
204
-func join(ps []*Param, fn func(*Param) string, sep string) string {
205
-	if len(ps) == 0 {
206
-		return ""
207
-	}
208
-	a := make([]string, 0)
209
-	for _, p := range ps {
210
-		a = append(a, fn(p))
211
-	}
212
-	return strings.Join(a, sep)
213
-}
214
-
215
-// Rets describes function return parameters.
216
-type Rets struct {
217
-	Name         string
218
-	Type         string
219
-	ReturnsError bool
220
-	FailCond     string
221
-}
222
-
223
-// ErrorVarName returns error variable name for r.
224
-func (r *Rets) ErrorVarName() string {
225
-	if r.ReturnsError {
226
-		return "err"
227
-	}
228
-	if r.Type == "error" {
229
-		return r.Name
230
-	}
231
-	return ""
232
-}
233
-
234
-// ToParams converts r into slice of *Param.
235
-func (r *Rets) ToParams() []*Param {
236
-	ps := make([]*Param, 0)
237
-	if len(r.Name) > 0 {
238
-		ps = append(ps, &Param{Name: r.Name, Type: r.Type})
239
-	}
240
-	if r.ReturnsError {
241
-		ps = append(ps, &Param{Name: "err", Type: "error"})
242
-	}
243
-	return ps
244
-}
245
-
246
-// List returns source code of syscall return parameters.
247
-func (r *Rets) List() string {
248
-	s := join(r.ToParams(), func(p *Param) string { return p.Name + " " + p.Type }, ", ")
249
-	if len(s) > 0 {
250
-		s = "(" + s + ")"
251
-	}
252
-	return s
253
-}
254
-
255
-// PrintList returns source code of trace printing part correspondent
256
-// to syscall return values.
257
-func (r *Rets) PrintList() string {
258
-	return join(r.ToParams(), func(p *Param) string { return fmt.Sprintf(`"%s=", %s, `, p.Name, p.Name) }, `", ", `)
259
-}
260
-
261
-// SetReturnValuesCode returns source code that accepts syscall return values.
262
-func (r *Rets) SetReturnValuesCode() string {
263
-	if r.Name == "" && !r.ReturnsError {
264
-		return ""
265
-	}
266
-	retvar := "r0"
267
-	if r.Name == "" {
268
-		retvar = "r1"
269
-	}
270
-	errvar := "_"
271
-	if r.ReturnsError {
272
-		errvar = "e1"
273
-	}
274
-	return fmt.Sprintf("%s, _, %s := ", retvar, errvar)
275
-}
276
-
277
-func (r *Rets) useLongHandleErrorCode(retvar string) string {
278
-	const code = `if %s {
279
-		if e1 != 0 {
280
-			err = error(e1)
281
-		} else {
282
-			err = %sEINVAL
283
-		}
284
-	}`
285
-	cond := retvar + " == 0"
286
-	if r.FailCond != "" {
287
-		cond = strings.Replace(r.FailCond, "failretval", retvar, 1)
288
-	}
289
-	return fmt.Sprintf(code, cond, syscalldot())
290
-}
291
-
292
-// SetErrorCode returns source code that sets return parameters.
293
-func (r *Rets) SetErrorCode() string {
294
-	const code = `if r0 != 0 {
295
-		%s = %sErrno(r0)
296
-	}`
297
-	if r.Name == "" && !r.ReturnsError {
298
-		return ""
299
-	}
300
-	if r.Name == "" {
301
-		return r.useLongHandleErrorCode("r1")
302
-	}
303
-	if r.Type == "error" {
304
-		return fmt.Sprintf(code, r.Name, syscalldot())
305
-	}
306
-	s := ""
307
-	switch {
308
-	case r.Type[0] == '*':
309
-		s = fmt.Sprintf("%s = (%s)(unsafe.Pointer(r0))", r.Name, r.Type)
310
-	case r.Type == "bool":
311
-		s = fmt.Sprintf("%s = r0 != 0", r.Name)
312
-	default:
313
-		s = fmt.Sprintf("%s = %s(r0)", r.Name, r.Type)
314
-	}
315
-	if !r.ReturnsError {
316
-		return s
317
-	}
318
-	return s + "\n\t" + r.useLongHandleErrorCode(r.Name)
319
-}
320
-
321
-// Fn describes syscall function.
322
-type Fn struct {
323
-	Name        string
324
-	Params      []*Param
325
-	Rets        *Rets
326
-	PrintTrace  bool
327
-	confirmproc bool
328
-	dllname     string
329
-	dllfuncname string
330
-	src         string
331
-	// TODO: get rid of this field and just use parameter index instead
332
-	curTmpVarIdx int // insure tmp variables have uniq names
333
-}
334
-
335
-// extractParams parses s to extract function parameters.
336
-func extractParams(s string, f *Fn) ([]*Param, error) {
337
-	s = trim(s)
338
-	if s == "" {
339
-		return nil, nil
340
-	}
341
-	a := strings.Split(s, ",")
342
-	ps := make([]*Param, len(a))
343
-	for i := range ps {
344
-		s2 := trim(a[i])
345
-		b := strings.Split(s2, " ")
346
-		if len(b) != 2 {
347
-			b = strings.Split(s2, "\t")
348
-			if len(b) != 2 {
349
-				return nil, errors.New("Could not extract function parameter from \"" + s2 + "\"")
350
-			}
351
-		}
352
-		ps[i] = &Param{
353
-			Name:      trim(b[0]),
354
-			Type:      trim(b[1]),
355
-			fn:        f,
356
-			tmpVarIdx: -1,
357
-		}
358
-	}
359
-	return ps, nil
360
-}
361
-
362
-// extractSection extracts text out of string s starting after start
363
-// and ending just before end. found return value will indicate success,
364
-// and prefix, body and suffix will contain correspondent parts of string s.
365
-func extractSection(s string, start, end rune) (prefix, body, suffix string, found bool) {
366
-	s = trim(s)
367
-	if strings.HasPrefix(s, string(start)) {
368
-		// no prefix
369
-		body = s[1:]
370
-	} else {
371
-		a := strings.SplitN(s, string(start), 2)
372
-		if len(a) != 2 {
373
-			return "", "", s, false
374
-		}
375
-		prefix = a[0]
376
-		body = a[1]
377
-	}
378
-	a := strings.SplitN(body, string(end), 2)
379
-	if len(a) != 2 {
380
-		return "", "", "", false
381
-	}
382
-	return prefix, a[0], a[1], true
383
-}
384
-
385
-// newFn parses string s and return created function Fn.
386
-func newFn(s string) (*Fn, error) {
387
-	s = trim(s)
388
-	f := &Fn{
389
-		Rets:       &Rets{},
390
-		src:        s,
391
-		PrintTrace: *printTraceFlag,
392
-	}
393
-	// function name and args
394
-	prefix, body, s, found := extractSection(s, '(', ')')
395
-	if !found || prefix == "" {
396
-		return nil, errors.New("Could not extract function name and parameters from \"" + f.src + "\"")
397
-	}
398
-	f.Name = prefix
399
-	var err error
400
-	f.Params, err = extractParams(body, f)
401
-	if err != nil {
402
-		return nil, err
403
-	}
404
-	// return values
405
-	_, body, s, found = extractSection(s, '(', ')')
406
-	if found {
407
-		r, err := extractParams(body, f)
408
-		if err != nil {
409
-			return nil, err
410
-		}
411
-		switch len(r) {
412
-		case 0:
413
-		case 1:
414
-			if r[0].IsError() {
415
-				f.Rets.ReturnsError = true
416
-			} else {
417
-				f.Rets.Name = r[0].Name
418
-				f.Rets.Type = r[0].Type
419
-			}
420
-		case 2:
421
-			if !r[1].IsError() {
422
-				return nil, errors.New("Only last windows error is allowed as second return value in \"" + f.src + "\"")
423
-			}
424
-			f.Rets.ReturnsError = true
425
-			f.Rets.Name = r[0].Name
426
-			f.Rets.Type = r[0].Type
427
-		default:
428
-			return nil, errors.New("Too many return values in \"" + f.src + "\"")
429
-		}
430
-	}
431
-	// fail condition
432
-	_, body, s, found = extractSection(s, '[', ']')
433
-	if found {
434
-		f.Rets.FailCond = body
435
-	}
436
-	// dll and dll function names
437
-	s = trim(s)
438
-	if s == "" {
439
-		return f, nil
440
-	}
441
-	if !strings.HasPrefix(s, "=") {
442
-		return nil, errors.New("Could not extract dll name from \"" + f.src + "\"")
443
-	}
444
-	s = trim(s[1:])
445
-	a := strings.Split(s, ".")
446
-	switch len(a) {
447
-	case 1:
448
-		f.dllfuncname = a[0]
449
-	case 2:
450
-		f.dllname = a[0]
451
-		f.dllfuncname = a[1]
452
-	default:
453
-		return nil, errors.New("Could not extract dll name from \"" + f.src + "\"")
454
-	}
455
-	if f.dllfuncname[len(f.dllfuncname)-1] == '?' {
456
-		f.confirmproc = true
457
-		f.dllfuncname = f.dllfuncname[0 : len(f.dllfuncname)-1]
458
-	}
459
-	return f, nil
460
-}
461
-
462
-// DLLName returns DLL name for function f.
463
-func (f *Fn) DLLName() string {
464
-	if f.dllname == "" {
465
-		return "kernel32"
466
-	}
467
-	return f.dllname
468
-}
469
-
470
-// DLLName returns DLL function name for function f.
471
-func (f *Fn) DLLFuncName() string {
472
-	if f.dllfuncname == "" {
473
-		return f.Name
474
-	}
475
-	return f.dllfuncname
476
-}
477
-
478
-func (f *Fn) ConfirmProc() bool {
479
-	return f.confirmproc
480
-}
481
-
482
-// ParamList returns source code for function f parameters.
483
-func (f *Fn) ParamList() string {
484
-	return join(f.Params, func(p *Param) string { return p.Name + " " + p.Type }, ", ")
485
-}
486
-
487
-// HelperParamList returns source code for helper function f parameters.
488
-func (f *Fn) HelperParamList() string {
489
-	return join(f.Params, func(p *Param) string { return p.Name + " " + p.HelperType() }, ", ")
490
-}
491
-
492
-// ParamPrintList returns source code of trace printing part correspondent
493
-// to syscall input parameters.
494
-func (f *Fn) ParamPrintList() string {
495
-	return join(f.Params, func(p *Param) string { return fmt.Sprintf(`"%s=", %s, `, p.Name, p.Name) }, `", ", `)
496
-}
497
-
498
-// ParamCount return number of syscall parameters for function f.
499
-func (f *Fn) ParamCount() int {
500
-	n := 0
501
-	for _, p := range f.Params {
502
-		n += len(p.SyscallArgList())
503
-	}
504
-	return n
505
-}
506
-
507
-// SyscallParamCount determines which version of Syscall/Syscall6/Syscall9/...
508
-// to use. It returns parameter count for correspondent SyscallX function.
509
-func (f *Fn) SyscallParamCount() int {
510
-	n := f.ParamCount()
511
-	switch {
512
-	case n <= 3:
513
-		return 3
514
-	case n <= 6:
515
-		return 6
516
-	case n <= 9:
517
-		return 9
518
-	case n <= 12:
519
-		return 12
520
-	case n <= 15:
521
-		return 15
522
-	default:
523
-		panic("too many arguments to system call")
524
-	}
525
-}
526
-
527
-// Syscall determines which SyscallX function to use for function f.
528
-func (f *Fn) Syscall() string {
529
-	c := f.SyscallParamCount()
530
-	if c == 3 {
531
-		return syscalldot() + "Syscall"
532
-	}
533
-	return syscalldot() + "Syscall" + strconv.Itoa(c)
534
-}
535
-
536
-// SyscallParamList returns source code for SyscallX parameters for function f.
537
-func (f *Fn) SyscallParamList() string {
538
-	a := make([]string, 0)
539
-	for _, p := range f.Params {
540
-		a = append(a, p.SyscallArgList()...)
541
-	}
542
-	for len(a) < f.SyscallParamCount() {
543
-		a = append(a, "0")
544
-	}
545
-	return strings.Join(a, ", ")
546
-}
547
-
548
-// HelperCallParamList returns source code of call into function f helper.
549
-func (f *Fn) HelperCallParamList() string {
550
-	a := make([]string, 0, len(f.Params))
551
-	for _, p := range f.Params {
552
-		s := p.Name
553
-		if p.Type == "string" {
554
-			s = p.tmpVar()
555
-		}
556
-		a = append(a, s)
557
-	}
558
-	return strings.Join(a, ", ")
559
-}
560
-
561
-// IsUTF16 is true, if f is W (utf16) function. It is false
562
-// for all A (ascii) functions.
563
-func (_ *Fn) IsUTF16() bool {
564
-	return true
565
-}
566
-
567
-// StrconvFunc returns name of Go string to OS string function for f.
568
-func (f *Fn) StrconvFunc() string {
569
-	if f.IsUTF16() {
570
-		return syscalldot() + "UTF16PtrFromString"
571
-	}
572
-	return syscalldot() + "BytePtrFromString"
573
-}
574
-
575
-// StrconvType returns Go type name used for OS string for f.
576
-func (f *Fn) StrconvType() string {
577
-	if f.IsUTF16() {
578
-		return "*uint16"
579
-	}
580
-	return "*byte"
581
-}
582
-
583
-// HasStringParam is true, if f has at least one string parameter.
584
-// Otherwise it is false.
585
-func (f *Fn) HasStringParam() bool {
586
-	for _, p := range f.Params {
587
-		if p.Type == "string" {
588
-			return true
589
-		}
590
-	}
591
-	return false
592
-}
593
-
594
-// HelperName returns name of function f helper.
595
-func (f *Fn) HelperName() string {
596
-	if !f.HasStringParam() {
597
-		return f.Name
598
-	}
599
-	return "_" + f.Name
600
-}
601
-
602
-// Source files and functions.
603
-type Source struct {
604
-	Funcs []*Fn
605
-	Files []string
606
-}
607
-
608
-// ParseFiles parses files listed in fs and extracts all syscall
609
-// functions listed in  sys comments. It returns source files
610
-// and functions collection *Source if successful.
611
-func ParseFiles(fs []string) (*Source, error) {
612
-	src := &Source{
613
-		Funcs: make([]*Fn, 0),
614
-		Files: make([]string, 0),
615
-	}
616
-	for _, file := range fs {
617
-		if err := src.ParseFile(file); err != nil {
618
-			return nil, err
619
-		}
620
-	}
621
-	return src, nil
622
-}
623
-
624
-// DLLs return dll names for a source set src.
625
-func (src *Source) DLLs() []string {
626
-	uniq := make(map[string]bool)
627
-	r := make([]string, 0)
628
-	for _, f := range src.Funcs {
629
-		name := f.DLLName()
630
-		if _, found := uniq[name]; !found {
631
-			uniq[name] = true
632
-			r = append(r, name)
633
-		}
634
-	}
635
-	return r
636
-}
637
-
638
-// ParseFile adds additional file path to a source set src.
639
-func (src *Source) ParseFile(path string) error {
640
-	file, err := os.Open(path)
641
-	if err != nil {
642
-		return err
643
-	}
644
-	defer file.Close()
645
-
646
-	s := bufio.NewScanner(file)
647
-	for s.Scan() {
648
-		t := trim(s.Text())
649
-		if len(t) < 7 {
650
-			continue
651
-		}
652
-		if !strings.HasPrefix(t, "//sys") {
653
-			continue
654
-		}
655
-		t = t[5:]
656
-		if !(t[0] == ' ' || t[0] == '\t') {
657
-			continue
658
-		}
659
-		f, err := newFn(t[1:])
660
-		if err != nil {
661
-			return err
662
-		}
663
-		src.Funcs = append(src.Funcs, f)
664
-	}
665
-	if err := s.Err(); err != nil {
666
-		return err
667
-	}
668
-	src.Files = append(src.Files, path)
669
-
670
-	// get package name
671
-	fset := token.NewFileSet()
672
-	_, err = file.Seek(0, 0)
673
-	if err != nil {
674
-		return err
675
-	}
676
-	pkg, err := parser.ParseFile(fset, "", file, parser.PackageClauseOnly)
677
-	if err != nil {
678
-		return err
679
-	}
680
-	packageName = pkg.Name.Name
681
-
682
-	return nil
683
-}
684
-
685
-// Generate output source file from a source set src.
686
-func (src *Source) Generate(w io.Writer) error {
687
-	funcMap := template.FuncMap{
688
-		"packagename": packagename,
689
-		"syscalldot":  syscalldot,
690
-	}
691
-	t := template.Must(template.New("main").Funcs(funcMap).Parse(srcTemplate))
692
-	err := t.Execute(w, src)
693
-	if err != nil {
694
-		return errors.New("Failed to execute template: " + err.Error())
695
-	}
696
-	return nil
697
-}
698
-
699
-func usage() {
700
-	fmt.Fprintf(os.Stderr, "usage: mksyscall_windows [flags] [path ...]\n")
701
-	flag.PrintDefaults()
702
-	os.Exit(1)
703
-}
704
-
705
-func main() {
706
-	flag.Usage = usage
707
-	flag.Parse()
708
-	if len(flag.Args()) <= 0 {
709
-		fmt.Fprintf(os.Stderr, "no files to parse provided\n")
710
-		usage()
711
-	}
712
-
713
-	src, err := ParseFiles(flag.Args())
714
-	if err != nil {
715
-		log.Fatal(err)
716
-	}
717
-
718
-	var buf bytes.Buffer
719
-	if err := src.Generate(&buf); err != nil {
720
-		log.Fatal(err)
721
-	}
722
-
723
-	data, err := format.Source(buf.Bytes())
724
-	if err != nil {
725
-		log.Fatal(err)
726
-	}
727
-	if *filename == "" {
728
-		_, err = os.Stdout.Write(data)
729
-	} else {
730
-		err = ioutil.WriteFile(*filename, data, 0644)
731
-	}
732
-	if err != nil {
733
-		log.Fatal(err)
734
-	}
735
-}
736
-
737
-// TODO: use println instead to print in the following template
738
-const srcTemplate = `
739
-
740
-{{define "main"}}// MACHINE GENERATED BY 'go generate' COMMAND; DO NOT EDIT
741
-
742
-package {{packagename}}
743
-
744
-import "unsafe"{{if syscalldot}}
745
-import "syscall"{{end}}
746
-
747
-var _ unsafe.Pointer
748
-
749
-var (
750
-{{template "dlls" .}}
751
-{{template "funcnames" .}})
752
-{{range .Funcs}}{{if .HasStringParam}}{{template "helperbody" .}}{{end}}{{template "funcbody" .}}{{end}}
753
-{{end}}
754
-
755
-{{/* help functions */}}
756
-
757
-{{define "dlls"}}{{range .DLLs}}	mod{{.}} = {{syscalldot}}NewLazyDLL("{{.}}.dll")
758
-{{end}}{{end}}
759
-
760
-{{define "funcnames"}}{{range .Funcs}}	proc{{.DLLFuncName}} = mod{{.DLLName}}.NewProc("{{.DLLFuncName}}")
761
-{{end}}{{end}}
762
-
763
-{{define "helperbody"}}
764
-func {{.Name}}({{.ParamList}}) {{template "results" .}}{
765
-{{template "helpertmpvars" .}}	return {{.HelperName}}({{.HelperCallParamList}})
766
-}
767
-{{end}}
768
-
769
-{{define "funcbody"}}
770
-func {{.HelperName}}({{.HelperParamList}}) {{template "results" .}}{
771
-{{template "tmpvars" .}}	{{template "syscallcheck" .}}{{template "syscall" .}}
772
-{{template "seterror" .}}{{template "printtrace" .}}	return
773
-}
774
-{{end}}
775
-
776
-{{define "helpertmpvars"}}{{range .Params}}{{if .TmpVarHelperCode}}	{{.TmpVarHelperCode}}
777
-{{end}}{{end}}{{end}}
778
-
779
-{{define "tmpvars"}}{{range .Params}}{{if .TmpVarCode}}	{{.TmpVarCode}}
780
-{{end}}{{end}}{{end}}
781
-
782
-{{define "results"}}{{if .Rets.List}}{{.Rets.List}} {{end}}{{end}}
783
-
784
-{{define "syscallcheck"}}{{if .ConfirmProc}}if {{.Rets.ErrorVarName}} = proc{{.DLLFuncName}}.Find(); {{.Rets.ErrorVarName}} != nil {
785
-    return
786
-}
787
-{{end}}{{end}}
788
-
789
-{{define "syscall"}}{{.Rets.SetReturnValuesCode}}{{.Syscall}}(proc{{.DLLFuncName}}.Addr(), {{.ParamCount}}, {{.SyscallParamList}}){{end}}
790
-
791
-{{define "seterror"}}{{if .Rets.SetErrorCode}}	{{.Rets.SetErrorCode}}
792
-{{end}}{{end}}
793
-
794
-{{define "printtrace"}}{{if .PrintTrace}}	print("SYSCALL: {{.Name}}(", {{.ParamPrintList}}") (", {{.Rets.PrintList}}")\n")
795
-{{end}}{{end}}
796
-
797
-`
798 1
deleted file mode 100644
... ...
@@ -1,20 +0,0 @@
1
-package hcsshim
2
-
3
-import "github.com/Sirupsen/logrus"
4
-
5
-// NameToGuid converts the given string into a GUID using the algorithm in the
6
-// Host Compute Service, ensuring GUIDs generated with the same string are common
7
-// across all clients.
8
-func NameToGuid(name string) (id GUID, err error) {
9
-	title := "hcsshim::NameToGuid "
10
-	logrus.Debugf(title+"Name %s", name)
11
-
12
-	err = nameToGuid(name, &id)
13
-	if err != nil {
14
-		err = makeErrorf(err, title, "name=%s", name)
15
-		logrus.Error(err)
16
-		return
17
-	}
18
-
19
-	return
20
-}
21 1
deleted file mode 100644
... ...
@@ -1,36 +0,0 @@
1
-package hcsshim
2
-
3
-import "github.com/Sirupsen/logrus"
4
-
5
-// PrepareLayer finds a mounted read-write layer matching layerId and enables the
6
-// the filesystem filter for use on that layer.  This requires the paths to all
7
-// parent layers, and is necessary in order to view or interact with the layer
8
-// as an actual filesystem (reading and writing files, creating directories, etc).
9
-// Disabling the filter must be done via UnprepareLayer.
10
-func PrepareLayer(info DriverInfo, layerId string, parentLayerPaths []string) error {
11
-	title := "hcsshim::PrepareLayer "
12
-	logrus.Debugf(title+"flavour %d layerId %s", info.Flavour, layerId)
13
-
14
-	// Generate layer descriptors
15
-	layers, err := layerPathsToDescriptors(parentLayerPaths)
16
-	if err != nil {
17
-		return err
18
-	}
19
-
20
-	// Convert info to API calling convention
21
-	infop, err := convertDriverInfo(info)
22
-	if err != nil {
23
-		logrus.Error(err)
24
-		return err
25
-	}
26
-
27
-	err = prepareLayer(&infop, layerId, layers)
28
-	if err != nil {
29
-		err = makeErrorf(err, title, "layerId=%s flavour=%d", layerId, info.Flavour)
30
-		logrus.Error(err)
31
-		return err
32
-	}
33
-
34
-	logrus.Debugf(title+"succeeded flavour=%d layerId=%s", info.Flavour, layerId)
35
-	return nil
36
-}
37 1
deleted file mode 100644
... ...
@@ -1,22 +0,0 @@
1
-package hcsshim
2
-
3
-import "github.com/Sirupsen/logrus"
4
-
5
-// ResizeConsoleInComputeSystem updates the height and width of the console
6
-// session for the process with the given id in the container with the given id.
7
-func ResizeConsoleInComputeSystem(id string, processid uint32, h, w int) error {
8
-
9
-	title := "HCSShim::ResizeConsoleInComputeSystem"
10
-	logrus.Debugf(title+" id=%s processid=%d (%d,%d)", id, processid, h, w)
11
-
12
-	err := resizeConsoleInComputeSystem(id, processid, uint16(h), uint16(w), 0)
13
-	if err != nil {
14
-		err = makeErrorf(err, title, "id=%s pid=%d", id, processid)
15
-		logrus.Error(err)
16
-		return err
17
-	}
18
-
19
-	logrus.Debugf(title+" succeeded id=%s processid=%d (%d,%d)", id, processid, h, w)
20
-	return nil
21
-
22
-}
23 1
deleted file mode 100644
... ...
@@ -1,44 +0,0 @@
1
-package hcsshim
2
-
3
-import "github.com/Sirupsen/logrus"
4
-
5
-// TerminateComputeSystem force terminates a container.
6
-func TerminateComputeSystem(id string, timeout uint32, context string) (uint32, error) {
7
-	return shutdownTerminate(false, id, timeout, context)
8
-}
9
-
10
-// ShutdownComputeSystem shuts down a container by requesting a shutdown within
11
-// the container operating system.
12
-func ShutdownComputeSystem(id string, timeout uint32, context string) (uint32, error) {
13
-	return shutdownTerminate(true, id, timeout, context)
14
-}
15
-
16
-// shutdownTerminate is a wrapper for ShutdownComputeSystem and TerminateComputeSystem
17
-// which have very similar calling semantics
18
-func shutdownTerminate(shutdown bool, id string, timeout uint32, context string) (uint32, error) {
19
-
20
-	var (
21
-		title = "HCSShim::"
22
-	)
23
-	if shutdown {
24
-		title = title + "ShutdownComputeSystem"
25
-	} else {
26
-		title = title + "TerminateComputeSystem"
27
-	}
28
-	logrus.Debugf(title+" id=%s context=%s", id, context)
29
-
30
-	var err error
31
-	if shutdown {
32
-		err = shutdownComputeSystem(id, timeout)
33
-	} else {
34
-		err = terminateComputeSystem(id)
35
-	}
36
-
37
-	if err != nil {
38
-		err := makeErrorf(err, title, "id=%s context=%s", id, context)
39
-		return err.HResult(), err
40
-	}
41
-
42
-	logrus.Debugf(title+" succeeded id=%s context=%s", id, context)
43
-	return 0, nil
44
-}
45 1
deleted file mode 100644
... ...
@@ -1,21 +0,0 @@
1
-package hcsshim
2
-
3
-import "github.com/Sirupsen/logrus"
4
-
5
-// StartComputeSystem starts a container that has previously been created via
6
-// CreateComputeSystem.
7
-func StartComputeSystem(id string) error {
8
-
9
-	title := "HCSShim::StartComputeSystem"
10
-	logrus.Debugf(title+" id=%s", id)
11
-
12
-	err := startComputeSystem(id)
13
-	if err != nil {
14
-		err = makeErrorf(err, title, "id=%s", id)
15
-		logrus.Error(err)
16
-		return err
17
-	}
18
-
19
-	logrus.Debugf(title+" succeeded id=%s", id)
20
-	return nil
21
-}
22 1
deleted file mode 100644
... ...
@@ -1,20 +0,0 @@
1
-package hcsshim
2
-
3
-import "github.com/Sirupsen/logrus"
4
-
5
-// TerminateProcessInComputeSystem kills a process in a running container.
6
-func TerminateProcessInComputeSystem(id string, processid uint32) (err error) {
7
-
8
-	title := "HCSShim::TerminateProcessInComputeSystem"
9
-	logrus.Debugf(title+" id=%s processid=%d", id, processid)
10
-
11
-	err = terminateProcessInComputeSystem(id, processid)
12
-	if err != nil {
13
-		err = makeErrorf(err, title, "err=%s id=%s", id)
14
-		logrus.Error(err)
15
-		return err
16
-	}
17
-
18
-	logrus.Debugf(title+" succeeded id=%s", id)
19
-	return nil
20
-}
21 1
deleted file mode 100644
... ...
@@ -1,27 +0,0 @@
1
-package hcsshim
2
-
3
-import "github.com/Sirupsen/logrus"
4
-
5
-// UnprepareLayer disables the filesystem filter for the read-write layer with
6
-// the given id.
7
-func UnprepareLayer(info DriverInfo, layerId string) error {
8
-	title := "hcsshim::UnprepareLayer "
9
-	logrus.Debugf(title+"flavour %d layerId %s", info.Flavour, layerId)
10
-
11
-	// Convert info to API calling convention
12
-	infop, err := convertDriverInfo(info)
13
-	if err != nil {
14
-		logrus.Error(err)
15
-		return err
16
-	}
17
-
18
-	err = unprepareLayer(&infop, layerId)
19
-	if err != nil {
20
-		err = makeErrorf(err, title, "layerId=%s flavour=%d", layerId, info.Flavour)
21
-		logrus.Error(err)
22
-		return err
23
-	}
24
-
25
-	logrus.Debugf(title+"succeeded flavour %d layerId=%s", info.Flavour, layerId)
26
-	return nil
27
-}
28 1
deleted file mode 100644
... ...
@@ -1,21 +0,0 @@
1
-package hcsshim
2
-
3
-import "github.com/Sirupsen/logrus"
4
-
5
-// WaitForProcessInComputeSystem waits for a process ID to terminate and returns
6
-// the exit code. Returns exitcode, errno, error
7
-func WaitForProcessInComputeSystem(id string, processid uint32, timeout uint32) (int32, uint32, error) {
8
-
9
-	title := "HCSShim::WaitForProcessInComputeSystem"
10
-	logrus.Debugf(title+" id=%s processid=%d", id, processid)
11
-
12
-	var exitCode uint32
13
-	err := waitForProcessInComputeSystem(id, processid, timeout, &exitCode)
14
-	if err != nil {
15
-		err := makeErrorf(err, title, "id=%s", id)
16
-		return 0, err.HResult(), err
17
-	}
18
-
19
-	logrus.Debugf(title+" succeeded id=%s processid=%d exitcode=%d", id, processid, exitCode)
20
-	return int32(exitCode), 0, nil
21
-}
22 1
deleted file mode 100644
... ...
@@ -1,559 +0,0 @@
1
-// MACHINE GENERATED BY 'go generate' COMMAND; DO NOT EDIT
2
-
3
-package hcsshim
4
-
5
-import "unsafe"
6
-import "syscall"
7
-
8
-var _ unsafe.Pointer
9
-
10
-var (
11
-	modole32     = syscall.NewLazyDLL("ole32.dll")
12
-	modvmcompute = syscall.NewLazyDLL("vmcompute.dll")
13
-
14
-	procCoTaskMemFree                              = modole32.NewProc("CoTaskMemFree")
15
-	procActivateLayer                              = modvmcompute.NewProc("ActivateLayer")
16
-	procCopyLayer                                  = modvmcompute.NewProc("CopyLayer")
17
-	procCreateLayer                                = modvmcompute.NewProc("CreateLayer")
18
-	procCreateSandboxLayer                         = modvmcompute.NewProc("CreateSandboxLayer")
19
-	procDeactivateLayer                            = modvmcompute.NewProc("DeactivateLayer")
20
-	procDestroyLayer                               = modvmcompute.NewProc("DestroyLayer")
21
-	procExportLayer                                = modvmcompute.NewProc("ExportLayer")
22
-	procGetLayerMountPath                          = modvmcompute.NewProc("GetLayerMountPath")
23
-	procGetBaseImages                              = modvmcompute.NewProc("GetBaseImages")
24
-	procImportLayer                                = modvmcompute.NewProc("ImportLayer")
25
-	procLayerExists                                = modvmcompute.NewProc("LayerExists")
26
-	procNameToGuid                                 = modvmcompute.NewProc("NameToGuid")
27
-	procPrepareLayer                               = modvmcompute.NewProc("PrepareLayer")
28
-	procUnprepareLayer                             = modvmcompute.NewProc("UnprepareLayer")
29
-	procCreateComputeSystem                        = modvmcompute.NewProc("CreateComputeSystem")
30
-	procCreateProcessWithStdHandlesInComputeSystem = modvmcompute.NewProc("CreateProcessWithStdHandlesInComputeSystem")
31
-	procResizeConsoleInComputeSystem               = modvmcompute.NewProc("ResizeConsoleInComputeSystem")
32
-	procShutdownComputeSystem                      = modvmcompute.NewProc("ShutdownComputeSystem")
33
-	procStartComputeSystem                         = modvmcompute.NewProc("StartComputeSystem")
34
-	procTerminateComputeSystem                     = modvmcompute.NewProc("TerminateComputeSystem")
35
-	procTerminateProcessInComputeSystem            = modvmcompute.NewProc("TerminateProcessInComputeSystem")
36
-	procWaitForProcessInComputeSystem              = modvmcompute.NewProc("WaitForProcessInComputeSystem")
37
-	procHNSCall                                    = modvmcompute.NewProc("HNSCall")
38
-)
39
-
40
-func coTaskMemFree(buffer unsafe.Pointer) {
41
-	syscall.Syscall(procCoTaskMemFree.Addr(), 1, uintptr(buffer), 0, 0)
42
-	return
43
-}
44
-
45
-func activateLayer(info *driverInfo, id string) (hr error) {
46
-	var _p0 *uint16
47
-	_p0, hr = syscall.UTF16PtrFromString(id)
48
-	if hr != nil {
49
-		return
50
-	}
51
-	return _activateLayer(info, _p0)
52
-}
53
-
54
-func _activateLayer(info *driverInfo, id *uint16) (hr error) {
55
-	if hr = procActivateLayer.Find(); hr != nil {
56
-		return
57
-	}
58
-	r0, _, _ := syscall.Syscall(procActivateLayer.Addr(), 2, uintptr(unsafe.Pointer(info)), uintptr(unsafe.Pointer(id)), 0)
59
-	if r0 != 0 {
60
-		hr = syscall.Errno(r0)
61
-	}
62
-	return
63
-}
64
-
65
-func copyLayer(info *driverInfo, srcId string, dstId string, descriptors []WC_LAYER_DESCRIPTOR) (hr error) {
66
-	var _p0 *uint16
67
-	_p0, hr = syscall.UTF16PtrFromString(srcId)
68
-	if hr != nil {
69
-		return
70
-	}
71
-	var _p1 *uint16
72
-	_p1, hr = syscall.UTF16PtrFromString(dstId)
73
-	if hr != nil {
74
-		return
75
-	}
76
-	return _copyLayer(info, _p0, _p1, descriptors)
77
-}
78
-
79
-func _copyLayer(info *driverInfo, srcId *uint16, dstId *uint16, descriptors []WC_LAYER_DESCRIPTOR) (hr error) {
80
-	var _p2 *WC_LAYER_DESCRIPTOR
81
-	if len(descriptors) > 0 {
82
-		_p2 = &descriptors[0]
83
-	}
84
-	if hr = procCopyLayer.Find(); hr != nil {
85
-		return
86
-	}
87
-	r0, _, _ := syscall.Syscall6(procCopyLayer.Addr(), 5, uintptr(unsafe.Pointer(info)), uintptr(unsafe.Pointer(srcId)), uintptr(unsafe.Pointer(dstId)), uintptr(unsafe.Pointer(_p2)), uintptr(len(descriptors)), 0)
88
-	if r0 != 0 {
89
-		hr = syscall.Errno(r0)
90
-	}
91
-	return
92
-}
93
-
94
-func createLayer(info *driverInfo, id string, parent string) (hr error) {
95
-	var _p0 *uint16
96
-	_p0, hr = syscall.UTF16PtrFromString(id)
97
-	if hr != nil {
98
-		return
99
-	}
100
-	var _p1 *uint16
101
-	_p1, hr = syscall.UTF16PtrFromString(parent)
102
-	if hr != nil {
103
-		return
104
-	}
105
-	return _createLayer(info, _p0, _p1)
106
-}
107
-
108
-func _createLayer(info *driverInfo, id *uint16, parent *uint16) (hr error) {
109
-	if hr = procCreateLayer.Find(); hr != nil {
110
-		return
111
-	}
112
-	r0, _, _ := syscall.Syscall(procCreateLayer.Addr(), 3, uintptr(unsafe.Pointer(info)), uintptr(unsafe.Pointer(id)), uintptr(unsafe.Pointer(parent)))
113
-	if r0 != 0 {
114
-		hr = syscall.Errno(r0)
115
-	}
116
-	return
117
-}
118
-
119
-func createSandboxLayer(info *driverInfo, id string, parent string, descriptors []WC_LAYER_DESCRIPTOR) (hr error) {
120
-	var _p0 *uint16
121
-	_p0, hr = syscall.UTF16PtrFromString(id)
122
-	if hr != nil {
123
-		return
124
-	}
125
-	var _p1 *uint16
126
-	_p1, hr = syscall.UTF16PtrFromString(parent)
127
-	if hr != nil {
128
-		return
129
-	}
130
-	return _createSandboxLayer(info, _p0, _p1, descriptors)
131
-}
132
-
133
-func _createSandboxLayer(info *driverInfo, id *uint16, parent *uint16, descriptors []WC_LAYER_DESCRIPTOR) (hr error) {
134
-	var _p2 *WC_LAYER_DESCRIPTOR
135
-	if len(descriptors) > 0 {
136
-		_p2 = &descriptors[0]
137
-	}
138
-	if hr = procCreateSandboxLayer.Find(); hr != nil {
139
-		return
140
-	}
141
-	r0, _, _ := syscall.Syscall6(procCreateSandboxLayer.Addr(), 5, uintptr(unsafe.Pointer(info)), uintptr(unsafe.Pointer(id)), uintptr(unsafe.Pointer(parent)), uintptr(unsafe.Pointer(_p2)), uintptr(len(descriptors)), 0)
142
-	if r0 != 0 {
143
-		hr = syscall.Errno(r0)
144
-	}
145
-	return
146
-}
147
-
148
-func deactivateLayer(info *driverInfo, id string) (hr error) {
149
-	var _p0 *uint16
150
-	_p0, hr = syscall.UTF16PtrFromString(id)
151
-	if hr != nil {
152
-		return
153
-	}
154
-	return _deactivateLayer(info, _p0)
155
-}
156
-
157
-func _deactivateLayer(info *driverInfo, id *uint16) (hr error) {
158
-	if hr = procDeactivateLayer.Find(); hr != nil {
159
-		return
160
-	}
161
-	r0, _, _ := syscall.Syscall(procDeactivateLayer.Addr(), 2, uintptr(unsafe.Pointer(info)), uintptr(unsafe.Pointer(id)), 0)
162
-	if r0 != 0 {
163
-		hr = syscall.Errno(r0)
164
-	}
165
-	return
166
-}
167
-
168
-func destroyLayer(info *driverInfo, id string) (hr error) {
169
-	var _p0 *uint16
170
-	_p0, hr = syscall.UTF16PtrFromString(id)
171
-	if hr != nil {
172
-		return
173
-	}
174
-	return _destroyLayer(info, _p0)
175
-}
176
-
177
-func _destroyLayer(info *driverInfo, id *uint16) (hr error) {
178
-	if hr = procDestroyLayer.Find(); hr != nil {
179
-		return
180
-	}
181
-	r0, _, _ := syscall.Syscall(procDestroyLayer.Addr(), 2, uintptr(unsafe.Pointer(info)), uintptr(unsafe.Pointer(id)), 0)
182
-	if r0 != 0 {
183
-		hr = syscall.Errno(r0)
184
-	}
185
-	return
186
-}
187
-
188
-func exportLayer(info *driverInfo, id string, path string, descriptors []WC_LAYER_DESCRIPTOR) (hr error) {
189
-	var _p0 *uint16
190
-	_p0, hr = syscall.UTF16PtrFromString(id)
191
-	if hr != nil {
192
-		return
193
-	}
194
-	var _p1 *uint16
195
-	_p1, hr = syscall.UTF16PtrFromString(path)
196
-	if hr != nil {
197
-		return
198
-	}
199
-	return _exportLayer(info, _p0, _p1, descriptors)
200
-}
201
-
202
-func _exportLayer(info *driverInfo, id *uint16, path *uint16, descriptors []WC_LAYER_DESCRIPTOR) (hr error) {
203
-	var _p2 *WC_LAYER_DESCRIPTOR
204
-	if len(descriptors) > 0 {
205
-		_p2 = &descriptors[0]
206
-	}
207
-	if hr = procExportLayer.Find(); hr != nil {
208
-		return
209
-	}
210
-	r0, _, _ := syscall.Syscall6(procExportLayer.Addr(), 5, uintptr(unsafe.Pointer(info)), uintptr(unsafe.Pointer(id)), uintptr(unsafe.Pointer(path)), uintptr(unsafe.Pointer(_p2)), uintptr(len(descriptors)), 0)
211
-	if r0 != 0 {
212
-		hr = syscall.Errno(r0)
213
-	}
214
-	return
215
-}
216
-
217
-func getLayerMountPath(info *driverInfo, id string, length *uintptr, buffer *uint16) (hr error) {
218
-	var _p0 *uint16
219
-	_p0, hr = syscall.UTF16PtrFromString(id)
220
-	if hr != nil {
221
-		return
222
-	}
223
-	return _getLayerMountPath(info, _p0, length, buffer)
224
-}
225
-
226
-func _getLayerMountPath(info *driverInfo, id *uint16, length *uintptr, buffer *uint16) (hr error) {
227
-	if hr = procGetLayerMountPath.Find(); hr != nil {
228
-		return
229
-	}
230
-	r0, _, _ := syscall.Syscall6(procGetLayerMountPath.Addr(), 4, uintptr(unsafe.Pointer(info)), uintptr(unsafe.Pointer(id)), uintptr(unsafe.Pointer(length)), uintptr(unsafe.Pointer(buffer)), 0, 0)
231
-	if r0 != 0 {
232
-		hr = syscall.Errno(r0)
233
-	}
234
-	return
235
-}
236
-
237
-func getBaseImages(buffer **uint16) (hr error) {
238
-	if hr = procGetBaseImages.Find(); hr != nil {
239
-		return
240
-	}
241
-	r0, _, _ := syscall.Syscall(procGetBaseImages.Addr(), 1, uintptr(unsafe.Pointer(buffer)), 0, 0)
242
-	if r0 != 0 {
243
-		hr = syscall.Errno(r0)
244
-	}
245
-	return
246
-}
247
-
248
-func importLayer(info *driverInfo, id string, path string, descriptors []WC_LAYER_DESCRIPTOR) (hr error) {
249
-	var _p0 *uint16
250
-	_p0, hr = syscall.UTF16PtrFromString(id)
251
-	if hr != nil {
252
-		return
253
-	}
254
-	var _p1 *uint16
255
-	_p1, hr = syscall.UTF16PtrFromString(path)
256
-	if hr != nil {
257
-		return
258
-	}
259
-	return _importLayer(info, _p0, _p1, descriptors)
260
-}
261
-
262
-func _importLayer(info *driverInfo, id *uint16, path *uint16, descriptors []WC_LAYER_DESCRIPTOR) (hr error) {
263
-	var _p2 *WC_LAYER_DESCRIPTOR
264
-	if len(descriptors) > 0 {
265
-		_p2 = &descriptors[0]
266
-	}
267
-	if hr = procImportLayer.Find(); hr != nil {
268
-		return
269
-	}
270
-	r0, _, _ := syscall.Syscall6(procImportLayer.Addr(), 5, uintptr(unsafe.Pointer(info)), uintptr(unsafe.Pointer(id)), uintptr(unsafe.Pointer(path)), uintptr(unsafe.Pointer(_p2)), uintptr(len(descriptors)), 0)
271
-	if r0 != 0 {
272
-		hr = syscall.Errno(r0)
273
-	}
274
-	return
275
-}
276
-
277
-func layerExists(info *driverInfo, id string, exists *uint32) (hr error) {
278
-	var _p0 *uint16
279
-	_p0, hr = syscall.UTF16PtrFromString(id)
280
-	if hr != nil {
281
-		return
282
-	}
283
-	return _layerExists(info, _p0, exists)
284
-}
285
-
286
-func _layerExists(info *driverInfo, id *uint16, exists *uint32) (hr error) {
287
-	if hr = procLayerExists.Find(); hr != nil {
288
-		return
289
-	}
290
-	r0, _, _ := syscall.Syscall(procLayerExists.Addr(), 3, uintptr(unsafe.Pointer(info)), uintptr(unsafe.Pointer(id)), uintptr(unsafe.Pointer(exists)))
291
-	if r0 != 0 {
292
-		hr = syscall.Errno(r0)
293
-	}
294
-	return
295
-}
296
-
297
-func nameToGuid(name string, guid *GUID) (hr error) {
298
-	var _p0 *uint16
299
-	_p0, hr = syscall.UTF16PtrFromString(name)
300
-	if hr != nil {
301
-		return
302
-	}
303
-	return _nameToGuid(_p0, guid)
304
-}
305
-
306
-func _nameToGuid(name *uint16, guid *GUID) (hr error) {
307
-	if hr = procNameToGuid.Find(); hr != nil {
308
-		return
309
-	}
310
-	r0, _, _ := syscall.Syscall(procNameToGuid.Addr(), 2, uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(guid)), 0)
311
-	if r0 != 0 {
312
-		hr = syscall.Errno(r0)
313
-	}
314
-	return
315
-}
316
-
317
-func prepareLayer(info *driverInfo, id string, descriptors []WC_LAYER_DESCRIPTOR) (hr error) {
318
-	var _p0 *uint16
319
-	_p0, hr = syscall.UTF16PtrFromString(id)
320
-	if hr != nil {
321
-		return
322
-	}
323
-	return _prepareLayer(info, _p0, descriptors)
324
-}
325
-
326
-func _prepareLayer(info *driverInfo, id *uint16, descriptors []WC_LAYER_DESCRIPTOR) (hr error) {
327
-	var _p1 *WC_LAYER_DESCRIPTOR
328
-	if len(descriptors) > 0 {
329
-		_p1 = &descriptors[0]
330
-	}
331
-	if hr = procPrepareLayer.Find(); hr != nil {
332
-		return
333
-	}
334
-	r0, _, _ := syscall.Syscall6(procPrepareLayer.Addr(), 4, uintptr(unsafe.Pointer(info)), uintptr(unsafe.Pointer(id)), uintptr(unsafe.Pointer(_p1)), uintptr(len(descriptors)), 0, 0)
335
-	if r0 != 0 {
336
-		hr = syscall.Errno(r0)
337
-	}
338
-	return
339
-}
340
-
341
-func unprepareLayer(info *driverInfo, id string) (hr error) {
342
-	var _p0 *uint16
343
-	_p0, hr = syscall.UTF16PtrFromString(id)
344
-	if hr != nil {
345
-		return
346
-	}
347
-	return _unprepareLayer(info, _p0)
348
-}
349
-
350
-func _unprepareLayer(info *driverInfo, id *uint16) (hr error) {
351
-	if hr = procUnprepareLayer.Find(); hr != nil {
352
-		return
353
-	}
354
-	r0, _, _ := syscall.Syscall(procUnprepareLayer.Addr(), 2, uintptr(unsafe.Pointer(info)), uintptr(unsafe.Pointer(id)), 0)
355
-	if r0 != 0 {
356
-		hr = syscall.Errno(r0)
357
-	}
358
-	return
359
-}
360
-
361
-func createComputeSystem(id string, configuration string) (hr error) {
362
-	var _p0 *uint16
363
-	_p0, hr = syscall.UTF16PtrFromString(id)
364
-	if hr != nil {
365
-		return
366
-	}
367
-	var _p1 *uint16
368
-	_p1, hr = syscall.UTF16PtrFromString(configuration)
369
-	if hr != nil {
370
-		return
371
-	}
372
-	return _createComputeSystem(_p0, _p1)
373
-}
374
-
375
-func _createComputeSystem(id *uint16, configuration *uint16) (hr error) {
376
-	if hr = procCreateComputeSystem.Find(); hr != nil {
377
-		return
378
-	}
379
-	r0, _, _ := syscall.Syscall(procCreateComputeSystem.Addr(), 2, uintptr(unsafe.Pointer(id)), uintptr(unsafe.Pointer(configuration)), 0)
380
-	if r0 != 0 {
381
-		hr = syscall.Errno(r0)
382
-	}
383
-	return
384
-}
385
-
386
-func createProcessWithStdHandlesInComputeSystem(id string, paramsJson string, pid *uint32, stdin *syscall.Handle, stdout *syscall.Handle, stderr *syscall.Handle) (hr error) {
387
-	var _p0 *uint16
388
-	_p0, hr = syscall.UTF16PtrFromString(id)
389
-	if hr != nil {
390
-		return
391
-	}
392
-	var _p1 *uint16
393
-	_p1, hr = syscall.UTF16PtrFromString(paramsJson)
394
-	if hr != nil {
395
-		return
396
-	}
397
-	return _createProcessWithStdHandlesInComputeSystem(_p0, _p1, pid, stdin, stdout, stderr)
398
-}
399
-
400
-func _createProcessWithStdHandlesInComputeSystem(id *uint16, paramsJson *uint16, pid *uint32, stdin *syscall.Handle, stdout *syscall.Handle, stderr *syscall.Handle) (hr error) {
401
-	if hr = procCreateProcessWithStdHandlesInComputeSystem.Find(); hr != nil {
402
-		return
403
-	}
404
-	r0, _, _ := syscall.Syscall6(procCreateProcessWithStdHandlesInComputeSystem.Addr(), 6, uintptr(unsafe.Pointer(id)), uintptr(unsafe.Pointer(paramsJson)), uintptr(unsafe.Pointer(pid)), uintptr(unsafe.Pointer(stdin)), uintptr(unsafe.Pointer(stdout)), uintptr(unsafe.Pointer(stderr)))
405
-	if r0 != 0 {
406
-		hr = syscall.Errno(r0)
407
-	}
408
-	return
409
-}
410
-
411
-func resizeConsoleInComputeSystem(id string, pid uint32, height uint16, width uint16, flags uint32) (hr error) {
412
-	var _p0 *uint16
413
-	_p0, hr = syscall.UTF16PtrFromString(id)
414
-	if hr != nil {
415
-		return
416
-	}
417
-	return _resizeConsoleInComputeSystem(_p0, pid, height, width, flags)
418
-}
419
-
420
-func _resizeConsoleInComputeSystem(id *uint16, pid uint32, height uint16, width uint16, flags uint32) (hr error) {
421
-	if hr = procResizeConsoleInComputeSystem.Find(); hr != nil {
422
-		return
423
-	}
424
-	r0, _, _ := syscall.Syscall6(procResizeConsoleInComputeSystem.Addr(), 5, uintptr(unsafe.Pointer(id)), uintptr(pid), uintptr(height), uintptr(width), uintptr(flags), 0)
425
-	if r0 != 0 {
426
-		hr = syscall.Errno(r0)
427
-	}
428
-	return
429
-}
430
-
431
-func shutdownComputeSystem(id string, timeout uint32) (hr error) {
432
-	var _p0 *uint16
433
-	_p0, hr = syscall.UTF16PtrFromString(id)
434
-	if hr != nil {
435
-		return
436
-	}
437
-	return _shutdownComputeSystem(_p0, timeout)
438
-}
439
-
440
-func _shutdownComputeSystem(id *uint16, timeout uint32) (hr error) {
441
-	if hr = procShutdownComputeSystem.Find(); hr != nil {
442
-		return
443
-	}
444
-	r0, _, _ := syscall.Syscall(procShutdownComputeSystem.Addr(), 2, uintptr(unsafe.Pointer(id)), uintptr(timeout), 0)
445
-	if r0 != 0 {
446
-		hr = syscall.Errno(r0)
447
-	}
448
-	return
449
-}
450
-
451
-func startComputeSystem(id string) (hr error) {
452
-	var _p0 *uint16
453
-	_p0, hr = syscall.UTF16PtrFromString(id)
454
-	if hr != nil {
455
-		return
456
-	}
457
-	return _startComputeSystem(_p0)
458
-}
459
-
460
-func _startComputeSystem(id *uint16) (hr error) {
461
-	if hr = procStartComputeSystem.Find(); hr != nil {
462
-		return
463
-	}
464
-	r0, _, _ := syscall.Syscall(procStartComputeSystem.Addr(), 1, uintptr(unsafe.Pointer(id)), 0, 0)
465
-	if r0 != 0 {
466
-		hr = syscall.Errno(r0)
467
-	}
468
-	return
469
-}
470
-
471
-func terminateComputeSystem(id string) (hr error) {
472
-	var _p0 *uint16
473
-	_p0, hr = syscall.UTF16PtrFromString(id)
474
-	if hr != nil {
475
-		return
476
-	}
477
-	return _terminateComputeSystem(_p0)
478
-}
479
-
480
-func _terminateComputeSystem(id *uint16) (hr error) {
481
-	if hr = procTerminateComputeSystem.Find(); hr != nil {
482
-		return
483
-	}
484
-	r0, _, _ := syscall.Syscall(procTerminateComputeSystem.Addr(), 1, uintptr(unsafe.Pointer(id)), 0, 0)
485
-	if r0 != 0 {
486
-		hr = syscall.Errno(r0)
487
-	}
488
-	return
489
-}
490
-
491
-func terminateProcessInComputeSystem(id string, pid uint32) (hr error) {
492
-	var _p0 *uint16
493
-	_p0, hr = syscall.UTF16PtrFromString(id)
494
-	if hr != nil {
495
-		return
496
-	}
497
-	return _terminateProcessInComputeSystem(_p0, pid)
498
-}
499
-
500
-func _terminateProcessInComputeSystem(id *uint16, pid uint32) (hr error) {
501
-	if hr = procTerminateProcessInComputeSystem.Find(); hr != nil {
502
-		return
503
-	}
504
-	r0, _, _ := syscall.Syscall(procTerminateProcessInComputeSystem.Addr(), 2, uintptr(unsafe.Pointer(id)), uintptr(pid), 0)
505
-	if r0 != 0 {
506
-		hr = syscall.Errno(r0)
507
-	}
508
-	return
509
-}
510
-
511
-func waitForProcessInComputeSystem(id string, pid uint32, timeout uint32, exitCode *uint32) (hr error) {
512
-	var _p0 *uint16
513
-	_p0, hr = syscall.UTF16PtrFromString(id)
514
-	if hr != nil {
515
-		return
516
-	}
517
-	return _waitForProcessInComputeSystem(_p0, pid, timeout, exitCode)
518
-}
519
-
520
-func _waitForProcessInComputeSystem(id *uint16, pid uint32, timeout uint32, exitCode *uint32) (hr error) {
521
-	if hr = procWaitForProcessInComputeSystem.Find(); hr != nil {
522
-		return
523
-	}
524
-	r0, _, _ := syscall.Syscall6(procWaitForProcessInComputeSystem.Addr(), 4, uintptr(unsafe.Pointer(id)), uintptr(pid), uintptr(timeout), uintptr(unsafe.Pointer(exitCode)), 0, 0)
525
-	if r0 != 0 {
526
-		hr = syscall.Errno(r0)
527
-	}
528
-	return
529
-}
530
-
531
-func _hnsCall(method string, path string, object string, response **uint16) (hr error) {
532
-	var _p0 *uint16
533
-	_p0, hr = syscall.UTF16PtrFromString(method)
534
-	if hr != nil {
535
-		return
536
-	}
537
-	var _p1 *uint16
538
-	_p1, hr = syscall.UTF16PtrFromString(path)
539
-	if hr != nil {
540
-		return
541
-	}
542
-	var _p2 *uint16
543
-	_p2, hr = syscall.UTF16PtrFromString(object)
544
-	if hr != nil {
545
-		return
546
-	}
547
-	return __hnsCall(_p0, _p1, _p2, response)
548
-}
549
-
550
-func __hnsCall(method *uint16, path *uint16, object *uint16, response **uint16) (hr error) {
551
-	if hr = procHNSCall.Find(); hr != nil {
552
-		return
553
-	}
554
-	r0, _, _ := syscall.Syscall6(procHNSCall.Addr(), 4, uintptr(unsafe.Pointer(method)), uintptr(unsafe.Pointer(path)), uintptr(unsafe.Pointer(object)), uintptr(unsafe.Pointer(response)), 0, 0)
555
-	if r0 != 0 {
556
-		hr = syscall.Errno(r0)
557
-	}
558
-	return
559
-}