Merge pull request #3500 from jterry75/revendor_go-winio
Update Microsoft/go-winio v0.4.14
This commit is contained in:
commit
4507cd1e04
@ -33,7 +33,7 @@ github.com/opencontainers/image-spec v1.0.1
|
|||||||
golang.org/x/sync 42b317875d0fa942474b76e1b46a6060d720ae6e
|
golang.org/x/sync 42b317875d0fa942474b76e1b46a6060d720ae6e
|
||||||
github.com/BurntSushi/toml v0.3.1
|
github.com/BurntSushi/toml v0.3.1
|
||||||
github.com/grpc-ecosystem/go-grpc-prometheus 6b7015e65d366bf3f19b2b2a000a831940f0f7e0
|
github.com/grpc-ecosystem/go-grpc-prometheus 6b7015e65d366bf3f19b2b2a000a831940f0f7e0
|
||||||
github.com/Microsoft/go-winio 7cdfd71a950d40d0da2167ccb690b541f7ba98c0
|
github.com/Microsoft/go-winio v0.4.14
|
||||||
github.com/Microsoft/hcsshim 8abdbb8205e4192c68b5f84c31197156f31be517
|
github.com/Microsoft/hcsshim 8abdbb8205e4192c68b5f84c31197156f31be517
|
||||||
google.golang.org/genproto d80a6e20e776b0b17a324d0ba1ab50a39c8e8944
|
google.golang.org/genproto d80a6e20e776b0b17a324d0ba1ab50a39c8e8944
|
||||||
golang.org/x/text 19e51611da83d6be54ddafce4a4af510cb3e9ea4
|
golang.org/x/text 19e51611da83d6be54ddafce4a4af510cb3e9ea4
|
||||||
|
27
vendor/github.com/Microsoft/go-winio/pkg/etw/provider.go
generated
vendored
27
vendor/github.com/Microsoft/go-winio/pkg/etw/provider.go
generated
vendored
@ -94,26 +94,27 @@ func providerCallbackAdapter(sourceID *guid.GUID, state uintptr, level uintptr,
|
|||||||
// uses the same algorithm as used by .NET's EventSource class, which is based
|
// uses the same algorithm as used by .NET's EventSource class, which is based
|
||||||
// on RFC 4122. More information on the algorithm can be found here:
|
// on RFC 4122. More information on the algorithm can be found here:
|
||||||
// https://blogs.msdn.microsoft.com/dcook/2015/09/08/etw-provider-names-and-guids/
|
// https://blogs.msdn.microsoft.com/dcook/2015/09/08/etw-provider-names-and-guids/
|
||||||
// The algorithm is roughly:
|
//
|
||||||
// Hash = Sha1(namespace + arg.ToUpper().ToUtf16be())
|
// The algorithm is roughly the RFC 4122 algorithm for a V5 UUID, but differs in
|
||||||
// Guid = Hash[0..15], with Hash[7] tweaked according to RFC 4122
|
// the following ways:
|
||||||
|
// - The input name is first upper-cased, UTF16-encoded, and converted to
|
||||||
|
// big-endian.
|
||||||
|
// - No variant is set on the result UUID.
|
||||||
|
// - The result UUID is treated as being in little-endian format, rather than
|
||||||
|
// big-endian.
|
||||||
func providerIDFromName(name string) guid.GUID {
|
func providerIDFromName(name string) guid.GUID {
|
||||||
buffer := sha1.New()
|
buffer := sha1.New()
|
||||||
|
namespace := guid.GUID{0x482C2DB2, 0xC390, 0x47C8, [8]byte{0x87, 0xF8, 0x1A, 0x15, 0xBF, 0xC1, 0x30, 0xFB}}
|
||||||
namespace := []byte{0x48, 0x2C, 0x2D, 0xB2, 0xC3, 0x90, 0x47, 0xC8, 0x87, 0xF8, 0x1A, 0x15, 0xBF, 0xC1, 0x30, 0xFB}
|
namespaceBytes := namespace.ToArray()
|
||||||
buffer.Write(namespace)
|
buffer.Write(namespaceBytes[:])
|
||||||
|
|
||||||
binary.Write(buffer, binary.BigEndian, utf16.Encode([]rune(strings.ToUpper(name))))
|
binary.Write(buffer, binary.BigEndian, utf16.Encode([]rune(strings.ToUpper(name))))
|
||||||
|
|
||||||
sum := buffer.Sum(nil)
|
sum := buffer.Sum(nil)
|
||||||
sum[7] = (sum[7] & 0xf) | 0x50
|
sum[7] = (sum[7] & 0xf) | 0x50
|
||||||
|
|
||||||
return guid.GUID{
|
a := [16]byte{}
|
||||||
Data1: binary.LittleEndian.Uint32(sum[0:4]),
|
copy(a[:], sum)
|
||||||
Data2: binary.LittleEndian.Uint16(sum[4:6]),
|
return guid.FromWindowsArray(a)
|
||||||
Data3: binary.LittleEndian.Uint16(sum[6:8]),
|
|
||||||
Data4: [8]byte{sum[8], sum[9], sum[10], sum[11], sum[12], sum[13], sum[14], sum[15]},
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewProvider creates and registers a new ETW provider. The provider ID is
|
// NewProvider creates and registers a new ETW provider. The provider ID is
|
||||||
|
7
vendor/github.com/Microsoft/go-winio/pkg/fs/fs_windows.go
generated
vendored
7
vendor/github.com/Microsoft/go-winio/pkg/fs/fs_windows.go
generated
vendored
@ -9,12 +9,17 @@ import (
|
|||||||
"golang.org/x/sys/windows"
|
"golang.org/x/sys/windows"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
// ErrInvalidPath is returned when the location of a file path doesn't begin with a driver letter.
|
||||||
|
ErrInvalidPath = errors.New("the path provided to GetFileSystemType must start with a drive letter")
|
||||||
|
)
|
||||||
|
|
||||||
// GetFileSystemType obtains the type of a file system through GetVolumeInformation.
|
// GetFileSystemType obtains the type of a file system through GetVolumeInformation.
|
||||||
// https://msdn.microsoft.com/en-us/library/windows/desktop/aa364993(v=vs.85).aspx
|
// https://msdn.microsoft.com/en-us/library/windows/desktop/aa364993(v=vs.85).aspx
|
||||||
func GetFileSystemType(path string) (fsType string, hr error) {
|
func GetFileSystemType(path string) (fsType string, hr error) {
|
||||||
drive := filepath.VolumeName(path)
|
drive := filepath.VolumeName(path)
|
||||||
if len(drive) != 2 {
|
if len(drive) != 2 {
|
||||||
return "", errors.New("getFileSystemType path must start with a drive letter")
|
return "", ErrInvalidPath
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
54
vendor/github.com/Microsoft/go-winio/pkg/guid/guid.go
generated
vendored
54
vendor/github.com/Microsoft/go-winio/pkg/guid/guid.go
generated
vendored
@ -7,6 +7,7 @@ package guid
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"crypto/rand"
|
"crypto/rand"
|
||||||
|
"crypto/sha1"
|
||||||
"encoding"
|
"encoding"
|
||||||
"encoding/binary"
|
"encoding/binary"
|
||||||
"fmt"
|
"fmt"
|
||||||
@ -52,10 +53,34 @@ func NewV4() (GUID, error) {
|
|||||||
return GUID{}, err
|
return GUID{}, err
|
||||||
}
|
}
|
||||||
|
|
||||||
b[6] = (b[6] & 0x0f) | 0x40 // Version 4 (randomly generated)
|
g := FromArray(b)
|
||||||
b[8] = (b[8] & 0x3f) | 0x80 // RFC4122 variant
|
g.setVersion(4) // Version 4 means randomly generated.
|
||||||
|
g.setVariant(VariantRFC4122)
|
||||||
|
|
||||||
return FromArray(b), nil
|
return g, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewV5 returns a new version 5 (generated from a string via SHA-1 hashing)
|
||||||
|
// GUID, as defined by RFC 4122. The RFC is unclear on the encoding of the name,
|
||||||
|
// and the sample code treats it as a series of bytes, so we do the same here.
|
||||||
|
//
|
||||||
|
// Some implementations, such as those found on Windows, treat the name as a
|
||||||
|
// big-endian UTF16 stream of bytes. If that is desired, the string can be
|
||||||
|
// encoded as such before being passed to this function.
|
||||||
|
func NewV5(namespace GUID, name []byte) (GUID, error) {
|
||||||
|
b := sha1.New()
|
||||||
|
namespaceBytes := namespace.ToArray()
|
||||||
|
b.Write(namespaceBytes[:])
|
||||||
|
b.Write(name)
|
||||||
|
|
||||||
|
a := [16]byte{}
|
||||||
|
copy(a[:], b.Sum(nil))
|
||||||
|
|
||||||
|
g := FromArray(a)
|
||||||
|
g.setVersion(5) // Version 5 means generated from a string.
|
||||||
|
g.setVariant(VariantRFC4122)
|
||||||
|
|
||||||
|
return g, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func fromArray(b [16]byte, order binary.ByteOrder) GUID {
|
func fromArray(b [16]byte, order binary.ByteOrder) GUID {
|
||||||
@ -150,6 +175,25 @@ func FromString(s string) (GUID, error) {
|
|||||||
return g, nil
|
return g, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (g *GUID) setVariant(v Variant) {
|
||||||
|
d := g.Data4[0]
|
||||||
|
switch v {
|
||||||
|
case VariantNCS:
|
||||||
|
d = (d & 0x7f)
|
||||||
|
case VariantRFC4122:
|
||||||
|
d = (d & 0x3f) | 0x80
|
||||||
|
case VariantMicrosoft:
|
||||||
|
d = (d & 0x1f) | 0xc0
|
||||||
|
case VariantFuture:
|
||||||
|
d = (d & 0x0f) | 0xe0
|
||||||
|
case VariantUnknown:
|
||||||
|
fallthrough
|
||||||
|
default:
|
||||||
|
panic(fmt.Sprintf("invalid variant: %d", v))
|
||||||
|
}
|
||||||
|
g.Data4[0] = d
|
||||||
|
}
|
||||||
|
|
||||||
// Variant returns the GUID variant, as defined in RFC 4122.
|
// Variant returns the GUID variant, as defined in RFC 4122.
|
||||||
func (g GUID) Variant() Variant {
|
func (g GUID) Variant() Variant {
|
||||||
b := g.Data4[0]
|
b := g.Data4[0]
|
||||||
@ -165,6 +209,10 @@ func (g GUID) Variant() Variant {
|
|||||||
return VariantUnknown
|
return VariantUnknown
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (g *GUID) setVersion(v Version) {
|
||||||
|
g.Data3 = (g.Data3 & 0x0fff) | (uint16(v) << 12)
|
||||||
|
}
|
||||||
|
|
||||||
// Version returns the GUID version, as defined in RFC 4122.
|
// Version returns the GUID version, as defined in RFC 4122.
|
||||||
func (g GUID) Version() Version {
|
func (g GUID) Version() Version {
|
||||||
return Version((g.Data3 & 0xF000) >> 12)
|
return Version((g.Data3 & 0xF000) >> 12)
|
||||||
|
10
vendor/github.com/Microsoft/go-winio/vhd/vhd.go
generated
vendored
10
vendor/github.com/Microsoft/go-winio/vhd/vhd.go
generated
vendored
@ -117,9 +117,13 @@ func CreateVhdx(path string, maxSizeInGb, blockSizeInMb uint32) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// DetachVhd detaches a VHD attached at the given path.
|
// DetachVhd detaches a mounted container layer vhd found at `path`.
|
||||||
func DetachVhd(path string) error {
|
func DetachVhd(path string) error {
|
||||||
handle, err := OpenVirtualDisk(path, VirtualDiskAccessDetach, OpenVirtualDiskFlagNone)
|
handle, err := OpenVirtualDisk(
|
||||||
|
path,
|
||||||
|
VirtualDiskAccessNone,
|
||||||
|
OpenVirtualDiskFlagCachedIO|OpenVirtualDiskFlagIgnoreRelativeParentLocator)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -127,7 +131,7 @@ func DetachVhd(path string) error {
|
|||||||
return detachVirtualDisk(handle, 0, 0)
|
return detachVirtualDisk(handle, 0, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
// OpenVirtuaDisk obtains a handle to a VHD opened with supplied access mask and flags.
|
// OpenVirtualDisk obtains a handle to a VHD opened with supplied access mask and flags.
|
||||||
func OpenVirtualDisk(path string, accessMask VirtualDiskAccessMask, flag VirtualDiskFlag) (syscall.Handle, error) {
|
func OpenVirtualDisk(path string, accessMask VirtualDiskAccessMask, flag VirtualDiskFlag) (syscall.Handle, error) {
|
||||||
var (
|
var (
|
||||||
defaultType virtualStorageType
|
defaultType virtualStorageType
|
||||||
|
Loading…
Reference in New Issue
Block a user