...

Source file src/github.com/Microsoft/hcsshim/computestorage/format.go

Documentation: github.com/Microsoft/hcsshim/computestorage

     1  //go:build windows
     2  
     3  package computestorage
     4  
     5  import (
     6  	"context"
     7  
     8  	"github.com/Microsoft/hcsshim/internal/oc"
     9  	"github.com/pkg/errors"
    10  	"golang.org/x/sys/windows"
    11  )
    12  
    13  // FormatWritableLayerVhd formats a virtual disk for use as a writable container layer.
    14  //
    15  // If the VHD is not mounted it will be temporarily mounted.
    16  //
    17  // NOTE: This API had a breaking change in the operating system after Windows Server 2019.
    18  // On ws2019 the API expects to get passed a file handle from CreateFile for the vhd that
    19  // the caller wants to format. On > ws2019, its expected that the caller passes a vhd handle
    20  // that can be obtained from the virtdisk APIs.
    21  func FormatWritableLayerVhd(ctx context.Context, vhdHandle windows.Handle) (err error) {
    22  	title := "hcsshim::FormatWritableLayerVhd"
    23  	ctx, span := oc.StartSpan(ctx, title) //nolint:ineffassign,staticcheck
    24  	defer span.End()
    25  	defer func() { oc.SetSpanStatus(span, err) }()
    26  
    27  	err = hcsFormatWritableLayerVhd(vhdHandle)
    28  	if err != nil {
    29  		return errors.Wrap(err, "failed to format writable layer vhd")
    30  	}
    31  	return nil
    32  }
    33  

View as plain text