mirror of
https://github.com/aljazceru/kata-containers.git
synced 2025-12-26 10:34:24 +01:00
Gopkg.lock says it's "dbea6f2bd41658b84b00417ceefa416b979cbf10"
but it is actually "5017d4e9a9cf2d4381db99eacd9baf84b95bfb14".
We need to make sure Gopkg.lock does not lie otherwise `dep ensure`
would really fetch the locked revision and it causes build failure
due to API changes.
Introduced by: 76d9db3e0b (vendor: Add github.com/gogo/protobuf).
While at it, constraint containerd/cgroups to a working revision.
Fixes: #1447
Signed-off-by: Peng Tao <bergwolf@hyper.sh>
97 lines
1.8 KiB
Go
97 lines
1.8 KiB
Go
package wclayer
|
|
|
|
// This file contains utility functions to support storage (graph) related
|
|
// functionality.
|
|
|
|
import (
|
|
"syscall"
|
|
|
|
"github.com/Microsoft/hcsshim/internal/guid"
|
|
"github.com/sirupsen/logrus"
|
|
)
|
|
|
|
/* To pass into syscall, we need a struct matching the following:
|
|
enum GraphDriverType
|
|
{
|
|
DiffDriver,
|
|
FilterDriver
|
|
};
|
|
|
|
struct DriverInfo {
|
|
GraphDriverType Flavour;
|
|
LPCWSTR HomeDir;
|
|
};
|
|
*/
|
|
|
|
type driverInfo struct {
|
|
Flavour int
|
|
HomeDirp *uint16
|
|
}
|
|
|
|
var (
|
|
utf16EmptyString uint16
|
|
stdDriverInfo = driverInfo{1, &utf16EmptyString}
|
|
)
|
|
|
|
/* 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;
|
|
*/
|
|
type WC_LAYER_DESCRIPTOR struct {
|
|
LayerId guid.GUID
|
|
Flags uint32
|
|
Pathp *uint16
|
|
}
|
|
|
|
func layerPathsToDescriptors(parentLayerPaths []string) ([]WC_LAYER_DESCRIPTOR, error) {
|
|
// Array of descriptors that gets constructed.
|
|
var layers []WC_LAYER_DESCRIPTOR
|
|
|
|
for i := 0; i < len(parentLayerPaths); i++ {
|
|
g, err := LayerID(parentLayerPaths[i])
|
|
if err != nil {
|
|
logrus.WithError(err).Debug("Failed to convert name to guid")
|
|
return nil, err
|
|
}
|
|
|
|
p, err := syscall.UTF16PtrFromString(parentLayerPaths[i])
|
|
if err != nil {
|
|
logrus.WithError(err).Debug("Failed conversion of parentLayerPath to pointer")
|
|
return nil, err
|
|
}
|
|
|
|
layers = append(layers, WC_LAYER_DESCRIPTOR{
|
|
LayerId: g,
|
|
Flags: 0,
|
|
Pathp: p,
|
|
})
|
|
}
|
|
|
|
return layers, nil
|
|
}
|