wclayer

package
v0.7.14 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 6, 2018 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ActivateLayer

func ActivateLayer(path string) error

ActivateLayer will find the layer with the given id and mount it's filesystem. For a read/write layer, the mounted filesystem will appear as a volume on the host, while a read-only layer is generally expected to be a no-op. An activated layer must later be deactivated via DeactivateLayer.

func CreateLayer

func CreateLayer(path, parent string) error

CreateLayer creates a new, empty, read-only layer on the filesystem based on the parent layer provided.

func CreateScratchLayer

func CreateScratchLayer(path string, parentLayerPaths []string) error

CreateScratchLayer creates and populates new read-write layer for use by a container. This requires both the id of the direct parent layer, as well as the full list of paths to all parent layers up to the base (and including the direct parent whose id was provided).

func DeactivateLayer

func DeactivateLayer(path string) error

DeactivateLayer will dismount a layer that was mounted via ActivateLayer.

func DestroyLayer

func DestroyLayer(path string) error

DestroyLayer will remove the on-disk files representing the layer with the given path, including that layer's containing folder, if any.

func ExpandScratchSize

func ExpandScratchSize(path string, size uint64) error

ExpandScratchSize expands the size of a layer to at least size bytes.

func ExportLayer

func ExportLayer(path string, exportFolderPath string, parentLayerPaths []string) error

ExportLayer will create a folder at exportFolderPath and fill that folder with the transport format version of the layer identified by layerId. This transport format includes any metadata required for later importing the layer (using ImportLayer), and requires the full list of parent layer paths in order to perform the export.

func GetLayerMountPath

func GetLayerMountPath(path string) (string, error)

GetLayerMountPath will look for a mounted layer with the given path and return the path at which that layer can be accessed. This path may be a volume path if the layer is a mounted read-write layer, otherwise it is expected to be the folder path at which the layer is stored.

func GetSharedBaseImages

func GetSharedBaseImages() (imageData string, err error)

GetSharedBaseImages will enumerate the images stored in the common central image store and return descriptive info about those images for the purpose of registering them with the graphdriver, graph, and tagstore.

func GrantVmAccess

func GrantVmAccess(vmid string, filepath string) error

GrantVmAccess adds access to a file for a given VM

func ImportLayer

func ImportLayer(path string, importFolderPath string, parentLayerPaths []string) error

ImportLayer will take the contents of the folder at importFolderPath and import that into a layer with the id layerId. Note that in order to correctly populate the layer and interperet the transport format, all parent layers must already be present on the system at the paths provided in parentLayerPaths.

func LayerExists

func LayerExists(path string) (bool, error)

LayerExists will return true if a layer with the given id exists and is known to the system.

func LayerID

func LayerID(path string) (guid.GUID, error)

LayerID returns the layer ID of a layer on disk.

func NameToGuid

func NameToGuid(name string) (id guid.GUID, err error)

NameToGuid converts the given string into a GUID using the algorithm in the Host Compute Service, ensuring GUIDs generated with the same string are common across all clients.

func PrepareLayer

func PrepareLayer(path string, parentLayerPaths []string) error

PrepareLayer finds a mounted read-write layer matching path and enables the the filesystem filter for use on that layer. This requires the paths to all parent layers, and is necessary in order to view or interact with the layer as an actual filesystem (reading and writing files, creating directories, etc). Disabling the filter must be done via UnprepareLayer.

func ProcessBaseLayer

func ProcessBaseLayer(path string) error

ProcessBaseLayer post-processes a base layer that has had its files extracted. The files should have been extracted to <path>\Files.

func ProcessUtilityVMImage

func ProcessUtilityVMImage(path string) error

ProcessUtilityVMImage post-processes a utility VM image that has had its files extracted. The files should have been extracted to <path>\Files.

func UnprepareLayer

func UnprepareLayer(path string) error

UnprepareLayer disables the filesystem filter for the read-write layer with the given id.

Types

type FilterLayerReader

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

