aboutsummaryrefslogtreecommitdiff
path: root/vendor/github.com/Microsoft/hcsshim/internal/hcs/utils.go
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/hcsshim/internal/hcs/utils.go
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/hcsshim/internal/hcs/utils.go')
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/hcs/utils.go28
1 files changed, 28 insertions, 0 deletions
diff --git a/vendor/github.com/Microsoft/hcsshim/internal/hcs/utils.go b/vendor/github.com/Microsoft/hcsshim/internal/hcs/utils.go
index a638677ed..b474604bd 100644
--- a/vendor/github.com/Microsoft/hcsshim/internal/hcs/utils.go
+++ b/vendor/github.com/Microsoft/hcsshim/internal/hcs/utils.go
@@ -1,10 +1,14 @@
package hcs
import (
+ "context"
"io"
"syscall"
"github.com/Microsoft/go-winio"
+ diskutil "github.com/Microsoft/go-winio/vhd"
+ "github.com/pkg/errors"
+ "golang.org/x/sys/windows"
)
// makeOpenFiles calls winio.MakeOpenFile for each handle in a slice but closes all the handles
@@ -31,3 +35,27 @@ func makeOpenFiles(hs []syscall.Handle) (_ []io.ReadWriteCloser, err error) {
}
return fs, nil
}
+
+// creates a VHD formatted with NTFS of size `sizeGB` at the given `vhdPath`.
+func CreateNTFSVHD(ctx context.Context, vhdPath string, sizeGB uint32) (err error) {
+ if err := diskutil.CreateVhdx(vhdPath, sizeGB, 1); err != nil {
+ return errors.Wrap(err, "failed to create VHD")
+ }
+
+ vhd, err := diskutil.OpenVirtualDisk(vhdPath, diskutil.VirtualDiskAccessNone, diskutil.OpenVirtualDiskFlagNone)
+ if err != nil {
+ return errors.Wrap(err, "failed to open VHD")
+ }
+ defer func() {
+ err2 := windows.CloseHandle(windows.Handle(vhd))
+ if err == nil {
+ err = errors.Wrap(err2, "failed to close VHD")
+ }
+ }()
+
+ if err := hcsFormatWritableLayerVhd(uintptr(vhd)); err != nil {
+ return errors.Wrap(err, "failed to format VHD")
+ }
+
+ return nil
+}