...

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

Documentation: github.com/Microsoft/hcsshim/computestorage

     1  //go:build windows
     2  
     3  package computestorage
     4  
     5  import (
     6  	"context"
     7  	"encoding/json"
     8  
     9  	"github.com/Microsoft/hcsshim/internal/oc"
    10  	"github.com/pkg/errors"
    11  	"go.opencensus.io/trace"
    12  )
    13  
    14  // InitializeWritableLayer initializes a writable layer for a container.
    15  //
    16  // `layerPath` is a path to a directory the layer is mounted. If the
    17  // path does not end in a `\` the platform will append it automatically.
    18  //
    19  // `layerData` is the parent read-only layer data.
    20  func InitializeWritableLayer(ctx context.Context, layerPath string, layerData LayerData) (err error) {
    21  	title := "hcsshim::InitializeWritableLayer"
    22  	ctx, span := oc.StartSpan(ctx, title) //nolint:ineffassign,staticcheck
    23  	defer span.End()
    24  	defer func() { oc.SetSpanStatus(span, err) }()
    25  	span.AddAttributes(
    26  		trace.StringAttribute("layerPath", layerPath),
    27  	)
    28  
    29  	bytes, err := json.Marshal(layerData)
    30  	if err != nil {
    31  		return err
    32  	}
    33  
    34  	// Options are not used in the platform as of RS5
    35  	err = hcsInitializeWritableLayer(layerPath, string(bytes), "")
    36  	if err != nil {
    37  		return errors.Wrap(err, "failed to intitialize container layer")
    38  	}
    39  	return nil
    40  }
    41  

View as plain text