Update dependencies for logrus rename
Signed-off-by: Derek McGowan <derek@mcgstyle.net>
This commit is contained in:
		
							
								
								
									
										2
									
								
								vendor/github.com/Microsoft/hcsshim/activatelayer.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								vendor/github.com/Microsoft/hcsshim/activatelayer.go
									
									
									
										generated
									
									
										vendored
									
									
								
							@@ -1,6 +1,6 @@
 | 
			
		||||
package hcsshim
 | 
			
		||||
 | 
			
		||||
import "github.com/Sirupsen/logrus"
 | 
			
		||||
import "github.com/sirupsen/logrus"
 | 
			
		||||
 | 
			
		||||
// ActivateLayer will find the layer with the given id and mount it's filesystem.
 | 
			
		||||
// For a read/write layer, the mounted filesystem will appear as a volume on the
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										108
									
								
								vendor/github.com/Microsoft/hcsshim/container.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										108
									
								
								vendor/github.com/Microsoft/hcsshim/container.go
									
									
									
										generated
									
									
										vendored
									
									
								
							@@ -4,12 +4,11 @@ import (
 | 
			
		||||
	"encoding/json"
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"os"
 | 
			
		||||
	"runtime"
 | 
			
		||||
	"sync"
 | 
			
		||||
	"syscall"
 | 
			
		||||
	"time"
 | 
			
		||||
 | 
			
		||||
	"github.com/Sirupsen/logrus"
 | 
			
		||||
	"github.com/sirupsen/logrus"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
var (
 | 
			
		||||
@@ -17,9 +16,10 @@ var (
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
const (
 | 
			
		||||
	pendingUpdatesQuery = `{ "PropertyTypes" : ["PendingUpdates"]}`
 | 
			
		||||
	statisticsQuery     = `{ "PropertyTypes" : ["Statistics"]}`
 | 
			
		||||
	processListQuery    = `{ "PropertyTypes" : ["ProcessList"]}`
 | 
			
		||||
	pendingUpdatesQuery    = `{ "PropertyTypes" : ["PendingUpdates"]}`
 | 
			
		||||
	statisticsQuery        = `{ "PropertyTypes" : ["Statistics"]}`
 | 
			
		||||
	processListQuery       = `{ "PropertyTypes" : ["ProcessList"]}`
 | 
			
		||||
	mappedVirtualDiskQuery = `{ "PropertyTypes" : ["MappedVirtualDisk"]}`
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
type container struct {
 | 
			
		||||
@@ -31,21 +31,21 @@ type container struct {
 | 
			
		||||
 | 
			
		||||
// ContainerProperties holds the properties for a container and the processes running in that container
 | 
			
		||||
type ContainerProperties struct {
 | 
			
		||||
	ID                string `json:"Id"`
 | 
			
		||||
	Name              string
 | 
			
		||||
	SystemType        string
 | 
			
		||||
	Owner             string
 | 
			
		||||
	SiloGUID          string            `json:"SiloGuid,omitempty"`
 | 
			
		||||
	IsDummy           bool              `json:",omitempty"`
 | 
			
		||||
	RuntimeID         string            `json:"RuntimeId,omitempty"`
 | 
			
		||||
	IsRuntimeTemplate bool              `json:",omitempty"`
 | 
			
		||||
	RuntimeImagePath  string            `json:",omitempty"`
 | 
			
		||||
	Stopped           bool              `json:",omitempty"`
 | 
			
		||||
	ExitType          string            `json:",omitempty"`
 | 
			
		||||
	AreUpdatesPending bool              `json:",omitempty"`
 | 
			
		||||
	ObRoot            string            `json:",omitempty"`
 | 
			
		||||
	Statistics        Statistics        `json:",omitempty"`
 | 
			
		||||
	ProcessList       []ProcessListItem `json:",omitempty"`
 | 
			
		||||
	ID                           string `json:"Id"`
 | 
			
		||||
	Name                         string
 | 
			
		||||
	SystemType                   string
 | 
			
		||||
	Owner                        string
 | 
			
		||||
	SiloGUID                     string                              `json:"SiloGuid,omitempty"`
 | 
			
		||||
	RuntimeID                    string                              `json:"RuntimeId,omitempty"`
 | 
			
		||||
	IsRuntimeTemplate            bool                                `json:",omitempty"`
 | 
			
		||||
	RuntimeImagePath             string                              `json:",omitempty"`
 | 
			
		||||
	Stopped                      bool                                `json:",omitempty"`
 | 
			
		||||
	ExitType                     string                              `json:",omitempty"`
 | 
			
		||||
	AreUpdatesPending            bool                                `json:",omitempty"`
 | 
			
		||||
	ObRoot                       string                              `json:",omitempty"`
 | 
			
		||||
	Statistics                   Statistics                          `json:",omitempty"`
 | 
			
		||||
	ProcessList                  []ProcessListItem                   `json:",omitempty"`
 | 
			
		||||
	MappedVirtualDiskControllers map[int]MappedVirtualDiskController `json:",omitempty"`
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// MemoryStats holds the memory statistics for a container
 | 
			
		||||
@@ -105,6 +105,11 @@ type ProcessListItem struct {
 | 
			
		||||
	UserTime100ns                uint64    `json:",omitempty"`
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// MappedVirtualDiskController is the structure of an item returned by a MappedVirtualDiskList call on a container
 | 
			
		||||
type MappedVirtualDiskController struct {
 | 
			
		||||
	MappedVirtualDisks map[int]MappedVirtualDisk `json:",omitempty"`
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Type of Request Support in ModifySystem
 | 
			
		||||
type RequestType string
 | 
			
		||||
 | 
			
		||||
@@ -122,7 +127,7 @@ const (
 | 
			
		||||
// Supported resource types are Network and Request Types are Add/Remove
 | 
			
		||||
type ResourceModificationRequestResponse struct {
 | 
			
		||||
	Resource ResourceType `json:"ResourceType"`
 | 
			
		||||
	Data     string       `json:"Settings"`
 | 
			
		||||
	Data     interface{}  `json:"Settings"`
 | 
			
		||||
	Request  RequestType  `json:"RequestType,omitempty"`
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -206,7 +211,6 @@ func createContainerWithJSON(id string, c *ContainerConfig, additionalJSON strin
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	logrus.Debugf(title+" succeeded id=%s handle=%d", id, container.handle)
 | 
			
		||||
	runtime.SetFinalizer(container, closeContainer)
 | 
			
		||||
	return container, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -264,7 +268,6 @@ func OpenContainer(id string) (Container, error) {
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	logrus.Debugf(title+" succeeded id=%s handle=%d", id, handle)
 | 
			
		||||
	runtime.SetFinalizer(container, closeContainer)
 | 
			
		||||
	return container, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -491,6 +494,55 @@ func (container *container) ProcessList() ([]ProcessListItem, error) {
 | 
			
		||||
	return properties.ProcessList, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// MappedVirtualDisks returns a map of the controllers and the disks mapped
 | 
			
		||||
// to a container.
 | 
			
		||||
//
 | 
			
		||||
// Example of JSON returned by the query.
 | 
			
		||||
//{
 | 
			
		||||
//   "Id":"1126e8d7d279c707a666972a15976371d365eaf622c02cea2c442b84f6f550a3_svm",
 | 
			
		||||
//   "SystemType":"Container",
 | 
			
		||||
//   "RuntimeOsType":"Linux",
 | 
			
		||||
//   "RuntimeId":"00000000-0000-0000-0000-000000000000",
 | 
			
		||||
//   "State":"Running",
 | 
			
		||||
//   "MappedVirtualDiskControllers":{
 | 
			
		||||
//      "0":{
 | 
			
		||||
//         "MappedVirtualDisks":{
 | 
			
		||||
//            "2":{
 | 
			
		||||
//               "HostPath":"C:\\lcow\\lcow\\scratch\\1126e8d7d279c707a666972a15976371d365eaf622c02cea2c442b84f6f550a3.vhdx",
 | 
			
		||||
//               "ContainerPath":"/mnt/gcs/LinuxServiceVM/scratch",
 | 
			
		||||
//               "Lun":2,
 | 
			
		||||
//               "CreateInUtilityVM":true
 | 
			
		||||
//            },
 | 
			
		||||
//            "3":{
 | 
			
		||||
//               "HostPath":"C:\\lcow\\lcow\\1126e8d7d279c707a666972a15976371d365eaf622c02cea2c442b84f6f550a3\\sandbox.vhdx",
 | 
			
		||||
//               "Lun":3,
 | 
			
		||||
//               "CreateInUtilityVM":true,
 | 
			
		||||
//               "AttachOnly":true
 | 
			
		||||
//            }
 | 
			
		||||
//         }
 | 
			
		||||
//      }
 | 
			
		||||
//   }
 | 
			
		||||
//}
 | 
			
		||||
func (container *container) MappedVirtualDisks() (map[int]MappedVirtualDiskController, error) {
 | 
			
		||||
	container.handleLock.RLock()
 | 
			
		||||
	defer container.handleLock.RUnlock()
 | 
			
		||||
	operation := "MappedVirtualDiskList"
 | 
			
		||||
	title := "HCSShim::Container::" + operation
 | 
			
		||||
	logrus.Debugf(title+" id=%s", container.id)
 | 
			
		||||
 | 
			
		||||
	if container.handle == 0 {
 | 
			
		||||
		return nil, makeContainerError(container, operation, "", ErrAlreadyClosed)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	properties, err := container.properties(mappedVirtualDiskQuery)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, makeContainerError(container, operation, "", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	logrus.Debugf(title+" succeeded id=%s", container.id)
 | 
			
		||||
	return properties.MappedVirtualDiskControllers, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Pause pauses the execution of the container. This feature is not enabled in TP5.
 | 
			
		||||
func (container *container) Pause() error {
 | 
			
		||||
	container.handleLock.RLock()
 | 
			
		||||
@@ -588,8 +640,7 @@ func (container *container) CreateProcess(c *ProcessConfig) (Process, error) {
 | 
			
		||||
		return nil, makeContainerError(container, operation, "", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	logrus.Debugf(title+" succeeded id=%s processid=%s", container.id, process.processID)
 | 
			
		||||
	runtime.SetFinalizer(process, closeProcess)
 | 
			
		||||
	logrus.Debugf(title+" succeeded id=%s processid=%d", container.id, process.processID)
 | 
			
		||||
	return process, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -626,7 +677,6 @@ func (container *container) OpenProcess(pid int) (Process, error) {
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	logrus.Debugf(title+" succeeded id=%s processid=%s", container.id, process.processID)
 | 
			
		||||
	runtime.SetFinalizer(process, closeProcess)
 | 
			
		||||
	return process, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -652,17 +702,11 @@ func (container *container) Close() error {
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	container.handle = 0
 | 
			
		||||
	runtime.SetFinalizer(container, nil)
 | 
			
		||||
 | 
			
		||||
	logrus.Debugf(title+" succeeded id=%s", container.id)
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// closeContainer wraps container.Close for use by a finalizer
 | 
			
		||||
func closeContainer(container *container) {
 | 
			
		||||
	container.Close()
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (container *container) registerCallback() error {
 | 
			
		||||
	context := ¬ifcationWatcherContext{
 | 
			
		||||
		channels: newChannels(),
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										2
									
								
								vendor/github.com/Microsoft/hcsshim/createlayer.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								vendor/github.com/Microsoft/hcsshim/createlayer.go
									
									
									
										generated
									
									
										vendored
									
									
								
							@@ -1,6 +1,6 @@
 | 
			
		||||
package hcsshim
 | 
			
		||||
 | 
			
		||||
import "github.com/Sirupsen/logrus"
 | 
			
		||||
import "github.com/sirupsen/logrus"
 | 
			
		||||
 | 
			
		||||
// CreateLayer creates a new, empty, read-only layer on the filesystem based on
 | 
			
		||||
// the parent layer provided.
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										2
									
								
								vendor/github.com/Microsoft/hcsshim/createsandboxlayer.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								vendor/github.com/Microsoft/hcsshim/createsandboxlayer.go
									
									
									
										generated
									
									
										vendored
									
									
								
							@@ -1,6 +1,6 @@
 | 
			
		||||
package hcsshim
 | 
			
		||||
 | 
			
		||||
import "github.com/Sirupsen/logrus"
 | 
			
		||||
import "github.com/sirupsen/logrus"
 | 
			
		||||
 | 
			
		||||
// CreateSandboxLayer creates and populates new read-write layer for use by a container.
 | 
			
		||||
// This requires both the id of the direct parent layer, as well as the full list
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										2
									
								
								vendor/github.com/Microsoft/hcsshim/deactivatelayer.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								vendor/github.com/Microsoft/hcsshim/deactivatelayer.go
									
									
									
										generated
									
									
										vendored
									
									
								
							@@ -1,6 +1,6 @@
 | 
			
		||||
package hcsshim
 | 
			
		||||
 | 
			
		||||
import "github.com/Sirupsen/logrus"
 | 
			
		||||
import "github.com/sirupsen/logrus"
 | 
			
		||||
 | 
			
		||||
// DeactivateLayer will dismount a layer that was mounted via ActivateLayer.
 | 
			
		||||
func DeactivateLayer(info DriverInfo, id string) error {
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										2
									
								
								vendor/github.com/Microsoft/hcsshim/destroylayer.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								vendor/github.com/Microsoft/hcsshim/destroylayer.go
									
									
									
										generated
									
									
										vendored
									
									
								
							@@ -1,6 +1,6 @@
 | 
			
		||||
package hcsshim
 | 
			
		||||
 | 
			
		||||
import "github.com/Sirupsen/logrus"
 | 
			
		||||
import "github.com/sirupsen/logrus"
 | 
			
		||||
 | 
			
		||||
// DestroyLayer will remove the on-disk files representing the layer with the given
 | 
			
		||||
// id, including that layer's containing folder, if any.
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										2
									
								
								vendor/github.com/Microsoft/hcsshim/expandsandboxsize.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								vendor/github.com/Microsoft/hcsshim/expandsandboxsize.go
									
									
									
										generated
									
									
										vendored
									
									
								
							@@ -1,6 +1,6 @@
 | 
			
		||||
package hcsshim
 | 
			
		||||
 | 
			
		||||
import "github.com/Sirupsen/logrus"
 | 
			
		||||
import "github.com/sirupsen/logrus"
 | 
			
		||||
 | 
			
		||||
// ExpandSandboxSize expands the size of a layer to at least size bytes.
 | 
			
		||||
func ExpandSandboxSize(info DriverInfo, layerId string, size uint64) error {
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										4
									
								
								vendor/github.com/Microsoft/hcsshim/exportlayer.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										4
									
								
								vendor/github.com/Microsoft/hcsshim/exportlayer.go
									
									
									
										generated
									
									
										vendored
									
									
								
							@@ -4,11 +4,10 @@ import (
 | 
			
		||||
	"io"
 | 
			
		||||
	"io/ioutil"
 | 
			
		||||
	"os"
 | 
			
		||||
	"runtime"
 | 
			
		||||
	"syscall"
 | 
			
		||||
 | 
			
		||||
	"github.com/Microsoft/go-winio"
 | 
			
		||||
	"github.com/Sirupsen/logrus"
 | 
			
		||||
	"github.com/sirupsen/logrus"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// ExportLayer will create a folder at exportFolderPath and fill that folder with
 | 
			
		||||
@@ -143,7 +142,6 @@ func NewLayerReader(info DriverInfo, layerID string, parentLayerPaths []string)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, makeError(err, "ExportLayerBegin", "")
 | 
			
		||||
	}
 | 
			
		||||
	runtime.SetFinalizer(r, func(r *FilterLayerReader) { r.Close() })
 | 
			
		||||
	return r, err
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										2
									
								
								vendor/github.com/Microsoft/hcsshim/getlayermountpath.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								vendor/github.com/Microsoft/hcsshim/getlayermountpath.go
									
									
									
										generated
									
									
										vendored
									
									
								
							@@ -3,7 +3,7 @@ package hcsshim
 | 
			
		||||
import (
 | 
			
		||||
	"syscall"
 | 
			
		||||
 | 
			
		||||
	"github.com/Sirupsen/logrus"
 | 
			
		||||
	"github.com/sirupsen/logrus"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// GetLayerMountPath will look for a mounted layer with the given id and return
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										2
									
								
								vendor/github.com/Microsoft/hcsshim/getsharedbaseimages.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								vendor/github.com/Microsoft/hcsshim/getsharedbaseimages.go
									
									
									
										generated
									
									
										vendored
									
									
								
							@@ -1,6 +1,6 @@
 | 
			
		||||
package hcsshim
 | 
			
		||||
 | 
			
		||||
import "github.com/Sirupsen/logrus"
 | 
			
		||||
import "github.com/sirupsen/logrus"
 | 
			
		||||
 | 
			
		||||
// GetSharedBaseImages will enumerate the images stored in the common central
 | 
			
		||||
// image store and return descriptive info about those images for the purpose
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										2
									
								
								vendor/github.com/Microsoft/hcsshim/hcsshim.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								vendor/github.com/Microsoft/hcsshim/hcsshim.go
									
									
									
										generated
									
									
										vendored
									
									
								
							@@ -8,7 +8,7 @@ import (
 | 
			
		||||
	"syscall"
 | 
			
		||||
	"unsafe"
 | 
			
		||||
 | 
			
		||||
	"github.com/Sirupsen/logrus"
 | 
			
		||||
	"github.com/sirupsen/logrus"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
//go:generate go run mksyscall_windows.go -output zhcsshim.go hcsshim.go
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										183
									
								
								vendor/github.com/Microsoft/hcsshim/hnsendpoint.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										183
									
								
								vendor/github.com/Microsoft/hcsshim/hnsendpoint.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,183 @@
 | 
			
		||||
package hcsshim
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"encoding/json"
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"net"
 | 
			
		||||
 | 
			
		||||
	"github.com/sirupsen/logrus"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// HNSEndpoint represents a network endpoint in HNS
 | 
			
		||||
type HNSEndpoint struct {
 | 
			
		||||
	Id                 string            `json:"ID,omitempty"`
 | 
			
		||||
	Name               string            `json:",omitempty"`
 | 
			
		||||
	VirtualNetwork     string            `json:",omitempty"`
 | 
			
		||||
	VirtualNetworkName string            `json:",omitempty"`
 | 
			
		||||
	Policies           []json.RawMessage `json:",omitempty"`
 | 
			
		||||
	MacAddress         string            `json:",omitempty"`
 | 
			
		||||
	IPAddress          net.IP            `json:",omitempty"`
 | 
			
		||||
	DNSSuffix          string            `json:",omitempty"`
 | 
			
		||||
	DNSServerList      string            `json:",omitempty"`
 | 
			
		||||
	GatewayAddress     string            `json:",omitempty"`
 | 
			
		||||
	EnableInternalDNS  bool              `json:",omitempty"`
 | 
			
		||||
	DisableICC         bool              `json:",omitempty"`
 | 
			
		||||
	PrefixLength       uint8             `json:",omitempty"`
 | 
			
		||||
	IsRemoteEndpoint   bool              `json:",omitempty"`
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// HNSEndpointRequest makes a HNS call to modify/query a network endpoint
 | 
			
		||||
func HNSEndpointRequest(method, path, request string) (*HNSEndpoint, error) {
 | 
			
		||||
	endpoint := &HNSEndpoint{}
 | 
			
		||||
	err := hnsCall(method, "/endpoints/"+path, request, &endpoint)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return endpoint, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// HNSListEndpointRequest makes a HNS call to query the list of available endpoints
 | 
			
		||||
func HNSListEndpointRequest() ([]HNSEndpoint, error) {
 | 
			
		||||
	var endpoint []HNSEndpoint
 | 
			
		||||
	err := hnsCall("GET", "/endpoints/", "", &endpoint)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return endpoint, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// HotAttachEndpoint makes a HCS Call to attach the endpoint to the container
 | 
			
		||||
func HotAttachEndpoint(containerID string, endpointID string) error {
 | 
			
		||||
	return modifyNetworkEndpoint(containerID, endpointID, Add)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// HotDetachEndpoint makes a HCS Call to detach the endpoint from the container
 | 
			
		||||
func HotDetachEndpoint(containerID string, endpointID string) error {
 | 
			
		||||
	return modifyNetworkEndpoint(containerID, endpointID, Remove)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// ModifyContainer corresponding to the container id, by sending a request
 | 
			
		||||
func modifyContainer(id string, request *ResourceModificationRequestResponse) error {
 | 
			
		||||
	container, err := OpenContainer(id)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		if IsNotExist(err) {
 | 
			
		||||
			return ErrComputeSystemDoesNotExist
 | 
			
		||||
		}
 | 
			
		||||
		return getInnerError(err)
 | 
			
		||||
	}
 | 
			
		||||
	defer container.Close()
 | 
			
		||||
	err = container.Modify(request)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		if IsNotSupported(err) {
 | 
			
		||||
			return ErrPlatformNotSupported
 | 
			
		||||
		}
 | 
			
		||||
		return getInnerError(err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func modifyNetworkEndpoint(containerID string, endpointID string, request RequestType) error {
 | 
			
		||||
	requestMessage := &ResourceModificationRequestResponse{
 | 
			
		||||
		Resource: Network,
 | 
			
		||||
		Request:  request,
 | 
			
		||||
		Data:     endpointID,
 | 
			
		||||
	}
 | 
			
		||||
	err := modifyContainer(containerID, requestMessage)
 | 
			
		||||
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// GetHNSEndpointByID
 | 
			
		||||
func GetHNSEndpointByID(endpointID string) (*HNSEndpoint, error) {
 | 
			
		||||
	return HNSEndpointRequest("GET", endpointID, "")
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// GetHNSNetworkName filtered by Name
 | 
			
		||||
func GetHNSEndpointByName(endpointName string) (*HNSEndpoint, error) {
 | 
			
		||||
	hnsResponse, err := HNSListEndpointRequest()
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
	for _, hnsEndpoint := range hnsResponse {
 | 
			
		||||
		if hnsEndpoint.Name == endpointName {
 | 
			
		||||
			return &hnsEndpoint, nil
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	return nil, fmt.Errorf("Endpoint %v not found", endpointName)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Create Endpoint by sending EndpointRequest to HNS. TODO: Create a separate HNS interface to place all these methods
 | 
			
		||||
func (endpoint *HNSEndpoint) Create() (*HNSEndpoint, error) {
 | 
			
		||||
	operation := "Create"
 | 
			
		||||
	title := "HCSShim::HNSEndpoint::" + operation
 | 
			
		||||
	logrus.Debugf(title+" id=%s", endpoint.Id)
 | 
			
		||||
 | 
			
		||||
	jsonString, err := json.Marshal(endpoint)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
	return HNSEndpointRequest("POST", "", string(jsonString))
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Delete Endpoint by sending EndpointRequest to HNS
 | 
			
		||||
func (endpoint *HNSEndpoint) Delete() (*HNSEndpoint, error) {
 | 
			
		||||
	operation := "Delete"
 | 
			
		||||
	title := "HCSShim::HNSEndpoint::" + operation
 | 
			
		||||
	logrus.Debugf(title+" id=%s", endpoint.Id)
 | 
			
		||||
 | 
			
		||||
	return HNSEndpointRequest("DELETE", endpoint.Id, "")
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Delete Endpoint by sending EndpointRequest to HNS
 | 
			
		||||
func (endpoint *HNSEndpoint) Update() (*HNSEndpoint, error) {
 | 
			
		||||
	operation := "Update"
 | 
			
		||||
	title := "HCSShim::HNSEndpoint::" + operation
 | 
			
		||||
	logrus.Debugf(title+" id=%s", endpoint.Id)
 | 
			
		||||
	jsonString, err := json.Marshal(endpoint)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
	err = hnsCall("POST", "/endpoints/"+endpoint.Id+"/update", string(jsonString), &endpoint)
 | 
			
		||||
 | 
			
		||||
	return endpoint, err
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Hot Attach an endpoint to a container
 | 
			
		||||
func (endpoint *HNSEndpoint) HotAttach(containerID string) error {
 | 
			
		||||
	operation := "HotAttach"
 | 
			
		||||
	title := "HCSShim::HNSEndpoint::" + operation
 | 
			
		||||
	logrus.Debugf(title+" id=%s, containerId=%s", endpoint.Id, containerID)
 | 
			
		||||
 | 
			
		||||
	return modifyNetworkEndpoint(containerID, endpoint.Id, Add)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Hot Detach an endpoint from a container
 | 
			
		||||
func (endpoint *HNSEndpoint) HotDetach(containerID string) error {
 | 
			
		||||
	operation := "HotDetach"
 | 
			
		||||
	title := "HCSShim::HNSEndpoint::" + operation
 | 
			
		||||
	logrus.Debugf(title+" id=%s, containerId=%s", endpoint.Id, containerID)
 | 
			
		||||
 | 
			
		||||
	return modifyNetworkEndpoint(containerID, endpoint.Id, Remove)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Apply Acl Policy on the Endpoint
 | 
			
		||||
func (endpoint *HNSEndpoint) ApplyACLPolicy(policy *ACLPolicy) error {
 | 
			
		||||
	operation := "ApplyACLPolicy"
 | 
			
		||||
	title := "HCSShim::HNSEndpoint::" + operation
 | 
			
		||||
	logrus.Debugf(title+" id=%s", endpoint.Id)
 | 
			
		||||
 | 
			
		||||
	jsonString, err := json.Marshal(policy)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return err
 | 
			
		||||
	}
 | 
			
		||||
	endpoint.Policies[0] = jsonString
 | 
			
		||||
	_, err = endpoint.Update()
 | 
			
		||||
	return err
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										233
									
								
								vendor/github.com/Microsoft/hcsshim/hnsfuncs.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										233
									
								
								vendor/github.com/Microsoft/hcsshim/hnsfuncs.go
									
									
									
										generated
									
									
										vendored
									
									
								
							@@ -3,99 +3,10 @@ package hcsshim
 | 
			
		||||
import (
 | 
			
		||||
	"encoding/json"
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"net"
 | 
			
		||||
 | 
			
		||||
	"github.com/Sirupsen/logrus"
 | 
			
		||||
	"github.com/sirupsen/logrus"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
type NatPolicy struct {
 | 
			
		||||
	Type         string
 | 
			
		||||
	Protocol     string
 | 
			
		||||
	InternalPort uint16
 | 
			
		||||
	ExternalPort uint16
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type QosPolicy struct {
 | 
			
		||||
	Type                            string
 | 
			
		||||
	MaximumOutgoingBandwidthInBytes uint64
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type VlanPolicy struct {
 | 
			
		||||
	Type string
 | 
			
		||||
	VLAN uint
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type VsidPolicy struct {
 | 
			
		||||
	Type string
 | 
			
		||||
	VSID uint
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type PaPolicy struct {
 | 
			
		||||
	Type string
 | 
			
		||||
	PA   string
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Subnet is assoicated with a network and represents a list
 | 
			
		||||
// of subnets available to the network
 | 
			
		||||
type Subnet struct {
 | 
			
		||||
	AddressPrefix  string            `json:",omitempty"`
 | 
			
		||||
	GatewayAddress string            `json:",omitempty"`
 | 
			
		||||
	Policies       []json.RawMessage `json:",omitempty"`
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// MacPool is assoicated with a network and represents a list
 | 
			
		||||
// of macaddresses available to the network
 | 
			
		||||
type MacPool struct {
 | 
			
		||||
	StartMacAddress string `json:",omitempty"`
 | 
			
		||||
	EndMacAddress   string `json:",omitempty"`
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// HNSNetwork represents a network in HNS
 | 
			
		||||
type HNSNetwork struct {
 | 
			
		||||
	Id                   string            `json:"ID,omitempty"`
 | 
			
		||||
	Name                 string            `json:",omitempty"`
 | 
			
		||||
	Type                 string            `json:",omitempty"`
 | 
			
		||||
	NetworkAdapterName   string            `json:",omitempty"`
 | 
			
		||||
	SourceMac            string            `json:",omitempty"`
 | 
			
		||||
	Policies             []json.RawMessage `json:",omitempty"`
 | 
			
		||||
	MacPools             []MacPool         `json:",omitempty"`
 | 
			
		||||
	Subnets              []Subnet          `json:",omitempty"`
 | 
			
		||||
	DNSSuffix            string            `json:",omitempty"`
 | 
			
		||||
	DNSServerList        string            `json:",omitempty"`
 | 
			
		||||
	DNSServerCompartment uint32            `json:",omitempty"`
 | 
			
		||||
	ManagementIP         string            `json:",omitempty"`
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// HNSEndpoint represents a network endpoint in HNS
 | 
			
		||||
type HNSEndpoint struct {
 | 
			
		||||
	Id                 string            `json:"ID,omitempty"`
 | 
			
		||||
	Name               string            `json:",omitempty"`
 | 
			
		||||
	VirtualNetwork     string            `json:",omitempty"`
 | 
			
		||||
	VirtualNetworkName string            `json:",omitempty"`
 | 
			
		||||
	Policies           []json.RawMessage `json:",omitempty"`
 | 
			
		||||
	MacAddress         string            `json:",omitempty"`
 | 
			
		||||
	IPAddress          net.IP            `json:",omitempty"`
 | 
			
		||||
	DNSSuffix          string            `json:",omitempty"`
 | 
			
		||||
	DNSServerList      string            `json:",omitempty"`
 | 
			
		||||
	GatewayAddress     string            `json:",omitempty"`
 | 
			
		||||
	EnableInternalDNS  bool              `json:",omitempty"`
 | 
			
		||||
	DisableICC         bool              `json:",omitempty"`
 | 
			
		||||
	PrefixLength       uint8             `json:",omitempty"`
 | 
			
		||||
	IsRemoteEndpoint   bool              `json:",omitempty"`
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type hnsNetworkResponse struct {
 | 
			
		||||
	Success bool
 | 
			
		||||
	Error   string
 | 
			
		||||
	Output  HNSNetwork
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type hnsResponse struct {
 | 
			
		||||
	Success bool
 | 
			
		||||
	Error   string
 | 
			
		||||
	Output  json.RawMessage
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func hnsCall(method, path, request string, returnResponse interface{}) error {
 | 
			
		||||
	var responseBuffer *uint16
 | 
			
		||||
	logrus.Debugf("[%s]=>[%s] Request : %s", method, path, request)
 | 
			
		||||
@@ -127,145 +38,3 @@ func hnsCall(method, path, request string, returnResponse interface{}) error {
 | 
			
		||||
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// HNSNetworkRequest makes a call into HNS to update/query a single network
 | 
			
		||||
func HNSNetworkRequest(method, path, request string) (*HNSNetwork, error) {
 | 
			
		||||
	var network HNSNetwork
 | 
			
		||||
	err := hnsCall(method, "/networks/"+path, request, &network)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return &network, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// HNSListNetworkRequest makes a HNS call to query the list of available networks
 | 
			
		||||
func HNSListNetworkRequest(method, path, request string) ([]HNSNetwork, error) {
 | 
			
		||||
	var network []HNSNetwork
 | 
			
		||||
	err := hnsCall(method, "/networks/"+path, request, &network)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return network, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// HNSEndpointRequest makes a HNS call to modify/query a network endpoint
 | 
			
		||||
func HNSEndpointRequest(method, path, request string) (*HNSEndpoint, error) {
 | 
			
		||||
	endpoint := &HNSEndpoint{}
 | 
			
		||||
	err := hnsCall(method, "/endpoints/"+path, request, &endpoint)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return endpoint, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// HNSListEndpointRequest makes a HNS call to query the list of available endpoints
 | 
			
		||||
func HNSListEndpointRequest() ([]HNSEndpoint, error) {
 | 
			
		||||
	var endpoint []HNSEndpoint
 | 
			
		||||
	err := hnsCall("GET", "/endpoints/", "", &endpoint)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return endpoint, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// HotAttachEndpoint makes a HCS Call to attach the endpoint to the container
 | 
			
		||||
func HotAttachEndpoint(containerID string, endpointID string) error {
 | 
			
		||||
	return modifyNetworkEndpoint(containerID, endpointID, Add)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// HotDetachEndpoint makes a HCS Call to detach the endpoint from the container
 | 
			
		||||
func HotDetachEndpoint(containerID string, endpointID string) error {
 | 
			
		||||
	return modifyNetworkEndpoint(containerID, endpointID, Remove)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// ModifyContainer corresponding to the container id, by sending a request
 | 
			
		||||
func modifyContainer(id string, request *ResourceModificationRequestResponse) error {
 | 
			
		||||
	container, err := OpenContainer(id)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		if IsNotExist(err) {
 | 
			
		||||
			return ErrComputeSystemDoesNotExist
 | 
			
		||||
		}
 | 
			
		||||
		return getInnerError(err)
 | 
			
		||||
	}
 | 
			
		||||
	defer container.Close()
 | 
			
		||||
	err = container.Modify(request)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		if IsNotSupported(err) {
 | 
			
		||||
			return ErrPlatformNotSupported
 | 
			
		||||
		}
 | 
			
		||||
		return getInnerError(err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func modifyNetworkEndpoint(containerID string, endpointID string, request RequestType) error {
 | 
			
		||||
	requestMessage := &ResourceModificationRequestResponse{
 | 
			
		||||
		Resource: Network,
 | 
			
		||||
		Request:  request,
 | 
			
		||||
		Data:     endpointID,
 | 
			
		||||
	}
 | 
			
		||||
	err := modifyContainer(containerID, requestMessage)
 | 
			
		||||
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// GetHNSNetworkByID
 | 
			
		||||
func GetHNSNetworkByID(networkID string) (*HNSNetwork, error) {
 | 
			
		||||
	return HNSNetworkRequest("GET", networkID, "")
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// GetHNSNetworkName filtered by Name
 | 
			
		||||
func GetHNSNetworkByName(networkName string) (*HNSNetwork, error) {
 | 
			
		||||
	hsnnetworks, err := HNSListNetworkRequest("GET", "", "")
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
	for _, hnsnetwork := range hsnnetworks {
 | 
			
		||||
		if hnsnetwork.Name == networkName {
 | 
			
		||||
			return &hnsnetwork, nil
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	return nil, fmt.Errorf("Network %v not found", networkName)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Create Endpoint by sending EndpointRequest to HNS. TODO: Create a separate HNS interface to place all these methods
 | 
			
		||||
func (endpoint *HNSEndpoint) Create() (*HNSEndpoint, error) {
 | 
			
		||||
	jsonString, err := json.Marshal(endpoint)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
	return HNSEndpointRequest("POST", "", string(jsonString))
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Create Endpoint by sending EndpointRequest to HNS
 | 
			
		||||
func (endpoint *HNSEndpoint) Delete() (*HNSEndpoint, error) {
 | 
			
		||||
	return HNSEndpointRequest("DELETE", endpoint.Id, "")
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// GetHNSEndpointByID
 | 
			
		||||
func GetHNSEndpointByID(endpointID string) (*HNSEndpoint, error) {
 | 
			
		||||
	return HNSEndpointRequest("GET", endpointID, "")
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// GetHNSNetworkName filtered by Name
 | 
			
		||||
func GetHNSEndpointByName(endpointName string) (*HNSEndpoint, error) {
 | 
			
		||||
	hnsResponse, err := HNSListEndpointRequest()
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
	for _, hnsEndpoint := range hnsResponse {
 | 
			
		||||
		if hnsEndpoint.Name == endpointName {
 | 
			
		||||
			return &hnsEndpoint, nil
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	return nil, fmt.Errorf("Endpoint %v not found", endpointName)
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										142
									
								
								vendor/github.com/Microsoft/hcsshim/hnsnetwork.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										142
									
								
								vendor/github.com/Microsoft/hcsshim/hnsnetwork.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,142 @@
 | 
			
		||||
package hcsshim
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"encoding/json"
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"net"
 | 
			
		||||
 | 
			
		||||
	"github.com/sirupsen/logrus"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// Subnet is assoicated with a network and represents a list
 | 
			
		||||
// of subnets available to the network
 | 
			
		||||
type Subnet struct {
 | 
			
		||||
	AddressPrefix  string            `json:",omitempty"`
 | 
			
		||||
	GatewayAddress string            `json:",omitempty"`
 | 
			
		||||
	Policies       []json.RawMessage `json:",omitempty"`
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// MacPool is assoicated with a network and represents a list
 | 
			
		||||
// of macaddresses available to the network
 | 
			
		||||
type MacPool struct {
 | 
			
		||||
	StartMacAddress string `json:",omitempty"`
 | 
			
		||||
	EndMacAddress   string `json:",omitempty"`
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// HNSNetwork represents a network in HNS
 | 
			
		||||
type HNSNetwork struct {
 | 
			
		||||
	Id                   string            `json:"ID,omitempty"`
 | 
			
		||||
	Name                 string            `json:",omitempty"`
 | 
			
		||||
	Type                 string            `json:",omitempty"`
 | 
			
		||||
	NetworkAdapterName   string            `json:",omitempty"`
 | 
			
		||||
	SourceMac            string            `json:",omitempty"`
 | 
			
		||||
	Policies             []json.RawMessage `json:",omitempty"`
 | 
			
		||||
	MacPools             []MacPool         `json:",omitempty"`
 | 
			
		||||
	Subnets              []Subnet          `json:",omitempty"`
 | 
			
		||||
	DNSSuffix            string            `json:",omitempty"`
 | 
			
		||||
	DNSServerList        string            `json:",omitempty"`
 | 
			
		||||
	DNSServerCompartment uint32            `json:",omitempty"`
 | 
			
		||||
	ManagementIP         string            `json:",omitempty"`
 | 
			
		||||
	AutomaticDNS         bool              `json:",omitempty"`
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type hnsNetworkResponse struct {
 | 
			
		||||
	Success bool
 | 
			
		||||
	Error   string
 | 
			
		||||
	Output  HNSNetwork
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type hnsResponse struct {
 | 
			
		||||
	Success bool
 | 
			
		||||
	Error   string
 | 
			
		||||
	Output  json.RawMessage
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// HNSNetworkRequest makes a call into HNS to update/query a single network
 | 
			
		||||
func HNSNetworkRequest(method, path, request string) (*HNSNetwork, error) {
 | 
			
		||||
	var network HNSNetwork
 | 
			
		||||
	err := hnsCall(method, "/networks/"+path, request, &network)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return &network, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// HNSListNetworkRequest makes a HNS call to query the list of available networks
 | 
			
		||||
func HNSListNetworkRequest(method, path, request string) ([]HNSNetwork, error) {
 | 
			
		||||
	var network []HNSNetwork
 | 
			
		||||
	err := hnsCall(method, "/networks/"+path, request, &network)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return network, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// GetHNSNetworkByID
 | 
			
		||||
func GetHNSNetworkByID(networkID string) (*HNSNetwork, error) {
 | 
			
		||||
	return HNSNetworkRequest("GET", networkID, "")
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// GetHNSNetworkName filtered by Name
 | 
			
		||||
func GetHNSNetworkByName(networkName string) (*HNSNetwork, error) {
 | 
			
		||||
	hsnnetworks, err := HNSListNetworkRequest("GET", "", "")
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
	for _, hnsnetwork := range hsnnetworks {
 | 
			
		||||
		if hnsnetwork.Name == networkName {
 | 
			
		||||
			return &hnsnetwork, nil
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	return nil, fmt.Errorf("Network %v not found", networkName)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Create Network by sending NetworkRequest to HNS.
 | 
			
		||||
func (network *HNSNetwork) Create() (*HNSNetwork, error) {
 | 
			
		||||
	operation := "Create"
 | 
			
		||||
	title := "HCSShim::HNSNetwork::" + operation
 | 
			
		||||
	logrus.Debugf(title+" id=%s", network.Id)
 | 
			
		||||
 | 
			
		||||
	jsonString, err := json.Marshal(network)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
	return HNSNetworkRequest("POST", "", string(jsonString))
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Delete Network by sending NetworkRequest to HNS
 | 
			
		||||
func (network *HNSNetwork) Delete() (*HNSNetwork, error) {
 | 
			
		||||
	operation := "Delete"
 | 
			
		||||
	title := "HCSShim::HNSNetwork::" + operation
 | 
			
		||||
	logrus.Debugf(title+" id=%s", network.Id)
 | 
			
		||||
 | 
			
		||||
	return HNSNetworkRequest("DELETE", network.Id, "")
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Creates an endpoint on the Network.
 | 
			
		||||
func (network *HNSNetwork) NewEndpoint(ipAddress net.IP, macAddress net.HardwareAddr) *HNSEndpoint {
 | 
			
		||||
	return &HNSEndpoint{
 | 
			
		||||
		VirtualNetwork: network.Id,
 | 
			
		||||
		IPAddress:      ipAddress,
 | 
			
		||||
		MacAddress:     string(macAddress),
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (network *HNSNetwork) CreateEndpoint(endpoint *HNSEndpoint) (*HNSEndpoint, error) {
 | 
			
		||||
	operation := "CreateEndpoint"
 | 
			
		||||
	title := "HCSShim::HNSNetwork::" + operation
 | 
			
		||||
	logrus.Debugf(title+" id=%s, endpointId=%s", network.Id, endpoint.Id)
 | 
			
		||||
 | 
			
		||||
	endpoint.VirtualNetwork = network.Id
 | 
			
		||||
	return endpoint.Create()
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (network *HNSNetwork) CreateRemoteEndpoint(endpoint *HNSEndpoint) (*HNSEndpoint, error) {
 | 
			
		||||
	operation := "CreateRemoteEndpoint"
 | 
			
		||||
	title := "HCSShim::HNSNetwork::" + operation
 | 
			
		||||
	logrus.Debugf(title+" id=%s", network.Id)
 | 
			
		||||
	endpoint.IsRemoteEndpoint = true
 | 
			
		||||
	return network.CreateEndpoint(endpoint)
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										95
									
								
								vendor/github.com/Microsoft/hcsshim/hnspolicy.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										95
									
								
								vendor/github.com/Microsoft/hcsshim/hnspolicy.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,95 @@
 | 
			
		||||
package hcsshim
 | 
			
		||||
 | 
			
		||||
// Type of Request Support in ModifySystem
 | 
			
		||||
type PolicyType string
 | 
			
		||||
 | 
			
		||||
// RequestType const
 | 
			
		||||
const (
 | 
			
		||||
	Nat                  PolicyType = "NAT"
 | 
			
		||||
	ACL                  PolicyType = "ACL"
 | 
			
		||||
	PA                   PolicyType = "PA"
 | 
			
		||||
	VLAN                 PolicyType = "VLAN"
 | 
			
		||||
	VSID                 PolicyType = "VSID"
 | 
			
		||||
	VNet                 PolicyType = "VNET"
 | 
			
		||||
	L2Driver             PolicyType = "L2Driver"
 | 
			
		||||
	Isolation            PolicyType = "Isolation"
 | 
			
		||||
	QOS                  PolicyType = "QOS"
 | 
			
		||||
	OutboundNat          PolicyType = "OutBoundNAT"
 | 
			
		||||
	ExternalLoadBalancer PolicyType = "ELB"
 | 
			
		||||
	Route                PolicyType = "ROUTE"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
type NatPolicy struct {
 | 
			
		||||
	Type         PolicyType `json:"Type"`
 | 
			
		||||
	Protocol     string
 | 
			
		||||
	InternalPort uint16
 | 
			
		||||
	ExternalPort uint16
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type QosPolicy struct {
 | 
			
		||||
	Type                            PolicyType `json:"Type"`
 | 
			
		||||
	MaximumOutgoingBandwidthInBytes uint64
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type IsolationPolicy struct {
 | 
			
		||||
	Type               PolicyType `json:"Type"`
 | 
			
		||||
	VLAN               uint
 | 
			
		||||
	VSID               uint
 | 
			
		||||
	InDefaultIsolation bool
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type VlanPolicy struct {
 | 
			
		||||
	Type PolicyType `json:"Type"`
 | 
			
		||||
	VLAN uint
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type VsidPolicy struct {
 | 
			
		||||
	Type PolicyType `json:"Type"`
 | 
			
		||||
	VSID uint
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type PaPolicy struct {
 | 
			
		||||
	Type PolicyType `json:"Type"`
 | 
			
		||||
	PA   string     `json:"PA"`
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type OutboundNatPolicy struct {
 | 
			
		||||
	Policy
 | 
			
		||||
	VIP        string   `json:"VIP,omitempty"`
 | 
			
		||||
	Exceptions []string `json:"ExceptionList,omitempty"`
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type ActionType string
 | 
			
		||||
type DirectionType string
 | 
			
		||||
type RuleType string
 | 
			
		||||
 | 
			
		||||
const (
 | 
			
		||||
	Allow ActionType = "Allow"
 | 
			
		||||
	Block ActionType = "Block"
 | 
			
		||||
 | 
			
		||||
	In  DirectionType = "In"
 | 
			
		||||
	Out DirectionType = "Out"
 | 
			
		||||
 | 
			
		||||
	Host   RuleType = "Host"
 | 
			
		||||
	Switch RuleType = "Switch"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
type ACLPolicy struct {
 | 
			
		||||
	Type          PolicyType `json:"Type"`
 | 
			
		||||
	Protocol      uint16
 | 
			
		||||
	InternalPort  uint16
 | 
			
		||||
	Action        ActionType
 | 
			
		||||
	Direction     DirectionType
 | 
			
		||||
	LocalAddress  string
 | 
			
		||||
	RemoteAddress string
 | 
			
		||||
	LocalPort     uint16
 | 
			
		||||
	RemotePort    uint16
 | 
			
		||||
	RuleType      RuleType `json:"RuleType,omitempty"`
 | 
			
		||||
 | 
			
		||||
	Priority    uint16
 | 
			
		||||
	ServiceName string
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type Policy struct {
 | 
			
		||||
	Type PolicyType `json:"Type"`
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										187
									
								
								vendor/github.com/Microsoft/hcsshim/hnspolicylist.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										187
									
								
								vendor/github.com/Microsoft/hcsshim/hnspolicylist.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,187 @@
 | 
			
		||||
package hcsshim
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"encoding/json"
 | 
			
		||||
 | 
			
		||||
	"github.com/sirupsen/logrus"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
type RoutePolicy struct {
 | 
			
		||||
	Policy
 | 
			
		||||
	DestinationPrefix string `json:"DestinationPrefix,omitempty"`
 | 
			
		||||
	NextHop           string `json:"NextHop,omitempty"`
 | 
			
		||||
	EncapEnabled      bool   `json:"NeedEncap,omitempty"`
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type ELBPolicy struct {
 | 
			
		||||
	LBPolicy
 | 
			
		||||
	SourceVIP string   `json:"SourceVIP,omitempty"`
 | 
			
		||||
	VIPs      []string `json:"VIPs,omitempty"`
 | 
			
		||||
	ILB       bool     `json:"ILB,omitempty"`
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type LBPolicy struct {
 | 
			
		||||
	Policy
 | 
			
		||||
	Protocol     uint16 `json:"Protocol,omitempty"`
 | 
			
		||||
	InternalPort uint16
 | 
			
		||||
	ExternalPort uint16
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type PolicyList struct {
 | 
			
		||||
	Id                 string   `json:"ID,omitempty"`
 | 
			
		||||
	EndpointReferences []string `json:"References,omitempty"`
 | 
			
		||||
	Policies           []string `json:"Policies,omitempty"`
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// HNSPolicyListRequest makes a call into HNS to update/query a single network
 | 
			
		||||
func HNSPolicyListRequest(method, path, request string) (*PolicyList, error) {
 | 
			
		||||
	var policy PolicyList
 | 
			
		||||
	err := hnsCall(method, "/policylists/"+path, request, &policy)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return &policy, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func HNSListPolicyListRequest() ([]PolicyList, error) {
 | 
			
		||||
	var plist []PolicyList
 | 
			
		||||
	err := hnsCall("GET", "/policylists/", "", &plist)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return plist, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// PolicyListRequest makes a HNS call to modify/query a network endpoint
 | 
			
		||||
func PolicyListRequest(method, path, request string) (*PolicyList, error) {
 | 
			
		||||
	policylist := &PolicyList{}
 | 
			
		||||
	err := hnsCall(method, "/policylists/"+path, request, &policylist)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return policylist, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Create PolicyList by sending PolicyListRequest to HNS.
 | 
			
		||||
func (policylist *PolicyList) Create() (*PolicyList, error) {
 | 
			
		||||
	operation := "Create"
 | 
			
		||||
	title := "HCSShim::PolicyList::" + operation
 | 
			
		||||
	logrus.Debugf(title+" id=%s", policylist.Id)
 | 
			
		||||
	jsonString, err := json.Marshal(policylist)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
	return PolicyListRequest("POST", "", string(jsonString))
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Create PolicyList by sending PolicyListRequest to HNS
 | 
			
		||||
func (policylist *PolicyList) Delete() (*PolicyList, error) {
 | 
			
		||||
	operation := "Delete"
 | 
			
		||||
	title := "HCSShim::PolicyList::" + operation
 | 
			
		||||
	logrus.Debugf(title+" id=%s", policylist.Id)
 | 
			
		||||
 | 
			
		||||
	return PolicyListRequest("DELETE", policylist.Id, "")
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Add an endpoint to a Policy List
 | 
			
		||||
func (policylist *PolicyList) AddEndpoint(endpoint *HNSEndpoint) (*PolicyList, error) {
 | 
			
		||||
	operation := "AddEndpoint"
 | 
			
		||||
	title := "HCSShim::PolicyList::" + operation
 | 
			
		||||
	logrus.Debugf(title+" id=%s, endpointId:%s", policylist.Id, endpoint.Id)
 | 
			
		||||
 | 
			
		||||
	_, err := policylist.Delete()
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// Add Endpoint to the Existing List
 | 
			
		||||
	policylist.EndpointReferences = append(policylist.EndpointReferences, "/endpoints/"+endpoint.Id)
 | 
			
		||||
 | 
			
		||||
	return policylist.Create()
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Remove an endpoint from the Policy List
 | 
			
		||||
func (policylist *PolicyList) RemoveEndpoint(endpoint *HNSEndpoint) (*PolicyList, error) {
 | 
			
		||||
	operation := "RemoveEndpoint"
 | 
			
		||||
	title := "HCSShim::PolicyList::" + operation
 | 
			
		||||
	logrus.Debugf(title+" id=%s, endpointId:%s", policylist.Id, endpoint.Id)
 | 
			
		||||
 | 
			
		||||
	_, err := policylist.Delete()
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	elementToRemove := "/endpoints/" + endpoint.Id
 | 
			
		||||
 | 
			
		||||
	var references []string
 | 
			
		||||
 | 
			
		||||
	for _, endpointReference := range policylist.EndpointReferences {
 | 
			
		||||
		if endpointReference == elementToRemove {
 | 
			
		||||
			continue
 | 
			
		||||
		}
 | 
			
		||||
		references = append(references, endpointReference)
 | 
			
		||||
	}
 | 
			
		||||
	policylist.EndpointReferences = references
 | 
			
		||||
	return policylist.Create()
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// AddLoadBalancer policy list for the specified endpoints
 | 
			
		||||
func AddLoadBalancer(endpoints []HNSEndpoint, isILB bool, vip string, protocol uint16, internalPort uint16, externalPort uint16) (*PolicyList, error) {
 | 
			
		||||
	operation := "AddLoadBalancer"
 | 
			
		||||
	title := "HCSShim::PolicyList::" + operation
 | 
			
		||||
	logrus.Debugf(title+" Vip:%s", vip)
 | 
			
		||||
 | 
			
		||||
	policylist := &PolicyList{}
 | 
			
		||||
 | 
			
		||||
	elbPolicy := &ELBPolicy{
 | 
			
		||||
		VIPs: []string{vip},
 | 
			
		||||
		ILB:  isILB,
 | 
			
		||||
	}
 | 
			
		||||
	elbPolicy.Type = ExternalLoadBalancer
 | 
			
		||||
	elbPolicy.Protocol = protocol
 | 
			
		||||
	elbPolicy.InternalPort = internalPort
 | 
			
		||||
	elbPolicy.ExternalPort = externalPort
 | 
			
		||||
 | 
			
		||||
	for _, endpoint := range endpoints {
 | 
			
		||||
		policylist.EndpointReferences = append(policylist.EndpointReferences, "/endpoints/"+endpoint.Id)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	jsonString, err := json.Marshal(elbPolicy)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	policylist.Policies[0] = string(jsonString)
 | 
			
		||||
	return policylist.Create()
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// AddLoadBalancer policy list for the specified endpoints
 | 
			
		||||
func AddRoute(endpoints []HNSEndpoint, destinationPrefix string, nextHop string, encapEnabled bool) (*PolicyList, error) {
 | 
			
		||||
	operation := "AddRoute"
 | 
			
		||||
	title := "HCSShim::PolicyList::" + operation
 | 
			
		||||
	logrus.Debugf(title+" destinationPrefix:%s", destinationPrefix)
 | 
			
		||||
 | 
			
		||||
	policylist := &PolicyList{}
 | 
			
		||||
 | 
			
		||||
	rPolicy := &RoutePolicy{
 | 
			
		||||
		DestinationPrefix: destinationPrefix,
 | 
			
		||||
		NextHop:           nextHop,
 | 
			
		||||
		EncapEnabled:      encapEnabled,
 | 
			
		||||
	}
 | 
			
		||||
	rPolicy.Type = Route
 | 
			
		||||
 | 
			
		||||
	for _, endpoint := range endpoints {
 | 
			
		||||
		policylist.EndpointReferences = append(policylist.EndpointReferences, "/endpoints/"+endpoint.Id)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	jsonString, err := json.Marshal(rPolicy)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	policylist.Policies[0] = string(jsonString)
 | 
			
		||||
	return policylist.Create()
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										4
									
								
								vendor/github.com/Microsoft/hcsshim/importlayer.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										4
									
								
								vendor/github.com/Microsoft/hcsshim/importlayer.go
									
									
									
										generated
									
									
										vendored
									
									
								
							@@ -5,10 +5,9 @@ import (
 | 
			
		||||
	"io/ioutil"
 | 
			
		||||
	"os"
 | 
			
		||||
	"path/filepath"
 | 
			
		||||
	"runtime"
 | 
			
		||||
 | 
			
		||||
	"github.com/Microsoft/go-winio"
 | 
			
		||||
	"github.com/Sirupsen/logrus"
 | 
			
		||||
	"github.com/sirupsen/logrus"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// ImportLayer will take the contents of the folder at importFolderPath and import
 | 
			
		||||
@@ -209,6 +208,5 @@ func NewLayerWriter(info DriverInfo, layerID string, parentLayerPaths []string)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, makeError(err, "ImportLayerStart", "")
 | 
			
		||||
	}
 | 
			
		||||
	runtime.SetFinalizer(w, func(w *FilterLayerWriter) { w.Close() })
 | 
			
		||||
	return w, nil
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										102
									
								
								vendor/github.com/Microsoft/hcsshim/interface.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										102
									
								
								vendor/github.com/Microsoft/hcsshim/interface.go
									
									
									
										generated
									
									
										vendored
									
									
								
							@@ -1,6 +1,7 @@
 | 
			
		||||
package hcsshim
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"encoding/json"
 | 
			
		||||
	"io"
 | 
			
		||||
	"time"
 | 
			
		||||
)
 | 
			
		||||
@@ -8,16 +9,19 @@ import (
 | 
			
		||||
// ProcessConfig is used as both the input of Container.CreateProcess
 | 
			
		||||
// and to convert the parameters to JSON for passing onto the HCS
 | 
			
		||||
type ProcessConfig struct {
 | 
			
		||||
	ApplicationName  string
 | 
			
		||||
	CommandLine      string
 | 
			
		||||
	User             string
 | 
			
		||||
	WorkingDirectory string
 | 
			
		||||
	Environment      map[string]string
 | 
			
		||||
	EmulateConsole   bool
 | 
			
		||||
	CreateStdInPipe  bool
 | 
			
		||||
	CreateStdOutPipe bool
 | 
			
		||||
	CreateStdErrPipe bool
 | 
			
		||||
	ConsoleSize      [2]uint
 | 
			
		||||
	ApplicationName   string            `json:",omitempty"`
 | 
			
		||||
	CommandLine       string            `json:",omitempty"`
 | 
			
		||||
	CommandArgs       []string          `json:",omitempty"` // Used by Linux Containers on Windows
 | 
			
		||||
	User              string            `json:",omitempty"`
 | 
			
		||||
	WorkingDirectory  string            `json:",omitempty"`
 | 
			
		||||
	Environment       map[string]string `json:",omitempty"`
 | 
			
		||||
	EmulateConsole    bool              `json:",omitempty"`
 | 
			
		||||
	CreateStdInPipe   bool              `json:",omitempty"`
 | 
			
		||||
	CreateStdOutPipe  bool              `json:",omitempty"`
 | 
			
		||||
	CreateStdErrPipe  bool              `json:",omitempty"`
 | 
			
		||||
	ConsoleSize       [2]uint           `json:",omitempty"`
 | 
			
		||||
	CreateInUtilityVm bool              `json:",omitempty"` // Used by Linux Containers on Windows
 | 
			
		||||
	OCISpecification  *json.RawMessage  `json:",omitempty"` // Used by Linux Containers on Windows
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type Layer struct {
 | 
			
		||||
@@ -33,40 +37,59 @@ type MappedDir struct {
 | 
			
		||||
	IOPSMaximum      uint64
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type MappedPipe struct {
 | 
			
		||||
	HostPath          string
 | 
			
		||||
	ContainerPipeName string
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type HvRuntime struct {
 | 
			
		||||
	ImagePath    string `json:",omitempty"`
 | 
			
		||||
	SkipTemplate bool   `json:",omitempty"`
 | 
			
		||||
	ImagePath           string `json:",omitempty"`
 | 
			
		||||
	SkipTemplate        bool   `json:",omitempty"`
 | 
			
		||||
	LinuxInitrdFile     string `json:",omitempty"` // File under ImagePath on host containing an initrd image for starting a Linux utility VM
 | 
			
		||||
	LinuxKernelFile     string `json:",omitempty"` // File under ImagePath on host containing a kernel for starting a Linux utility VM
 | 
			
		||||
	LinuxBootParameters string `json:",omitempty"` // Additional boot parameters for starting a Linux Utility VM in initrd mode
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type MappedVirtualDisk struct {
 | 
			
		||||
	HostPath          string `json:",omitempty"` // Path to VHD on the host
 | 
			
		||||
	ContainerPath     string // Platform-specific mount point path in the container
 | 
			
		||||
	CreateInUtilityVM bool   `json:",omitempty"`
 | 
			
		||||
	ReadOnly          bool   `json:",omitempty"`
 | 
			
		||||
	Cache             string `json:",omitempty"` // "" (Unspecified); "Disabled"; "Enabled"; "Private"; "PrivateAllowSharing"
 | 
			
		||||
	AttachOnly        bool   `json:",omitempty:`
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// ContainerConfig is used as both the input of CreateContainer
 | 
			
		||||
// and to convert the parameters to JSON for passing onto the HCS
 | 
			
		||||
type ContainerConfig struct {
 | 
			
		||||
	SystemType                 string      // HCS requires this to be hard-coded to "Container"
 | 
			
		||||
	Name                       string      // Name of the container. We use the docker ID.
 | 
			
		||||
	Owner                      string      // The management platform that created this container
 | 
			
		||||
	IsDummy                    bool        // Used for development purposes.
 | 
			
		||||
	VolumePath                 string      `json:",omitempty"` // Windows volume path for scratch space. Used by Windows Server Containers only. Format \\?\\Volume{GUID}
 | 
			
		||||
	IgnoreFlushesDuringBoot    bool        // Optimization hint for container startup in Windows
 | 
			
		||||
	LayerFolderPath            string      `json:",omitempty"` // Where the layer folders are located. Used by Windows Server Containers only. Format  %root%\windowsfilter\containerID
 | 
			
		||||
	Layers                     []Layer     // List of storage layers. Required for Windows Server and Hyper-V Containers. Format ID=GUID;Path=%root%\windowsfilter\layerID
 | 
			
		||||
	Credentials                string      `json:",omitempty"` // Credentials information
 | 
			
		||||
	ProcessorCount             uint32      `json:",omitempty"` // Number of processors to assign to the container.
 | 
			
		||||
	ProcessorWeight            uint64      `json:",omitempty"` // CPU Shares 0..10000 on Windows; where 0 will be omitted and HCS will default.
 | 
			
		||||
	ProcessorMaximum           int64       `json:",omitempty"` // CPU maximum usage percent 1..100
 | 
			
		||||
	StorageIOPSMaximum         uint64      `json:",omitempty"` // Maximum Storage IOPS
 | 
			
		||||
	StorageBandwidthMaximum    uint64      `json:",omitempty"` // Maximum Storage Bandwidth in bytes per second
 | 
			
		||||
	StorageSandboxSize         uint64      `json:",omitempty"` // Size in bytes that the container system drive should be expanded to if smaller
 | 
			
		||||
	MemoryMaximumInMB          int64       `json:",omitempty"` // Maximum memory available to the container in Megabytes
 | 
			
		||||
	HostName                   string      // Hostname
 | 
			
		||||
	MappedDirectories          []MappedDir // List of mapped directories (volumes/mounts)
 | 
			
		||||
	SandboxPath                string      `json:",omitempty"` // Location of unmounted sandbox. Used by Hyper-V containers only. Format %root%\windowsfilter
 | 
			
		||||
	HvPartition                bool        // True if it a Hyper-V Container
 | 
			
		||||
	EndpointList               []string    // List of networking endpoints to be attached to container
 | 
			
		||||
	NetworkSharedContainerName string      `json:",omitempty"` // Name (ID) of the container that we will share the network stack with.
 | 
			
		||||
	HvRuntime                  *HvRuntime  `json:",omitempty"` // Hyper-V container settings. Used by Hyper-V containers only. Format ImagePath=%root%\BaseLayerID\UtilityVM
 | 
			
		||||
	Servicing                  bool        // True if this container is for servicing
 | 
			
		||||
	AllowUnqualifiedDNSQuery   bool        // True to allow unqualified DNS name resolution
 | 
			
		||||
	DNSSearchList              string      `json:",omitempty"` // Comma seperated list of DNS suffixes to use for name resolution
 | 
			
		||||
	SystemType                  string              // HCS requires this to be hard-coded to "Container"
 | 
			
		||||
	Name                        string              // Name of the container. We use the docker ID.
 | 
			
		||||
	Owner                       string              `json:",omitempty"` // The management platform that created this container
 | 
			
		||||
	VolumePath                  string              `json:",omitempty"` // Windows volume path for scratch space. Used by Windows Server Containers only. Format \\?\\Volume{GUID}
 | 
			
		||||
	IgnoreFlushesDuringBoot     bool                `json:",omitempty"` // Optimization hint for container startup in Windows
 | 
			
		||||
	LayerFolderPath             string              `json:",omitempty"` // Where the layer folders are located. Used by Windows Server Containers only. Format  %root%\windowsfilter\containerID
 | 
			
		||||
	Layers                      []Layer             // List of storage layers. Required for Windows Server and Hyper-V Containers. Format ID=GUID;Path=%root%\windowsfilter\layerID
 | 
			
		||||
	Credentials                 string              `json:",omitempty"` // Credentials information
 | 
			
		||||
	ProcessorCount              uint32              `json:",omitempty"` // Number of processors to assign to the container.
 | 
			
		||||
	ProcessorWeight             uint64              `json:",omitempty"` // CPU shares (relative weight to other containers with cpu shares). Range is from 1 to 10000. A value of 0 results in default shares.
 | 
			
		||||
	ProcessorMaximum            int64               `json:",omitempty"` // Specifies the portion of processor cycles that this container can use as a percentage times 100. Range is from 1 to 10000. A value of 0 results in no limit.
 | 
			
		||||
	StorageIOPSMaximum          uint64              `json:",omitempty"` // Maximum Storage IOPS
 | 
			
		||||
	StorageBandwidthMaximum     uint64              `json:",omitempty"` // Maximum Storage Bandwidth in bytes per second
 | 
			
		||||
	StorageSandboxSize          uint64              `json:",omitempty"` // Size in bytes that the container system drive should be expanded to if smaller
 | 
			
		||||
	MemoryMaximumInMB           int64               `json:",omitempty"` // Maximum memory available to the container in Megabytes
 | 
			
		||||
	HostName                    string              `json:",omitempty"` // Hostname
 | 
			
		||||
	MappedDirectories           []MappedDir         `json:",omitempty"` // List of mapped directories (volumes/mounts)
 | 
			
		||||
	MappedPipes                 []MappedPipe        `json:",omitempty"` // List of mapped Windows named pipes
 | 
			
		||||
	HvPartition                 bool                // True if it a Hyper-V Container
 | 
			
		||||
	NetworkSharedContainerName  string              `json:",omitempty"` // Name (ID) of the container that we will share the network stack with.
 | 
			
		||||
	EndpointList                []string            `json:",omitempty"` // List of networking endpoints to be attached to container
 | 
			
		||||
	HvRuntime                   *HvRuntime          `json:",omitempty"` // Hyper-V container settings. Used by Hyper-V containers only. Format ImagePath=%root%\BaseLayerID\UtilityVM
 | 
			
		||||
	Servicing                   bool                `json:",omitempty"` // True if this container is for servicing
 | 
			
		||||
	AllowUnqualifiedDNSQuery    bool                `json:",omitempty"` // True to allow unqualified DNS name resolution
 | 
			
		||||
	DNSSearchList               string              `json:",omitempty"` // Comma seperated list of DNS suffixes to use for name resolution
 | 
			
		||||
	ContainerType               string              `json:",omitempty"` // "Linux" for Linux containers on Windows. Omitted otherwise.
 | 
			
		||||
	TerminateOnLastHandleClosed bool                `json:",omitempty"` // Should HCS terminate the container once all handles have been closed
 | 
			
		||||
	MappedVirtualDisks          []MappedVirtualDisk `json:",omitempty"` // Array of virtual disks to mount at start
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type ComputeSystemQuery struct {
 | 
			
		||||
@@ -109,6 +132,9 @@ type Container interface {
 | 
			
		||||
	// ProcessList returns details for the processes in a container.
 | 
			
		||||
	ProcessList() ([]ProcessListItem, error)
 | 
			
		||||
 | 
			
		||||
	// MappedVirtualDisks returns virtual disks mapped to a utility VM, indexed by controller
 | 
			
		||||
	MappedVirtualDisks() (map[int]MappedVirtualDiskController, error)
 | 
			
		||||
 | 
			
		||||
	// CreateProcess launches a new process within the container.
 | 
			
		||||
	CreateProcess(c *ProcessConfig) (Process, error)
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										2
									
								
								vendor/github.com/Microsoft/hcsshim/layerexists.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								vendor/github.com/Microsoft/hcsshim/layerexists.go
									
									
									
										generated
									
									
										vendored
									
									
								
							@@ -1,6 +1,6 @@
 | 
			
		||||
package hcsshim
 | 
			
		||||
 | 
			
		||||
import "github.com/Sirupsen/logrus"
 | 
			
		||||
import "github.com/sirupsen/logrus"
 | 
			
		||||
 | 
			
		||||
// LayerExists will return true if a layer with the given id exists and is known
 | 
			
		||||
// to the system.
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										2
									
								
								vendor/github.com/Microsoft/hcsshim/layerutils.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								vendor/github.com/Microsoft/hcsshim/layerutils.go
									
									
									
										generated
									
									
										vendored
									
									
								
							@@ -7,7 +7,7 @@ import (
 | 
			
		||||
	"path/filepath"
 | 
			
		||||
	"syscall"
 | 
			
		||||
 | 
			
		||||
	"github.com/Sirupsen/logrus"
 | 
			
		||||
	"github.com/sirupsen/logrus"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
/* To pass into syscall, we need a struct matching the following:
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										48
									
								
								vendor/github.com/Microsoft/hcsshim/legacy.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										48
									
								
								vendor/github.com/Microsoft/hcsshim/legacy.go
									
									
									
										generated
									
									
										vendored
									
									
								
							@@ -23,6 +23,13 @@ var mutatedUtilityVMFiles = map[string]bool{
 | 
			
		||||
	`EFI\Microsoft\Boot\BCD.LOG2`: true,
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
const (
 | 
			
		||||
	filesPath          = `Files`
 | 
			
		||||
	hivesPath          = `Hives`
 | 
			
		||||
	utilityVMPath      = `UtilityVM`
 | 
			
		||||
	utilityVMFilesPath = `UtilityVM\Files`
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
func openFileOrDir(path string, mode uint32, createDisposition uint32) (file *os.File, err error) {
 | 
			
		||||
	return winio.OpenForBackup(path, mode, syscall.FILE_SHARE_READ, createDisposition)
 | 
			
		||||
}
 | 
			
		||||
@@ -44,6 +51,10 @@ func makeLongAbsPath(path string) (string, error) {
 | 
			
		||||
	return `\\?\` + path, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func hasPathPrefix(p, prefix string) bool {
 | 
			
		||||
	return strings.HasPrefix(p, prefix) && len(p) > len(prefix) && p[len(prefix)] == '\\'
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type fileEntry struct {
 | 
			
		||||
	path string
 | 
			
		||||
	fi   os.FileInfo
 | 
			
		||||
@@ -83,7 +94,7 @@ func readTombstones(path string) (map[string]([]string), error) {
 | 
			
		||||
 | 
			
		||||
	ts := make(map[string]([]string))
 | 
			
		||||
	for s.Scan() {
 | 
			
		||||
		t := filepath.Join("Files", s.Text()[1:]) // skip leading `\`
 | 
			
		||||
		t := filepath.Join(filesPath, s.Text()[1:]) // skip leading `\`
 | 
			
		||||
		dir := filepath.Dir(t)
 | 
			
		||||
		ts[dir] = append(ts[dir], t)
 | 
			
		||||
	}
 | 
			
		||||
@@ -212,7 +223,7 @@ func (r *legacyLayerReader) Next() (path string, size int64, fileInfo *winio.Fil
 | 
			
		||||
		return
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if fe.fi.IsDir() && strings.HasPrefix(path, `Files\`) {
 | 
			
		||||
	if fe.fi.IsDir() && hasPathPrefix(path, filesPath) {
 | 
			
		||||
		fe.path += ".$wcidirs$"
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
@@ -231,14 +242,14 @@ func (r *legacyLayerReader) Next() (path string, size int64, fileInfo *winio.Fil
 | 
			
		||||
		return
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if !strings.HasPrefix(path, `Files\`) {
 | 
			
		||||
	if !hasPathPrefix(path, filesPath) {
 | 
			
		||||
		size = fe.fi.Size()
 | 
			
		||||
		r.backupReader = winio.NewBackupFileReader(f, false)
 | 
			
		||||
		if path == "Hives" || path == "Files" {
 | 
			
		||||
		if path == hivesPath || path == filesPath {
 | 
			
		||||
			// The Hives directory has a non-deterministic file time because of the
 | 
			
		||||
			// nature of the import process. Use the times from System_Delta.
 | 
			
		||||
			var g *os.File
 | 
			
		||||
			g, err = os.Open(filepath.Join(r.root, `Hives\System_Delta`))
 | 
			
		||||
			g, err = os.Open(filepath.Join(r.root, hivesPath, `System_Delta`))
 | 
			
		||||
			if err != nil {
 | 
			
		||||
				return
 | 
			
		||||
			}
 | 
			
		||||
@@ -357,7 +368,7 @@ func (w *legacyLayerWriter) init() error {
 | 
			
		||||
 | 
			
		||||
func (w *legacyLayerWriter) initUtilityVM() error {
 | 
			
		||||
	if !w.HasUtilityVM {
 | 
			
		||||
		err := os.Mkdir(filepath.Join(w.destRoot, `UtilityVM`), 0)
 | 
			
		||||
		err := os.Mkdir(filepath.Join(w.destRoot, utilityVMPath), 0)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			return err
 | 
			
		||||
		}
 | 
			
		||||
@@ -365,7 +376,7 @@ func (w *legacyLayerWriter) initUtilityVM() error {
 | 
			
		||||
		// clone the utility VM from the parent layer into this layer. Use hard
 | 
			
		||||
		// links to avoid unnecessary copying, since most of the files are
 | 
			
		||||
		// immutable.
 | 
			
		||||
		err = cloneTree(filepath.Join(w.parentRoots[0], `UtilityVM\Files`), filepath.Join(w.destRoot, `UtilityVM\Files`), mutatedUtilityVMFiles)
 | 
			
		||||
		err = cloneTree(filepath.Join(w.parentRoots[0], utilityVMFilesPath), filepath.Join(w.destRoot, utilityVMFilesPath), mutatedUtilityVMFiles)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			return fmt.Errorf("cloning the parent utility VM image failed: %s", err)
 | 
			
		||||
		}
 | 
			
		||||
@@ -490,15 +501,15 @@ func (w *legacyLayerWriter) Add(name string, fileInfo *winio.FileBasicInfo) erro
 | 
			
		||||
		return err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if name == `UtilityVM` {
 | 
			
		||||
	if name == utilityVMPath {
 | 
			
		||||
		return w.initUtilityVM()
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if strings.HasPrefix(name, `UtilityVM\`) {
 | 
			
		||||
	if hasPathPrefix(name, utilityVMPath) {
 | 
			
		||||
		if !w.HasUtilityVM {
 | 
			
		||||
			return errors.New("missing UtilityVM directory")
 | 
			
		||||
		}
 | 
			
		||||
		if !strings.HasPrefix(name, `UtilityVM\Files\`) && name != `UtilityVM\Files` {
 | 
			
		||||
		if !hasPathPrefix(name, utilityVMFilesPath) && name != utilityVMFilesPath {
 | 
			
		||||
			return errors.New("invalid UtilityVM layer")
 | 
			
		||||
		}
 | 
			
		||||
		path := filepath.Join(w.destRoot, name)
 | 
			
		||||
@@ -585,7 +596,7 @@ func (w *legacyLayerWriter) Add(name string, fileInfo *winio.FileBasicInfo) erro
 | 
			
		||||
		return err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if strings.HasPrefix(name, `Hives\`) {
 | 
			
		||||
	if hasPathPrefix(name, hivesPath) {
 | 
			
		||||
		w.backupWriter = winio.NewBackupFileWriter(f, false)
 | 
			
		||||
	} else {
 | 
			
		||||
		// The file attributes are written before the stream.
 | 
			
		||||
@@ -608,22 +619,19 @@ func (w *legacyLayerWriter) AddLink(name string, target string) error {
 | 
			
		||||
		return err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	var requiredPrefix string
 | 
			
		||||
	var roots []string
 | 
			
		||||
	if prefix := `Files\`; strings.HasPrefix(name, prefix) {
 | 
			
		||||
		requiredPrefix = prefix
 | 
			
		||||
	if hasPathPrefix(target, filesPath) {
 | 
			
		||||
		// Look for cross-layer hard link targets in the parent layers, since
 | 
			
		||||
		// nothing is in the destination path yet.
 | 
			
		||||
		roots = w.parentRoots
 | 
			
		||||
	} else if prefix := `UtilityVM\Files\`; strings.HasPrefix(name, prefix) {
 | 
			
		||||
		requiredPrefix = prefix
 | 
			
		||||
	} else if hasPathPrefix(target, utilityVMFilesPath) {
 | 
			
		||||
		// Since the utility VM is fully cloned into the destination path
 | 
			
		||||
		// already, look for cross-layer hard link targets directly in the
 | 
			
		||||
		// destination path.
 | 
			
		||||
		roots = []string{w.destRoot}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if requiredPrefix == "" || !strings.HasPrefix(target, requiredPrefix) {
 | 
			
		||||
	if roots == nil || (!hasPathPrefix(name, filesPath) && !hasPathPrefix(name, utilityVMFilesPath)) {
 | 
			
		||||
		return errors.New("invalid hard link in layer")
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
@@ -657,9 +665,9 @@ func (w *legacyLayerWriter) AddLink(name string, target string) error {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (w *legacyLayerWriter) Remove(name string) error {
 | 
			
		||||
	if strings.HasPrefix(name, `Files\`) {
 | 
			
		||||
		w.tombstones = append(w.tombstones, name[len(`Files\`):])
 | 
			
		||||
	} else if strings.HasPrefix(name, `UtilityVM\Files\`) {
 | 
			
		||||
	if hasPathPrefix(name, filesPath) {
 | 
			
		||||
		w.tombstones = append(w.tombstones, name[len(filesPath)+1:])
 | 
			
		||||
	} else if hasPathPrefix(name, utilityVMFilesPath) {
 | 
			
		||||
		err := w.initUtilityVM()
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			return err
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										934
									
								
								vendor/github.com/Microsoft/hcsshim/mksyscall_windows.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										934
									
								
								vendor/github.com/Microsoft/hcsshim/mksyscall_windows.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,934 @@
 | 
			
		||||
// Copyright 2013 The Go Authors. All rights reserved.
 | 
			
		||||
// Use of this source code is governed by a BSD-style
 | 
			
		||||
// license that can be found in the LICENSE file.
 | 
			
		||||
 | 
			
		||||
// +build ignore
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
mksyscall_windows generates windows system call bodies
 | 
			
		||||
 | 
			
		||||
It parses all files specified on command line containing function
 | 
			
		||||
prototypes (like syscall_windows.go) and prints system call bodies
 | 
			
		||||
to standard output.
 | 
			
		||||
 | 
			
		||||
The prototypes are marked by lines beginning with "//sys" and read
 | 
			
		||||
like func declarations if //sys is replaced by func, but:
 | 
			
		||||
 | 
			
		||||
* The parameter lists must give a name for each argument. This
 | 
			
		||||
  includes return parameters.
 | 
			
		||||
 | 
			
		||||
* The parameter lists must give a type for each argument:
 | 
			
		||||
  the (x, y, z int) shorthand is not allowed.
 | 
			
		||||
 | 
			
		||||
* If the return parameter is an error number, it must be named err.
 | 
			
		||||
 | 
			
		||||
* If go func name needs to be different from it's winapi dll name,
 | 
			
		||||
  the winapi name could be specified at the end, after "=" sign, like
 | 
			
		||||
  //sys LoadLibrary(libname string) (handle uint32, err error) = LoadLibraryA
 | 
			
		||||
 | 
			
		||||
* Each function that returns err needs to supply a condition, that
 | 
			
		||||
  return value of winapi will be tested against to detect failure.
 | 
			
		||||
  This would set err to windows "last-error", otherwise it will be nil.
 | 
			
		||||
  The value can be provided at end of //sys declaration, like
 | 
			
		||||
  //sys LoadLibrary(libname string) (handle uint32, err error) [failretval==-1] = LoadLibraryA
 | 
			
		||||
  and is [failretval==0] by default.
 | 
			
		||||
 | 
			
		||||
Usage:
 | 
			
		||||
	mksyscall_windows [flags] [path ...]
 | 
			
		||||
 | 
			
		||||
The flags are:
 | 
			
		||||
	-output
 | 
			
		||||
		Specify output file name (outputs to console if blank).
 | 
			
		||||
	-trace
 | 
			
		||||
		Generate print statement after every syscall.
 | 
			
		||||
*/
 | 
			
		||||
package main
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"bufio"
 | 
			
		||||
	"bytes"
 | 
			
		||||
	"errors"
 | 
			
		||||
	"flag"
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"go/format"
 | 
			
		||||
	"go/parser"
 | 
			
		||||
	"go/token"
 | 
			
		||||
	"io"
 | 
			
		||||
	"io/ioutil"
 | 
			
		||||
	"log"
 | 
			
		||||
	"os"
 | 
			
		||||
	"path/filepath"
 | 
			
		||||
	"runtime"
 | 
			
		||||
	"sort"
 | 
			
		||||
	"strconv"
 | 
			
		||||
	"strings"
 | 
			
		||||
	"text/template"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
var (
 | 
			
		||||
	filename       = flag.String("output", "", "output file name (standard output if omitted)")
 | 
			
		||||
	printTraceFlag = flag.Bool("trace", false, "generate print statement after every syscall")
 | 
			
		||||
	systemDLL      = flag.Bool("systemdll", true, "whether all DLLs should be loaded from the Windows system directory")
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
func trim(s string) string {
 | 
			
		||||
	return strings.Trim(s, " \t")
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
var packageName string
 | 
			
		||||
 | 
			
		||||
func packagename() string {
 | 
			
		||||
	return packageName
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func syscalldot() string {
 | 
			
		||||
	if packageName == "syscall" {
 | 
			
		||||
		return ""
 | 
			
		||||
	}
 | 
			
		||||
	return "syscall."
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Param is function parameter
 | 
			
		||||
type Param struct {
 | 
			
		||||
	Name      string
 | 
			
		||||
	Type      string
 | 
			
		||||
	fn        *Fn
 | 
			
		||||
	tmpVarIdx int
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// tmpVar returns temp variable name that will be used to represent p during syscall.
 | 
			
		||||
func (p *Param) tmpVar() string {
 | 
			
		||||
	if p.tmpVarIdx < 0 {
 | 
			
		||||
		p.tmpVarIdx = p.fn.curTmpVarIdx
 | 
			
		||||
		p.fn.curTmpVarIdx++
 | 
			
		||||
	}
 | 
			
		||||
	return fmt.Sprintf("_p%d", p.tmpVarIdx)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// BoolTmpVarCode returns source code for bool temp variable.
 | 
			
		||||
func (p *Param) BoolTmpVarCode() string {
 | 
			
		||||
	const code = `var %s uint32
 | 
			
		||||
	if %s {
 | 
			
		||||
		%s = 1
 | 
			
		||||
	} else {
 | 
			
		||||
		%s = 0
 | 
			
		||||
	}`
 | 
			
		||||
	tmp := p.tmpVar()
 | 
			
		||||
	return fmt.Sprintf(code, tmp, p.Name, tmp, tmp)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// SliceTmpVarCode returns source code for slice temp variable.
 | 
			
		||||
func (p *Param) SliceTmpVarCode() string {
 | 
			
		||||
	const code = `var %s *%s
 | 
			
		||||
	if len(%s) > 0 {
 | 
			
		||||
		%s = &%s[0]
 | 
			
		||||
	}`
 | 
			
		||||
	tmp := p.tmpVar()
 | 
			
		||||
	return fmt.Sprintf(code, tmp, p.Type[2:], p.Name, tmp, p.Name)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// StringTmpVarCode returns source code for string temp variable.
 | 
			
		||||
func (p *Param) StringTmpVarCode() string {
 | 
			
		||||
	errvar := p.fn.Rets.ErrorVarName()
 | 
			
		||||
	if errvar == "" {
 | 
			
		||||
		errvar = "_"
 | 
			
		||||
	}
 | 
			
		||||
	tmp := p.tmpVar()
 | 
			
		||||
	const code = `var %s %s
 | 
			
		||||
	%s, %s = %s(%s)`
 | 
			
		||||
	s := fmt.Sprintf(code, tmp, p.fn.StrconvType(), tmp, errvar, p.fn.StrconvFunc(), p.Name)
 | 
			
		||||
	if errvar == "-" {
 | 
			
		||||
		return s
 | 
			
		||||
	}
 | 
			
		||||
	const morecode = `
 | 
			
		||||
	if %s != nil {
 | 
			
		||||
		return
 | 
			
		||||
	}`
 | 
			
		||||
	return s + fmt.Sprintf(morecode, errvar)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// TmpVarCode returns source code for temp variable.
 | 
			
		||||
func (p *Param) TmpVarCode() string {
 | 
			
		||||
	switch {
 | 
			
		||||
	case p.Type == "bool":
 | 
			
		||||
		return p.BoolTmpVarCode()
 | 
			
		||||
	case strings.HasPrefix(p.Type, "[]"):
 | 
			
		||||
		return p.SliceTmpVarCode()
 | 
			
		||||
	default:
 | 
			
		||||
		return ""
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// TmpVarHelperCode returns source code for helper's temp variable.
 | 
			
		||||
func (p *Param) TmpVarHelperCode() string {
 | 
			
		||||
	if p.Type != "string" {
 | 
			
		||||
		return ""
 | 
			
		||||
	}
 | 
			
		||||
	return p.StringTmpVarCode()
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// SyscallArgList returns source code fragments representing p parameter
 | 
			
		||||
// in syscall. Slices are translated into 2 syscall parameters: pointer to
 | 
			
		||||
// the first element and length.
 | 
			
		||||
func (p *Param) SyscallArgList() []string {
 | 
			
		||||
	t := p.HelperType()
 | 
			
		||||
	var s string
 | 
			
		||||
	switch {
 | 
			
		||||
	case t[0] == '*':
 | 
			
		||||
		s = fmt.Sprintf("unsafe.Pointer(%s)", p.Name)
 | 
			
		||||
	case t == "bool":
 | 
			
		||||
		s = p.tmpVar()
 | 
			
		||||
	case strings.HasPrefix(t, "[]"):
 | 
			
		||||
		return []string{
 | 
			
		||||
			fmt.Sprintf("uintptr(unsafe.Pointer(%s))", p.tmpVar()),
 | 
			
		||||
			fmt.Sprintf("uintptr(len(%s))", p.Name),
 | 
			
		||||
		}
 | 
			
		||||
	default:
 | 
			
		||||
		s = p.Name
 | 
			
		||||
	}
 | 
			
		||||
	return []string{fmt.Sprintf("uintptr(%s)", s)}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// IsError determines if p parameter is used to return error.
 | 
			
		||||
func (p *Param) IsError() bool {
 | 
			
		||||
	return p.Name == "err" && p.Type == "error"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// HelperType returns type of parameter p used in helper function.
 | 
			
		||||
func (p *Param) HelperType() string {
 | 
			
		||||
	if p.Type == "string" {
 | 
			
		||||
		return p.fn.StrconvType()
 | 
			
		||||
	}
 | 
			
		||||
	return p.Type
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// join concatenates parameters ps into a string with sep separator.
 | 
			
		||||
// Each parameter is converted into string by applying fn to it
 | 
			
		||||
// before conversion.
 | 
			
		||||
func join(ps []*Param, fn func(*Param) string, sep string) string {
 | 
			
		||||
	if len(ps) == 0 {
 | 
			
		||||
		return ""
 | 
			
		||||
	}
 | 
			
		||||
	a := make([]string, 0)
 | 
			
		||||
	for _, p := range ps {
 | 
			
		||||
		a = append(a, fn(p))
 | 
			
		||||
	}
 | 
			
		||||
	return strings.Join(a, sep)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Rets describes function return parameters.
 | 
			
		||||
type Rets struct {
 | 
			
		||||
	Name         string
 | 
			
		||||
	Type         string
 | 
			
		||||
	ReturnsError bool
 | 
			
		||||
	FailCond     string
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// ErrorVarName returns error variable name for r.
 | 
			
		||||
func (r *Rets) ErrorVarName() string {
 | 
			
		||||
	if r.ReturnsError {
 | 
			
		||||
		return "err"
 | 
			
		||||
	}
 | 
			
		||||
	if r.Type == "error" {
 | 
			
		||||
		return r.Name
 | 
			
		||||
	}
 | 
			
		||||
	return ""
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// ToParams converts r into slice of *Param.
 | 
			
		||||
func (r *Rets) ToParams() []*Param {
 | 
			
		||||
	ps := make([]*Param, 0)
 | 
			
		||||
	if len(r.Name) > 0 {
 | 
			
		||||
		ps = append(ps, &Param{Name: r.Name, Type: r.Type})
 | 
			
		||||
	}
 | 
			
		||||
	if r.ReturnsError {
 | 
			
		||||
		ps = append(ps, &Param{Name: "err", Type: "error"})
 | 
			
		||||
	}
 | 
			
		||||
	return ps
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// List returns source code of syscall return parameters.
 | 
			
		||||
func (r *Rets) List() string {
 | 
			
		||||
	s := join(r.ToParams(), func(p *Param) string { return p.Name + " " + p.Type }, ", ")
 | 
			
		||||
	if len(s) > 0 {
 | 
			
		||||
		s = "(" + s + ")"
 | 
			
		||||
	}
 | 
			
		||||
	return s
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// PrintList returns source code of trace printing part correspondent
 | 
			
		||||
// to syscall return values.
 | 
			
		||||
func (r *Rets) PrintList() string {
 | 
			
		||||
	return join(r.ToParams(), func(p *Param) string { return fmt.Sprintf(`"%s=", %s, `, p.Name, p.Name) }, `", ", `)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// SetReturnValuesCode returns source code that accepts syscall return values.
 | 
			
		||||
func (r *Rets) SetReturnValuesCode() string {
 | 
			
		||||
	if r.Name == "" && !r.ReturnsError {
 | 
			
		||||
		return ""
 | 
			
		||||
	}
 | 
			
		||||
	retvar := "r0"
 | 
			
		||||
	if r.Name == "" {
 | 
			
		||||
		retvar = "r1"
 | 
			
		||||
	}
 | 
			
		||||
	errvar := "_"
 | 
			
		||||
	if r.ReturnsError {
 | 
			
		||||
		errvar = "e1"
 | 
			
		||||
	}
 | 
			
		||||
	return fmt.Sprintf("%s, _, %s := ", retvar, errvar)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (r *Rets) useLongHandleErrorCode(retvar string) string {
 | 
			
		||||
	const code = `if %s {
 | 
			
		||||
		if e1 != 0 {
 | 
			
		||||
			err = errnoErr(e1)
 | 
			
		||||
		} else {
 | 
			
		||||
			err = %sEINVAL
 | 
			
		||||
		}
 | 
			
		||||
	}`
 | 
			
		||||
	cond := retvar + " == 0"
 | 
			
		||||
	if r.FailCond != "" {
 | 
			
		||||
		cond = strings.Replace(r.FailCond, "failretval", retvar, 1)
 | 
			
		||||
	}
 | 
			
		||||
	return fmt.Sprintf(code, cond, syscalldot())
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// SetErrorCode returns source code that sets return parameters.
 | 
			
		||||
func (r *Rets) SetErrorCode() string {
 | 
			
		||||
	const code = `if r0 != 0 {
 | 
			
		||||
		%s = %sErrno(r0)
 | 
			
		||||
	}`
 | 
			
		||||
	const hrCode = `if int32(r0) < 0 {
 | 
			
		||||
		%s = %sErrno(win32FromHresult(r0))
 | 
			
		||||
	}`
 | 
			
		||||
	if r.Name == "" && !r.ReturnsError {
 | 
			
		||||
		return ""
 | 
			
		||||
	}
 | 
			
		||||
	if r.Name == "" {
 | 
			
		||||
		return r.useLongHandleErrorCode("r1")
 | 
			
		||||
	}
 | 
			
		||||
	if r.Type == "error" {
 | 
			
		||||
		if r.Name == "hr" {
 | 
			
		||||
			return fmt.Sprintf(hrCode, r.Name, syscalldot())
 | 
			
		||||
		} else {
 | 
			
		||||
			return fmt.Sprintf(code, r.Name, syscalldot())
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	s := ""
 | 
			
		||||
	switch {
 | 
			
		||||
	case r.Type[0] == '*':
 | 
			
		||||
		s = fmt.Sprintf("%s = (%s)(unsafe.Pointer(r0))", r.Name, r.Type)
 | 
			
		||||
	case r.Type == "bool":
 | 
			
		||||
		s = fmt.Sprintf("%s = r0 != 0", r.Name)
 | 
			
		||||
	default:
 | 
			
		||||
		s = fmt.Sprintf("%s = %s(r0)", r.Name, r.Type)
 | 
			
		||||
	}
 | 
			
		||||
	if !r.ReturnsError {
 | 
			
		||||
		return s
 | 
			
		||||
	}
 | 
			
		||||
	return s + "\n\t" + r.useLongHandleErrorCode(r.Name)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Fn describes syscall function.
 | 
			
		||||
type Fn struct {
 | 
			
		||||
	Name        string
 | 
			
		||||
	Params      []*Param
 | 
			
		||||
	Rets        *Rets
 | 
			
		||||
	PrintTrace  bool
 | 
			
		||||
	confirmproc bool
 | 
			
		||||
	dllname     string
 | 
			
		||||
	dllfuncname string
 | 
			
		||||
	src         string
 | 
			
		||||
	// TODO: get rid of this field and just use parameter index instead
 | 
			
		||||
	curTmpVarIdx int // insure tmp variables have uniq names
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// extractParams parses s to extract function parameters.
 | 
			
		||||
func extractParams(s string, f *Fn) ([]*Param, error) {
 | 
			
		||||
	s = trim(s)
 | 
			
		||||
	if s == "" {
 | 
			
		||||
		return nil, nil
 | 
			
		||||
	}
 | 
			
		||||
	a := strings.Split(s, ",")
 | 
			
		||||
	ps := make([]*Param, len(a))
 | 
			
		||||
	for i := range ps {
 | 
			
		||||
		s2 := trim(a[i])
 | 
			
		||||
		b := strings.Split(s2, " ")
 | 
			
		||||
		if len(b) != 2 {
 | 
			
		||||
			b = strings.Split(s2, "\t")
 | 
			
		||||
			if len(b) != 2 {
 | 
			
		||||
				return nil, errors.New("Could not extract function parameter from \"" + s2 + "\"")
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		ps[i] = &Param{
 | 
			
		||||
			Name:      trim(b[0]),
 | 
			
		||||
			Type:      trim(b[1]),
 | 
			
		||||
			fn:        f,
 | 
			
		||||
			tmpVarIdx: -1,
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	return ps, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// extractSection extracts text out of string s starting after start
 | 
			
		||||
// and ending just before end. found return value will indicate success,
 | 
			
		||||
// and prefix, body and suffix will contain correspondent parts of string s.
 | 
			
		||||
func extractSection(s string, start, end rune) (prefix, body, suffix string, found bool) {
 | 
			
		||||
	s = trim(s)
 | 
			
		||||
	if strings.HasPrefix(s, string(start)) {
 | 
			
		||||
		// no prefix
 | 
			
		||||
		body = s[1:]
 | 
			
		||||
	} else {
 | 
			
		||||
		a := strings.SplitN(s, string(start), 2)
 | 
			
		||||
		if len(a) != 2 {
 | 
			
		||||
			return "", "", s, false
 | 
			
		||||
		}
 | 
			
		||||
		prefix = a[0]
 | 
			
		||||
		body = a[1]
 | 
			
		||||
	}
 | 
			
		||||
	a := strings.SplitN(body, string(end), 2)
 | 
			
		||||
	if len(a) != 2 {
 | 
			
		||||
		return "", "", "", false
 | 
			
		||||
	}
 | 
			
		||||
	return prefix, a[0], a[1], true
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// newFn parses string s and return created function Fn.
 | 
			
		||||
func newFn(s string) (*Fn, error) {
 | 
			
		||||
	s = trim(s)
 | 
			
		||||
	f := &Fn{
 | 
			
		||||
		Rets:       &Rets{},
 | 
			
		||||
		src:        s,
 | 
			
		||||
		PrintTrace: *printTraceFlag,
 | 
			
		||||
	}
 | 
			
		||||
	// function name and args
 | 
			
		||||
	prefix, body, s, found := extractSection(s, '(', ')')
 | 
			
		||||
	if !found || prefix == "" {
 | 
			
		||||
		return nil, errors.New("Could not extract function name and parameters from \"" + f.src + "\"")
 | 
			
		||||
	}
 | 
			
		||||
	f.Name = prefix
 | 
			
		||||
	var err error
 | 
			
		||||
	f.Params, err = extractParams(body, f)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
	// return values
 | 
			
		||||
	_, body, s, found = extractSection(s, '(', ')')
 | 
			
		||||
	if found {
 | 
			
		||||
		r, err := extractParams(body, f)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			return nil, err
 | 
			
		||||
		}
 | 
			
		||||
		switch len(r) {
 | 
			
		||||
		case 0:
 | 
			
		||||
		case 1:
 | 
			
		||||
			if r[0].IsError() {
 | 
			
		||||
				f.Rets.ReturnsError = true
 | 
			
		||||
			} else {
 | 
			
		||||
				f.Rets.Name = r[0].Name
 | 
			
		||||
				f.Rets.Type = r[0].Type
 | 
			
		||||
			}
 | 
			
		||||
		case 2:
 | 
			
		||||
			if !r[1].IsError() {
 | 
			
		||||
				return nil, errors.New("Only last windows error is allowed as second return value in \"" + f.src + "\"")
 | 
			
		||||
			}
 | 
			
		||||
			f.Rets.ReturnsError = true
 | 
			
		||||
			f.Rets.Name = r[0].Name
 | 
			
		||||
			f.Rets.Type = r[0].Type
 | 
			
		||||
		default:
 | 
			
		||||
			return nil, errors.New("Too many return values in \"" + f.src + "\"")
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	// fail condition
 | 
			
		||||
	_, body, s, found = extractSection(s, '[', ']')
 | 
			
		||||
	if found {
 | 
			
		||||
		f.Rets.FailCond = body
 | 
			
		||||
	}
 | 
			
		||||
	// dll and dll function names
 | 
			
		||||
	s = trim(s)
 | 
			
		||||
	if s == "" {
 | 
			
		||||
		return f, nil
 | 
			
		||||
	}
 | 
			
		||||
	if !strings.HasPrefix(s, "=") {
 | 
			
		||||
		return nil, errors.New("Could not extract dll name from \"" + f.src + "\"")
 | 
			
		||||
	}
 | 
			
		||||
	s = trim(s[1:])
 | 
			
		||||
	a := strings.Split(s, ".")
 | 
			
		||||
	switch len(a) {
 | 
			
		||||
	case 1:
 | 
			
		||||
		f.dllfuncname = a[0]
 | 
			
		||||
	case 2:
 | 
			
		||||
		f.dllname = a[0]
 | 
			
		||||
		f.dllfuncname = a[1]
 | 
			
		||||
	default:
 | 
			
		||||
		return nil, errors.New("Could not extract dll name from \"" + f.src + "\"")
 | 
			
		||||
	}
 | 
			
		||||
	if f.dllfuncname[len(f.dllfuncname)-1] == '?' {
 | 
			
		||||
		f.confirmproc = true
 | 
			
		||||
		f.dllfuncname = f.dllfuncname[0 : len(f.dllfuncname)-1]
 | 
			
		||||
	}
 | 
			
		||||
	return f, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// DLLName returns DLL name for function f.
 | 
			
		||||
func (f *Fn) DLLName() string {
 | 
			
		||||
	if f.dllname == "" {
 | 
			
		||||
		return "kernel32"
 | 
			
		||||
	}
 | 
			
		||||
	return f.dllname
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// DLLName returns DLL function name for function f.
 | 
			
		||||
func (f *Fn) DLLFuncName() string {
 | 
			
		||||
	if f.dllfuncname == "" {
 | 
			
		||||
		return f.Name
 | 
			
		||||
	}
 | 
			
		||||
	return f.dllfuncname
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (f *Fn) ConfirmProc() bool {
 | 
			
		||||
	return f.confirmproc
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// ParamList returns source code for function f parameters.
 | 
			
		||||
func (f *Fn) ParamList() string {
 | 
			
		||||
	return join(f.Params, func(p *Param) string { return p.Name + " " + p.Type }, ", ")
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// HelperParamList returns source code for helper function f parameters.
 | 
			
		||||
func (f *Fn) HelperParamList() string {
 | 
			
		||||
	return join(f.Params, func(p *Param) string { return p.Name + " " + p.HelperType() }, ", ")
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// ParamPrintList returns source code of trace printing part correspondent
 | 
			
		||||
// to syscall input parameters.
 | 
			
		||||
func (f *Fn) ParamPrintList() string {
 | 
			
		||||
	return join(f.Params, func(p *Param) string { return fmt.Sprintf(`"%s=", %s, `, p.Name, p.Name) }, `", ", `)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// ParamCount return number of syscall parameters for function f.
 | 
			
		||||
func (f *Fn) ParamCount() int {
 | 
			
		||||
	n := 0
 | 
			
		||||
	for _, p := range f.Params {
 | 
			
		||||
		n += len(p.SyscallArgList())
 | 
			
		||||
	}
 | 
			
		||||
	return n
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// SyscallParamCount determines which version of Syscall/Syscall6/Syscall9/...
 | 
			
		||||
// to use. It returns parameter count for correspondent SyscallX function.
 | 
			
		||||
func (f *Fn) SyscallParamCount() int {
 | 
			
		||||
	n := f.ParamCount()
 | 
			
		||||
	switch {
 | 
			
		||||
	case n <= 3:
 | 
			
		||||
		return 3
 | 
			
		||||
	case n <= 6:
 | 
			
		||||
		return 6
 | 
			
		||||
	case n <= 9:
 | 
			
		||||
		return 9
 | 
			
		||||
	case n <= 12:
 | 
			
		||||
		return 12
 | 
			
		||||
	case n <= 15:
 | 
			
		||||
		return 15
 | 
			
		||||
	default:
 | 
			
		||||
		panic("too many arguments to system call")
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Syscall determines which SyscallX function to use for function f.
 | 
			
		||||
func (f *Fn) Syscall() string {
 | 
			
		||||
	c := f.SyscallParamCount()
 | 
			
		||||
	if c == 3 {
 | 
			
		||||
		return syscalldot() + "Syscall"
 | 
			
		||||
	}
 | 
			
		||||
	return syscalldot() + "Syscall" + strconv.Itoa(c)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// SyscallParamList returns source code for SyscallX parameters for function f.
 | 
			
		||||
func (f *Fn) SyscallParamList() string {
 | 
			
		||||
	a := make([]string, 0)
 | 
			
		||||
	for _, p := range f.Params {
 | 
			
		||||
		a = append(a, p.SyscallArgList()...)
 | 
			
		||||
	}
 | 
			
		||||
	for len(a) < f.SyscallParamCount() {
 | 
			
		||||
		a = append(a, "0")
 | 
			
		||||
	}
 | 
			
		||||
	return strings.Join(a, ", ")
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// HelperCallParamList returns source code of call into function f helper.
 | 
			
		||||
func (f *Fn) HelperCallParamList() string {
 | 
			
		||||
	a := make([]string, 0, len(f.Params))
 | 
			
		||||
	for _, p := range f.Params {
 | 
			
		||||
		s := p.Name
 | 
			
		||||
		if p.Type == "string" {
 | 
			
		||||
			s = p.tmpVar()
 | 
			
		||||
		}
 | 
			
		||||
		a = append(a, s)
 | 
			
		||||
	}
 | 
			
		||||
	return strings.Join(a, ", ")
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// IsUTF16 is true, if f is W (utf16) function. It is false
 | 
			
		||||
// for all A (ascii) functions.
 | 
			
		||||
func (_ *Fn) IsUTF16() bool {
 | 
			
		||||
	return true
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// StrconvFunc returns name of Go string to OS string function for f.
 | 
			
		||||
func (f *Fn) StrconvFunc() string {
 | 
			
		||||
	if f.IsUTF16() {
 | 
			
		||||
		return syscalldot() + "UTF16PtrFromString"
 | 
			
		||||
	}
 | 
			
		||||
	return syscalldot() + "BytePtrFromString"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// StrconvType returns Go type name used for OS string for f.
 | 
			
		||||
func (f *Fn) StrconvType() string {
 | 
			
		||||
	if f.IsUTF16() {
 | 
			
		||||
		return "*uint16"
 | 
			
		||||
	}
 | 
			
		||||
	return "*byte"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// HasStringParam is true, if f has at least one string parameter.
 | 
			
		||||
// Otherwise it is false.
 | 
			
		||||
func (f *Fn) HasStringParam() bool {
 | 
			
		||||
	for _, p := range f.Params {
 | 
			
		||||
		if p.Type == "string" {
 | 
			
		||||
			return true
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	return false
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
var uniqDllFuncName = make(map[string]bool)
 | 
			
		||||
 | 
			
		||||
// IsNotDuplicate is true if f is not a duplicated function
 | 
			
		||||
func (f *Fn) IsNotDuplicate() bool {
 | 
			
		||||
	funcName := f.DLLFuncName()
 | 
			
		||||
	if uniqDllFuncName[funcName] == false {
 | 
			
		||||
		uniqDllFuncName[funcName] = true
 | 
			
		||||
		return true
 | 
			
		||||
	}
 | 
			
		||||
	return false
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// HelperName returns name of function f helper.
 | 
			
		||||
func (f *Fn) HelperName() string {
 | 
			
		||||
	if !f.HasStringParam() {
 | 
			
		||||
		return f.Name
 | 
			
		||||
	}
 | 
			
		||||
	return "_" + f.Name
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Source files and functions.
 | 
			
		||||
type Source struct {
 | 
			
		||||
	Funcs           []*Fn
 | 
			
		||||
	Files           []string
 | 
			
		||||
	StdLibImports   []string
 | 
			
		||||
	ExternalImports []string
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (src *Source) Import(pkg string) {
 | 
			
		||||
	src.StdLibImports = append(src.StdLibImports, pkg)
 | 
			
		||||
	sort.Strings(src.StdLibImports)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (src *Source) ExternalImport(pkg string) {
 | 
			
		||||
	src.ExternalImports = append(src.ExternalImports, pkg)
 | 
			
		||||
	sort.Strings(src.ExternalImports)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// ParseFiles parses files listed in fs and extracts all syscall
 | 
			
		||||
// functions listed in  sys comments. It returns source files
 | 
			
		||||
// and functions collection *Source if successful.
 | 
			
		||||
func ParseFiles(fs []string) (*Source, error) {
 | 
			
		||||
	src := &Source{
 | 
			
		||||
		Funcs: make([]*Fn, 0),
 | 
			
		||||
		Files: make([]string, 0),
 | 
			
		||||
		StdLibImports: []string{
 | 
			
		||||
			"unsafe",
 | 
			
		||||
		},
 | 
			
		||||
		ExternalImports: make([]string, 0),
 | 
			
		||||
	}
 | 
			
		||||
	for _, file := range fs {
 | 
			
		||||
		if err := src.ParseFile(file); err != nil {
 | 
			
		||||
			return nil, err
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	return src, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// DLLs return dll names for a source set src.
 | 
			
		||||
func (src *Source) DLLs() []string {
 | 
			
		||||
	uniq := make(map[string]bool)
 | 
			
		||||
	r := make([]string, 0)
 | 
			
		||||
	for _, f := range src.Funcs {
 | 
			
		||||
		name := f.DLLName()
 | 
			
		||||
		if _, found := uniq[name]; !found {
 | 
			
		||||
			uniq[name] = true
 | 
			
		||||
			r = append(r, name)
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	return r
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// ParseFile adds additional file path to a source set src.
 | 
			
		||||
func (src *Source) ParseFile(path string) error {
 | 
			
		||||
	file, err := os.Open(path)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return err
 | 
			
		||||
	}
 | 
			
		||||
	defer file.Close()
 | 
			
		||||
 | 
			
		||||
	s := bufio.NewScanner(file)
 | 
			
		||||
	for s.Scan() {
 | 
			
		||||
		t := trim(s.Text())
 | 
			
		||||
		if len(t) < 7 {
 | 
			
		||||
			continue
 | 
			
		||||
		}
 | 
			
		||||
		if !strings.HasPrefix(t, "//sys") {
 | 
			
		||||
			continue
 | 
			
		||||
		}
 | 
			
		||||
		t = t[5:]
 | 
			
		||||
		if !(t[0] == ' ' || t[0] == '\t') {
 | 
			
		||||
			continue
 | 
			
		||||
		}
 | 
			
		||||
		f, err := newFn(t[1:])
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			return err
 | 
			
		||||
		}
 | 
			
		||||
		src.Funcs = append(src.Funcs, f)
 | 
			
		||||
	}
 | 
			
		||||
	if err := s.Err(); err != nil {
 | 
			
		||||
		return err
 | 
			
		||||
	}
 | 
			
		||||
	src.Files = append(src.Files, path)
 | 
			
		||||
 | 
			
		||||
	// get package name
 | 
			
		||||
	fset := token.NewFileSet()
 | 
			
		||||
	_, err = file.Seek(0, 0)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return err
 | 
			
		||||
	}
 | 
			
		||||
	pkg, err := parser.ParseFile(fset, "", file, parser.PackageClauseOnly)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return err
 | 
			
		||||
	}
 | 
			
		||||
	packageName = pkg.Name.Name
 | 
			
		||||
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// IsStdRepo returns true if src is part of standard library.
 | 
			
		||||
func (src *Source) IsStdRepo() (bool, error) {
 | 
			
		||||
	if len(src.Files) == 0 {
 | 
			
		||||
		return false, errors.New("no input files provided")
 | 
			
		||||
	}
 | 
			
		||||
	abspath, err := filepath.Abs(src.Files[0])
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return false, err
 | 
			
		||||
	}
 | 
			
		||||
	goroot := runtime.GOROOT()
 | 
			
		||||
	if runtime.GOOS == "windows" {
 | 
			
		||||
		abspath = strings.ToLower(abspath)
 | 
			
		||||
		goroot = strings.ToLower(goroot)
 | 
			
		||||
	}
 | 
			
		||||
	sep := string(os.PathSeparator)
 | 
			
		||||
	if !strings.HasSuffix(goroot, sep) {
 | 
			
		||||
		goroot += sep
 | 
			
		||||
	}
 | 
			
		||||
	return strings.HasPrefix(abspath, goroot), nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Generate output source file from a source set src.
 | 
			
		||||
func (src *Source) Generate(w io.Writer) error {
 | 
			
		||||
	const (
 | 
			
		||||
		pkgStd         = iota // any package in std library
 | 
			
		||||
		pkgXSysWindows        // x/sys/windows package
 | 
			
		||||
		pkgOther
 | 
			
		||||
	)
 | 
			
		||||
	isStdRepo, err := src.IsStdRepo()
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return err
 | 
			
		||||
	}
 | 
			
		||||
	var pkgtype int
 | 
			
		||||
	switch {
 | 
			
		||||
	case isStdRepo:
 | 
			
		||||
		pkgtype = pkgStd
 | 
			
		||||
	case packageName == "windows":
 | 
			
		||||
		// TODO: this needs better logic than just using package name
 | 
			
		||||
		pkgtype = pkgXSysWindows
 | 
			
		||||
	default:
 | 
			
		||||
		pkgtype = pkgOther
 | 
			
		||||
	}
 | 
			
		||||
	if *systemDLL {
 | 
			
		||||
		switch pkgtype {
 | 
			
		||||
		case pkgStd:
 | 
			
		||||
			src.Import("internal/syscall/windows/sysdll")
 | 
			
		||||
		case pkgXSysWindows:
 | 
			
		||||
		default:
 | 
			
		||||
			src.ExternalImport("golang.org/x/sys/windows")
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	src.ExternalImport("github.com/Microsoft/go-winio")
 | 
			
		||||
	if packageName != "syscall" {
 | 
			
		||||
		src.Import("syscall")
 | 
			
		||||
	}
 | 
			
		||||
	funcMap := template.FuncMap{
 | 
			
		||||
		"packagename": packagename,
 | 
			
		||||
		"syscalldot":  syscalldot,
 | 
			
		||||
		"newlazydll": func(dll string) string {
 | 
			
		||||
			arg := "\"" + dll + ".dll\""
 | 
			
		||||
			if !*systemDLL {
 | 
			
		||||
				return syscalldot() + "NewLazyDLL(" + arg + ")"
 | 
			
		||||
			}
 | 
			
		||||
			switch pkgtype {
 | 
			
		||||
			case pkgStd:
 | 
			
		||||
				return syscalldot() + "NewLazyDLL(sysdll.Add(" + arg + "))"
 | 
			
		||||
			case pkgXSysWindows:
 | 
			
		||||
				return "NewLazySystemDLL(" + arg + ")"
 | 
			
		||||
			default:
 | 
			
		||||
				return "windows.NewLazySystemDLL(" + arg + ")"
 | 
			
		||||
			}
 | 
			
		||||
		},
 | 
			
		||||
	}
 | 
			
		||||
	t := template.Must(template.New("main").Funcs(funcMap).Parse(srcTemplate))
 | 
			
		||||
	err = t.Execute(w, src)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return errors.New("Failed to execute template: " + err.Error())
 | 
			
		||||
	}
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func usage() {
 | 
			
		||||
	fmt.Fprintf(os.Stderr, "usage: mksyscall_windows [flags] [path ...]\n")
 | 
			
		||||
	flag.PrintDefaults()
 | 
			
		||||
	os.Exit(1)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func main() {
 | 
			
		||||
	flag.Usage = usage
 | 
			
		||||
	flag.Parse()
 | 
			
		||||
	if len(flag.Args()) <= 0 {
 | 
			
		||||
		fmt.Fprintf(os.Stderr, "no files to parse provided\n")
 | 
			
		||||
		usage()
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	src, err := ParseFiles(flag.Args())
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		log.Fatal(err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	var buf bytes.Buffer
 | 
			
		||||
	if err := src.Generate(&buf); err != nil {
 | 
			
		||||
		log.Fatal(err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	data, err := format.Source(buf.Bytes())
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		log.Fatal(err)
 | 
			
		||||
	}
 | 
			
		||||
	if *filename == "" {
 | 
			
		||||
		_, err = os.Stdout.Write(data)
 | 
			
		||||
	} else {
 | 
			
		||||
		err = ioutil.WriteFile(*filename, data, 0644)
 | 
			
		||||
	}
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		log.Fatal(err)
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// TODO: use println instead to print in the following template
 | 
			
		||||
const srcTemplate = `
 | 
			
		||||
 | 
			
		||||
{{define "main"}}// MACHINE GENERATED BY 'go generate' COMMAND; DO NOT EDIT
 | 
			
		||||
 | 
			
		||||
package {{packagename}}
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
{{range .StdLibImports}}"{{.}}"
 | 
			
		||||
{{end}}
 | 
			
		||||
 | 
			
		||||
{{range .ExternalImports}}"{{.}}"
 | 
			
		||||
{{end}}
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
var _ unsafe.Pointer
 | 
			
		||||
 | 
			
		||||
// Do the interface allocations only once for common
 | 
			
		||||
// Errno values.
 | 
			
		||||
const (
 | 
			
		||||
	errnoERROR_IO_PENDING = 997
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
var (
 | 
			
		||||
	errERROR_IO_PENDING error = {{syscalldot}}Errno(errnoERROR_IO_PENDING)
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// errnoErr returns common boxed Errno values, to prevent
 | 
			
		||||
// allocations at runtime.
 | 
			
		||||
func errnoErr(e {{syscalldot}}Errno) error {
 | 
			
		||||
	switch e {
 | 
			
		||||
	case 0:
 | 
			
		||||
		return nil
 | 
			
		||||
	case errnoERROR_IO_PENDING:
 | 
			
		||||
		return errERROR_IO_PENDING
 | 
			
		||||
	}
 | 
			
		||||
	// TODO: add more here, after collecting data on the common
 | 
			
		||||
	// error values see on Windows. (perhaps when running
 | 
			
		||||
	// all.bat?)
 | 
			
		||||
	return e
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
var (
 | 
			
		||||
{{template "dlls" .}}
 | 
			
		||||
{{template "funcnames" .}})
 | 
			
		||||
{{range .Funcs}}{{if .HasStringParam}}{{template "helperbody" .}}{{end}}{{template "funcbody" .}}{{end}}
 | 
			
		||||
{{end}}
 | 
			
		||||
 | 
			
		||||
{{/* help functions */}}
 | 
			
		||||
 | 
			
		||||
{{define "dlls"}}{{range .DLLs}}	mod{{.}} = {{newlazydll .}}
 | 
			
		||||
{{end}}{{end}}
 | 
			
		||||
 | 
			
		||||
{{define "funcnames"}}{{range .Funcs}}{{if .IsNotDuplicate}}	proc{{.DLLFuncName}} = mod{{.DLLName}}.NewProc("{{.DLLFuncName}}"){{end}}
 | 
			
		||||
{{end}}{{end}}
 | 
			
		||||
 | 
			
		||||
{{define "helperbody"}}
 | 
			
		||||
func {{.Name}}({{.ParamList}}) {{template "results" .}}{
 | 
			
		||||
{{template "helpertmpvars" .}}	return {{.HelperName}}({{.HelperCallParamList}})
 | 
			
		||||
}
 | 
			
		||||
{{end}}
 | 
			
		||||
 | 
			
		||||
{{define "funcbody"}}
 | 
			
		||||
func {{.HelperName}}({{.HelperParamList}}) {{template "results" .}}{
 | 
			
		||||
{{template "tmpvars" .}}	{{template "syscallcheck" .}}{{template "syscall" .}}
 | 
			
		||||
{{template "seterror" .}}{{template "printtrace" .}}	return
 | 
			
		||||
}
 | 
			
		||||
{{end}}
 | 
			
		||||
 | 
			
		||||
{{define "helpertmpvars"}}{{range .Params}}{{if .TmpVarHelperCode}}	{{.TmpVarHelperCode}}
 | 
			
		||||
{{end}}{{end}}{{end}}
 | 
			
		||||
 | 
			
		||||
{{define "tmpvars"}}{{range .Params}}{{if .TmpVarCode}}	{{.TmpVarCode}}
 | 
			
		||||
{{end}}{{end}}{{end}}
 | 
			
		||||
 | 
			
		||||
{{define "results"}}{{if .Rets.List}}{{.Rets.List}} {{end}}{{end}}
 | 
			
		||||
 | 
			
		||||
{{define "syscall"}}{{.Rets.SetReturnValuesCode}}{{.Syscall}}(proc{{.DLLFuncName}}.Addr(), {{.ParamCount}}, {{.SyscallParamList}}){{end}}
 | 
			
		||||
 | 
			
		||||
{{define "syscallcheck"}}{{if .ConfirmProc}}if {{.Rets.ErrorVarName}} = proc{{.DLLFuncName}}.Find(); {{.Rets.ErrorVarName}} != nil {
 | 
			
		||||
    return
 | 
			
		||||
}
 | 
			
		||||
{{end}}{{end}}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
{{define "seterror"}}{{if .Rets.SetErrorCode}}	{{.Rets.SetErrorCode}}
 | 
			
		||||
{{end}}{{end}}
 | 
			
		||||
 | 
			
		||||
{{define "printtrace"}}{{if .PrintTrace}}	print("SYSCALL: {{.Name}}(", {{.ParamPrintList}}") (", {{.Rets.PrintList}}")\n")
 | 
			
		||||
{{end}}{{end}}
 | 
			
		||||
 | 
			
		||||
`
 | 
			
		||||
							
								
								
									
										2
									
								
								vendor/github.com/Microsoft/hcsshim/nametoguid.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								vendor/github.com/Microsoft/hcsshim/nametoguid.go
									
									
									
										generated
									
									
										vendored
									
									
								
							@@ -1,6 +1,6 @@
 | 
			
		||||
package hcsshim
 | 
			
		||||
 | 
			
		||||
import "github.com/Sirupsen/logrus"
 | 
			
		||||
import "github.com/sirupsen/logrus"
 | 
			
		||||
 | 
			
		||||
// NameToGuid converts the given string into a GUID using the algorithm in the
 | 
			
		||||
// Host Compute Service, ensuring GUIDs generated with the same string are common
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										2
									
								
								vendor/github.com/Microsoft/hcsshim/preparelayer.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								vendor/github.com/Microsoft/hcsshim/preparelayer.go
									
									
									
										generated
									
									
										vendored
									
									
								
							@@ -3,7 +3,7 @@ package hcsshim
 | 
			
		||||
import (
 | 
			
		||||
	"sync"
 | 
			
		||||
 | 
			
		||||
	"github.com/Sirupsen/logrus"
 | 
			
		||||
	"github.com/sirupsen/logrus"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
var prepareLayerLock sync.Mutex
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										9
									
								
								vendor/github.com/Microsoft/hcsshim/process.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										9
									
								
								vendor/github.com/Microsoft/hcsshim/process.go
									
									
									
										generated
									
									
										vendored
									
									
								
							@@ -3,12 +3,11 @@ package hcsshim
 | 
			
		||||
import (
 | 
			
		||||
	"encoding/json"
 | 
			
		||||
	"io"
 | 
			
		||||
	"runtime"
 | 
			
		||||
	"sync"
 | 
			
		||||
	"syscall"
 | 
			
		||||
	"time"
 | 
			
		||||
 | 
			
		||||
	"github.com/Sirupsen/logrus"
 | 
			
		||||
	"github.com/sirupsen/logrus"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// ContainerError is an error encountered in HCS
 | 
			
		||||
@@ -322,17 +321,11 @@ func (process *process) Close() error {
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	process.handle = 0
 | 
			
		||||
	runtime.SetFinalizer(process, nil)
 | 
			
		||||
 | 
			
		||||
	logrus.Debugf(title+" succeeded processid=%d", process.processID)
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// closeProcess wraps process.Close for use by a finalizer
 | 
			
		||||
func closeProcess(process *process) {
 | 
			
		||||
	process.Close()
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (process *process) registerCallback() error {
 | 
			
		||||
	context := ¬ifcationWatcherContext{
 | 
			
		||||
		channels: newChannels(),
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										2
									
								
								vendor/github.com/Microsoft/hcsshim/unpreparelayer.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								vendor/github.com/Microsoft/hcsshim/unpreparelayer.go
									
									
									
										generated
									
									
										vendored
									
									
								
							@@ -1,6 +1,6 @@
 | 
			
		||||
package hcsshim
 | 
			
		||||
 | 
			
		||||
import "github.com/Sirupsen/logrus"
 | 
			
		||||
import "github.com/sirupsen/logrus"
 | 
			
		||||
 | 
			
		||||
// UnprepareLayer disables the filesystem filter for the read-write layer with
 | 
			
		||||
// the given id.
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										3
									
								
								vendor/github.com/Microsoft/hcsshim/waithelper.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										3
									
								
								vendor/github.com/Microsoft/hcsshim/waithelper.go
									
									
									
										generated
									
									
										vendored
									
									
								
							@@ -3,7 +3,7 @@ package hcsshim
 | 
			
		||||
import (
 | 
			
		||||
	"time"
 | 
			
		||||
 | 
			
		||||
	"github.com/Sirupsen/logrus"
 | 
			
		||||
	"github.com/sirupsen/logrus"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
func processAsyncHcsResult(err error, resultp *uint16, callbackNumber uintptr, expectedNotification hcsNotification, timeout *time.Duration) error {
 | 
			
		||||
@@ -59,4 +59,5 @@ func waitForNotification(callbackNumber uintptr, expectedNotification hcsNotific
 | 
			
		||||
	case <-c:
 | 
			
		||||
		return ErrTimeout
 | 
			
		||||
	}
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user