From c1dbbf34c3ba15e32319ca4ac5c397f3cb9e947e Mon Sep 17 00:00:00 2001 From: Malte Poll Date: Fri, 19 May 2023 14:30:46 +0200 Subject: [PATCH] cryptsetup: Provide implementation without cgo --- internal/cryptsetup/BUILD.bazel | 5 ++++- internal/cryptsetup/crypsetup_cross.go | 15 +++++++++++++++ .../{cryptsetup.go => cryptsetup_cgo.go} | 2 ++ 3 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 internal/cryptsetup/crypsetup_cross.go rename internal/cryptsetup/{cryptsetup.go => cryptsetup_cgo.go} (94%) diff --git a/internal/cryptsetup/BUILD.bazel b/internal/cryptsetup/BUILD.bazel index e9884f1d4..2def0d584 100644 --- a/internal/cryptsetup/BUILD.bazel +++ b/internal/cryptsetup/BUILD.bazel @@ -2,7 +2,10 @@ load("@io_bazel_rules_go//go:def.bzl", "go_library") go_library( name = "cryptsetup", - srcs = ["cryptsetup.go"], + srcs = [ + "crypsetup_cross.go", + "cryptsetup_cgo.go", + ], # keep cdeps = [ "@//rpm:cryptsetup", diff --git a/internal/cryptsetup/crypsetup_cross.go b/internal/cryptsetup/crypsetup_cross.go new file mode 100644 index 000000000..c56d62b8f --- /dev/null +++ b/internal/cryptsetup/crypsetup_cross.go @@ -0,0 +1,15 @@ +//go:build !linux || !cgo + +/* +Copyright (c) Edgeless Systems GmbH + +SPDX-License-Identifier: AGPL-3.0-only +*/ +package cryptsetup + +const ( + // ReadWriteQueueBypass is a flag to disable the write and read workqueues for a crypt device. + ReadWriteQueueBypass = cryptActivateNoReadWorkqueue | cryptActivateNoWriteWorkqueue + cryptActivateNoReadWorkqueue = 0x1000000 + cryptActivateNoWriteWorkqueue = 0x2000000 +) diff --git a/internal/cryptsetup/cryptsetup.go b/internal/cryptsetup/cryptsetup_cgo.go similarity index 94% rename from internal/cryptsetup/cryptsetup.go rename to internal/cryptsetup/cryptsetup_cgo.go index 80c4a6bca..eddb820ea 100644 --- a/internal/cryptsetup/cryptsetup.go +++ b/internal/cryptsetup/cryptsetup_cgo.go @@ -1,3 +1,5 @@ +//go:build linux && cgo + /* Copyright (c) Edgeless Systems GmbH