FilterLayerReader provides an interface for extracting the contents of an on-disk layer.

func (*FilterLayerReader) Close

func (r *FilterLayerReader) Close() (err error)

Close frees resources associated with the layer reader. It will return an error if there was an error while reading the layer or of the layer was not completely read.

func (*FilterLayerReader) Next

func (r *FilterLayerReader) Next() (string, int64, *winio.FileBasicInfo, error)

Next reads the next available file from a layer, ensuring that parent directories are always read before child files and directories.

Next returns the file's relative path, size, and basic file metadata. Read() should be used to extract a Win32 backup stream with the remainder of the metadata and the data.

func (*FilterLayerReader) Read

func (r *FilterLayerReader) Read(b []byte) (int, error)

Read reads from the current file's Win32 backup stream.

type FilterLayerWriter

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

FilterLayerWriter provides an interface to write the contents of a layer to the file system.

func (*FilterLayerWriter) Add

func (w *FilterLayerWriter) Add(name string, fileInfo *winio.FileBasicInfo) error

Add adds a file or directory to the layer. The file's parent directory must have already been added.

name contains the file's relative path. fileInfo contains file times and file attributes; the rest of the file metadata and the file data must be written as a Win32 backup stream to the Write() method. winio.BackupStreamWriter can be used to facilitate this.

func (w *FilterLayerWriter) AddLink(name string, target string) error

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

func (*FilterLayerWriter) Close

func (w *FilterLayerWriter) Close() (err error)

Close completes the layer write operation. The error must be checked to ensure that the operation was successful.

func (*FilterLayerWriter) Remove

func (w *FilterLayerWriter) Remove(name string) error

Remove removes a file from the layer. The file must have been present in the parent layer.

name contains the file's relative path.

func (*FilterLayerWriter) Write

func (w *FilterLayerWriter) Write(b []byte) (int, error)

Write writes more backup stream data to the current file.

type LayerReader

type LayerReader interface {
	Next() (string, int64, *winio.FileBasicInfo, error)
	Read(b []byte) (int, error)
	Close() error
}

func NewLayerReader

func NewLayerReader(path string, parentLayerPaths []string) (LayerReader, error)

NewLayerReader returns a new layer reader for reading the contents of an on-disk layer. The caller must have taken the SeBackupPrivilege privilege to call this and any methods on the resulting LayerReader.

type LayerWriter

type LayerWriter interface {
	// Add adds a file to the layer with given metadata.
	Add(name string, fileInfo *winio.FileBasicInfo) error
	// AddLink adds a hard link to the layer. The target must already have been added.
	AddLink(name string, target string) error
	// Remove removes a file that was present in a parent layer from the layer.
	Remove(name string) error
	// Write writes data to the current file. The data must be in the format of a Win32
	// backup stream.
	Write(b []byte) (int, error)
	// Close finishes the layer writing process and releases any resources.
	Close() error
}

LayerWriter is an interface that supports writing a new container image layer.

func NewLayerWriter

func NewLayerWriter(path string, parentLayerPaths []string) (LayerWriter, error)

NewLayerWriter returns a new layer writer for creating a layer on disk. The caller must have taken the SeBackupPrivilege and SeRestorePrivilege privileges to call this and any methods on the resulting LayerWriter.

type WC_LAYER_DESCRIPTOR

type WC_LAYER_DESCRIPTOR struct {
	LayerId guid.GUID
	Flags   uint32
	Pathp   *uint16
}
To pass into syscall, we need a struct matching the following:

typedef struct _WC_LAYER_DESCRIPTOR {

//
// The ID of the layer
//

GUID LayerId;

//
// Additional flags
//

union {
    struct {
        ULONG Reserved : 31;
        ULONG Dirty : 1;    // Created from sandbox as a result of snapshot
    };
    ULONG Value;
} Flags;

//
// Path to the layer root directory, null-terminated
//

PCWSTR Path;

} WC_LAYER_DESCRIPTOR, *PWC_LAYER_DESCRIPTOR;

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL