2023-05-17 11:36:01 -04:00
|
|
|
//go:build linux && cgo
|
|
|
|
|
|
|
|
/*
|
|
|
|
Copyright (c) Edgeless Systems GmbH
|
|
|
|
|
|
|
|
SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
*/
|
|
|
|
|
|
|
|
package cryptmapper
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
|
|
|
|
ccryptsetup "github.com/edgelesssys/constellation/v2/internal/cryptsetup"
|
|
|
|
cryptsetup "github.com/martinjungblut/go-cryptsetup"
|
|
|
|
mount "k8s.io/mount-utils"
|
|
|
|
utilexec "k8s.io/utils/exec"
|
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
2023-07-17 07:55:31 -04:00
|
|
|
resizeFlags = cryptsetup.CRYPT_ACTIVATE_KEYRING_KEY | ccryptsetup.ReadWriteQueueBypass
|
2023-05-17 11:36:01 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
cryptsetup.SetDebugLevel(cryptsetup.CRYPT_LOG_NORMAL)
|
|
|
|
cryptsetup.SetLogCallback(func(_ int, message string) { fmt.Printf("libcryptsetup: %s\n", message) })
|
|
|
|
}
|
|
|
|
|
2023-07-17 07:55:31 -04:00
|
|
|
func getDiskFormat(disk string) (string, error) {
|
|
|
|
mountUtil := &mount.SafeFormatAndMount{Exec: utilexec.New()}
|
|
|
|
return mountUtil.GetDiskFormat(disk)
|
2023-05-17 11:36:01 -04:00
|
|
|
}
|