package cim

import "github.com/Microsoft/hcsshim/internal/wclayer/cim"

This package provides utilities for working with container image layers in the cim format via the wclayer APIs.

Index

Functions

func CleanupContainerMounts

func CleanupContainerMounts(containerID string) error

func DestroyCimLayer

func DestroyCimLayer(ctx context.Context, layerPath string) error

DestroyCimLayer destroys a cim layer i.e it removes all the cimfs files for the given layer as well as all of the other files that are stored in the layer directory (at path `layerPath`). If this is not a cimfs layer (i.e a cim file for the given layer does not exist) then nothing is done.

func GetCimDirFromLayer

func GetCimDirFromLayer(layerPath string) string

CimDir is the directory inside which all cims are stored.

func GetCimMountPath

func GetCimMountPath(cimPath, containerID string) (string, error)

GetCimMountPath returns the volume at which a cim is mounted. If the cim is not mounted returns error

func GetCimNameFromLayer

func GetCimNameFromLayer(layerPath string) string

CimName is the filename (<layerid>.cim) of the file representing the cim

func GetCimPathFromLayer

func GetCimPathFromLayer(layerPath string) string

CimPath is the path to the CimDir/<layerid>.cim file that represents a layer cim.

func IsCimLayer

func IsCimLayer(layerPath string) bool

IsCimLayer returns `true` if the layer at path `layerPath` is a cim layer. Returns `false` otherwise.

func MountCimLayer

func MountCimLayer(ctx context.Context, cimPath, containerID string) (string, error)

MountCimLayer mounts the cim at path `cimPath` and returns the mount location of that cim. This method uses the `CimMountFlagCacheFiles` mount flag when mounting the cim. The containerID is used to generated the volumeID for the volume at which this CIM is mounted. containerID is used so that if the shim process crashes for any reason, the mounted cim can be correctly cleaned up during `shim delete` call.

func UnmountCimLayer

func UnmountCimLayer(ctx context.Context, cimPath, containerID string) error

Unmount unmounts the cim at mounted for given container.

Types

type CimLayerWriter

type CimLayerWriter struct {
	// contains filtered or unexported fields
}

A CimLayerWriter implements the wclayer.LayerWriter interface to allow writing container image layers in the cim format. A cim layer consist of cim files (which are usually stored in the `cim-layers` directory and some other files which are stored in the directory of that layer (i.e the `path` directory).

func NewCimLayerWriter

func NewCimLayerWriter(ctx context.Context, path string, parentLayerPaths []string) (_ *CimLayerWriter, err error)

func (*CimLayerWriter) Add

func (cw *CimLayerWriter) Add(name string, fileInfo *winio.FileBasicInfo, fileSize int64, securityDescriptor []byte, extendedAttributes []byte, reparseData []byte) error

Add adds a file to the layer with given metadata.

func (*CimLayerWriter) AddAlternateStream

func (cw *CimLayerWriter) AddAlternateStream(name string, size uint64) error

AddAlternateStream creates another alternate stream at the given path. Any writes made after this call will go to that stream.

func (cw *CimLayerWriter) AddLink(name string, target string) error

AddLink adds a hard link to the layer. The target must already have been added.

func (*CimLayerWriter) Close

func (cw *CimLayerWriter) Close(ctx context.Context) (retErr error)

Close finishes the layer writing process and releases any resources.

func (*CimLayerWriter) Remove

func (cw *CimLayerWriter) Remove(name string) error

Remove removes a file that was present in a parent layer from the layer.

func (*CimLayerWriter) Write

func (cw *CimLayerWriter) Write(b []byte) (int, error)

Write writes data to the current file. The data must be in the format of a Win32 backup stream.

Source Files

LayerWriter.go bcd.go common.go doc.go file_writer.go mount.go pending.go process.go registry.go

Version
v0.12.6
Published
Aug 19, 2024
Platform
windows/amd64
Imports
33 packages
Last checked
6 minutes ago

Tools for package owners.