summaryrefslogtreecommitdiff
path: root/vendor/github.com/Microsoft/go-winio
diff options
context:
space:
mode:
authordependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>2020-05-13 09:20:53 +0000
committerDaniel J Walsh <dwalsh@redhat.com>2020-05-14 07:23:58 -0400
commit1f0cc866d4707c75116d210dc781534c9d7f62fd (patch)
tree0e5a15f979b88eb2e05adb7ac0967dbfcaa7a459 /vendor/github.com/Microsoft/go-winio
parent150679d7b10ad56b7f41d22810eb2c421edf9da5 (diff)
downloadpodman-1f0cc866d4707c75116d210dc781534c9d7f62fd.tar.gz
podman-1f0cc866d4707c75116d210dc781534c9d7f62fd.tar.bz2
podman-1f0cc866d4707c75116d210dc781534c9d7f62fd.zip
Bump github.com/containers/storage from 1.19.1 to 1.19.2
Bumps [github.com/containers/storage](https://github.com/containers/storage) from 1.19.1 to 1.19.2. - [Release notes](https://github.com/containers/storage/releases) - [Changelog](https://github.com/containers/storage/blob/master/docs/containers-storage-changes.md) - [Commits](https://github.com/containers/storage/compare/v1.19.1...v1.19.2) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> Signed-off-by: Valentin Rothberg <rothberg@redhat.com> Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
Diffstat (limited to 'vendor/github.com/Microsoft/go-winio')
-rw-r--r--vendor/github.com/Microsoft/go-winio/vhd/vhd.go151
-rw-r--r--vendor/github.com/Microsoft/go-winio/vhd/zvhd.go99
2 files changed, 250 insertions, 0 deletions
diff --git a/vendor/github.com/Microsoft/go-winio/vhd/vhd.go b/vendor/github.com/Microsoft/go-winio/vhd/vhd.go
new file mode 100644
index 000000000..229ac2556
--- /dev/null
+++ b/vendor/github.com/Microsoft/go-winio/vhd/vhd.go
@@ -0,0 +1,151 @@
+// +build windows
+
+package vhd
+
+import "syscall"
+
+//go:generate go run mksyscall_windows.go -output zvhd.go vhd.go
+
+//sys createVirtualDisk(virtualStorageType *virtualStorageType, path string, virtualDiskAccessMask uint32, securityDescriptor *uintptr, flags uint32, providerSpecificFlags uint32, parameters *createVirtualDiskParameters, o *syscall.Overlapped, handle *syscall.Handle) (err error) [failretval != 0] = VirtDisk.CreateVirtualDisk
+//sys openVirtualDisk(virtualStorageType *virtualStorageType, path string, virtualDiskAccessMask uint32, flags uint32, parameters *openVirtualDiskParameters, handle *syscall.Handle) (err error) [failretval != 0] = VirtDisk.OpenVirtualDisk
+//sys detachVirtualDisk(handle syscall.Handle, flags uint32, providerSpecificFlags uint32) (err error) [failretval != 0] = VirtDisk.DetachVirtualDisk
+
+type virtualStorageType struct {
+ DeviceID uint32
+ VendorID [16]byte
+}
+
+type (
+ createVirtualDiskFlag uint32
+ VirtualDiskAccessMask uint32
+ VirtualDiskFlag uint32
+)
+
+const (
+ // Flags for creating a VHD (not exported)
+ createVirtualDiskFlagNone createVirtualDiskFlag = 0
+ createVirtualDiskFlagFullPhysicalAllocation createVirtualDiskFlag = 1
+ createVirtualDiskFlagPreventWritesToSourceDisk createVirtualDiskFlag = 2
+ createVirtualDiskFlagDoNotCopyMetadataFromParent createVirtualDiskFlag = 4
+
+ // Access Mask for opening a VHD
+ VirtualDiskAccessNone VirtualDiskAccessMask = 0
+ VirtualDiskAccessAttachRO VirtualDiskAccessMask = 65536
+ VirtualDiskAccessAttachRW VirtualDiskAccessMask = 131072
+ VirtualDiskAccessDetach VirtualDiskAccessMask = 262144
+ VirtualDiskAccessGetInfo VirtualDiskAccessMask = 524288
+ VirtualDiskAccessCreate VirtualDiskAccessMask = 1048576
+ VirtualDiskAccessMetaOps VirtualDiskAccessMask = 2097152
+ VirtualDiskAccessRead VirtualDiskAccessMask = 851968
+ VirtualDiskAccessAll VirtualDiskAccessMask = 4128768
+ VirtualDiskAccessWritable VirtualDiskAccessMask = 3276800
+
+ // Flags for opening a VHD
+ OpenVirtualDiskFlagNone VirtualDiskFlag = 0
+ OpenVirtualDiskFlagNoParents VirtualDiskFlag = 0x1
+ OpenVirtualDiskFlagBlankFile VirtualDiskFlag = 0x2
+ OpenVirtualDiskFlagBootDrive VirtualDiskFlag = 0x4
+ OpenVirtualDiskFlagCachedIO VirtualDiskFlag = 0x8
+ OpenVirtualDiskFlagCustomDiffChain VirtualDiskFlag = 0x10
+ OpenVirtualDiskFlagParentCachedIO VirtualDiskFlag = 0x20
+ OpenVirtualDiskFlagVhdSetFileOnly VirtualDiskFlag = 0x40
+ OpenVirtualDiskFlagIgnoreRelativeParentLocator VirtualDiskFlag = 0x80
+ OpenVirtualDiskFlagNoWriteHardening VirtualDiskFlag = 0x100
+)
+
+type createVersion2 struct {
+ UniqueID [16]byte // GUID
+ MaximumSize uint64
+ BlockSizeInBytes uint32
+ SectorSizeInBytes uint32
+ ParentPath *uint16 // string
+ SourcePath *uint16 // string
+ OpenFlags uint32
+ ParentVirtualStorageType virtualStorageType
+ SourceVirtualStorageType virtualStorageType
+ ResiliencyGUID [16]byte // GUID
+}
+
+type createVirtualDiskParameters struct {
+ Version uint32 // Must always be set to 2
+ Version2 createVersion2
+}
+
+type openVersion2 struct {
+ GetInfoOnly int32 // bool but 4-byte aligned
+ ReadOnly int32 // bool but 4-byte aligned
+ ResiliencyGUID [16]byte // GUID
+}
+
+type openVirtualDiskParameters struct {
+ Version uint32 // Must always be set to 2
+ Version2 openVersion2
+}
+
+// CreateVhdx will create a simple vhdx file at the given path using default values.
+func CreateVhdx(path string, maxSizeInGb, blockSizeInMb uint32) error {
+ var (
+ defaultType virtualStorageType
+ handle syscall.Handle
+ )
+
+ parameters := createVirtualDiskParameters{
+ Version: 2,
+ Version2: createVersion2{
+ MaximumSize: uint64(maxSizeInGb) * 1024 * 1024 * 1024,
+ BlockSizeInBytes: blockSizeInMb * 1024 * 1024,
+ },
+ }
+
+ if err := createVirtualDisk(
+ &defaultType,
+ path,
+ uint32(VirtualDiskAccessNone),
+ nil,
+ uint32(createVirtualDiskFlagNone),
+ 0,
+ &parameters,
+ nil,
+ &handle); err != nil {
+ return err
+ }
+
+ if err := syscall.CloseHandle(handle); err != nil {
+ return err
+ }
+
+ return nil
+}
+
+// DetachVhd detaches a mounted container layer vhd found at `path`.
+func DetachVhd(path string) error {
+ handle, err := OpenVirtualDisk(
+ path,
+ VirtualDiskAccessNone,
+ OpenVirtualDiskFlagCachedIO|OpenVirtualDiskFlagIgnoreRelativeParentLocator)
+
+ if err != nil {
+ return err
+ }
+ defer syscall.CloseHandle(handle)
+ return detachVirtualDisk(handle, 0, 0)
+}
+
+// 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) {
+ var (
+ defaultType virtualStorageType
+ handle syscall.Handle
+ )
+ parameters := openVirtualDiskParameters{Version: 2}
+ if err := openVirtualDisk(
+ &defaultType,
+ path,
+ uint32(accessMask),
+ uint32(flag),
+ &parameters,
+ &handle); err != nil {
+ return 0, err
+ }
+ return handle, nil
+}
diff --git a/vendor/github.com/Microsoft/go-winio/vhd/zvhd.go b/vendor/github.com/Microsoft/go-winio/vhd/zvhd.go
new file mode 100644
index 000000000..00599ea49
--- /dev/null
+++ b/vendor/github.com/Microsoft/go-winio/vhd/zvhd.go
@@ -0,0 +1,99 @@
+// MACHINE GENERATED BY 'go generate' COMMAND; DO NOT EDIT
+
+package vhd
+
+import (
+ "syscall"
+ "unsafe"
+
+ "golang.org/x/sys/windows"
+)
+
+var _ unsafe.Pointer
+
+// Do the interface allocations only once for common
+// Errno values.
+const (
+ errnoERROR_IO_PENDING = 997
+)
+
+var (
+ errERROR_IO_PENDING error = syscall.Errno(errnoERROR_IO_PENDING)
+)
+
+// errnoErr returns common boxed Errno values, to prevent
+// allocations at runtime.
+func errnoErr(e syscall.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 (
+ modVirtDisk = windows.NewLazySystemDLL("VirtDisk.dll")
+
+ procCreateVirtualDisk = modVirtDisk.NewProc("CreateVirtualDisk")
+ procOpenVirtualDisk = modVirtDisk.NewProc("OpenVirtualDisk")
+ procDetachVirtualDisk = modVirtDisk.NewProc("DetachVirtualDisk")
+)
+
+func createVirtualDisk(virtualStorageType *virtualStorageType, path string, virtualDiskAccessMask uint32, securityDescriptor *uintptr, flags uint32, providerSpecificFlags uint32, parameters *createVirtualDiskParameters, o *syscall.Overlapped, handle *syscall.Handle) (err error) {
+ var _p0 *uint16
+ _p0, err = syscall.UTF16PtrFromString(path)
+ if err != nil {
+ return
+ }
+ return _createVirtualDisk(virtualStorageType, _p0, virtualDiskAccessMask, securityDescriptor, flags, providerSpecificFlags, parameters, o, handle)
+}
+
+func _createVirtualDisk(virtualStorageType *virtualStorageType, path *uint16, virtualDiskAccessMask uint32, securityDescriptor *uintptr, flags uint32, providerSpecificFlags uint32, parameters *createVirtualDiskParameters, o *syscall.Overlapped, handle *syscall.Handle) (err error) {
+ r1, _, e1 := syscall.Syscall9(procCreateVirtualDisk.Addr(), 9, uintptr(unsafe.Pointer(virtualStorageType)), uintptr(unsafe.Pointer(path)), uintptr(virtualDiskAccessMask), uintptr(unsafe.Pointer(securityDescriptor)), uintptr(flags), uintptr(providerSpecificFlags), uintptr(unsafe.Pointer(parameters)), uintptr(unsafe.Pointer(o)), uintptr(unsafe.Pointer(handle)))
+ if r1 != 0 {
+ if e1 != 0 {
+ err = errnoErr(e1)
+ } else {
+ err = syscall.EINVAL
+ }
+ }
+ return
+}
+
+func openVirtualDisk(virtualStorageType *virtualStorageType, path string, virtualDiskAccessMask uint32, flags uint32, parameters *openVirtualDiskParameters, handle *syscall.Handle) (err error) {
+ var _p0 *uint16
+ _p0, err = syscall.UTF16PtrFromString(path)
+ if err != nil {
+ return
+ }
+ return _openVirtualDisk(virtualStorageType, _p0, virtualDiskAccessMask, flags, parameters, handle)
+}
+
+func _openVirtualDisk(virtualStorageType *virtualStorageType, path *uint16, virtualDiskAccessMask uint32, flags uint32, parameters *openVirtualDiskParameters, handle *syscall.Handle) (err error) {
+ r1, _, e1 := syscall.Syscall6(procOpenVirtualDisk.Addr(), 6, uintptr(unsafe.Pointer(virtualStorageType)), uintptr(unsafe.Pointer(path)), uintptr(virtualDiskAccessMask), uintptr(flags), uintptr(unsafe.Pointer(parameters)), uintptr(unsafe.Pointer(handle)))
+ if r1 != 0 {
+ if e1 != 0 {
+ err = errnoErr(e1)
+ } else {
+ err = syscall.EINVAL
+ }
+ }
+ return
+}
+
+func detachVirtualDisk(handle syscall.Handle, flags uint32, providerSpecificFlags uint32) (err error) {
+ r1, _, e1 := syscall.Syscall(procDetachVirtualDisk.Addr(), 3, uintptr(handle), uintptr(flags), uintptr(providerSpecificFlags))
+ if r1 != 0 {
+ if e1 != 0 {
+ err = errnoErr(e1)
+ } else {
+ err = syscall.EINVAL
+ }
+ }
+ return
+}