summaryrefslogtreecommitdiff
path: root/src/partition
diff options
context:
space:
mode:
authorDaan De Meyer <daan.j.demeyer@gmail.com>2023-04-26 10:16:21 +0200
committerDaan De Meyer <daan.j.demeyer@gmail.com>2023-04-26 10:16:21 +0200
commit13bde177e4423a2f2646bbda724eb57ee7d7a3a0 (patch)
tree837c09bceaa284f433894b5880c44f87f9a5c3a6 /src/partition
parente463e257c70120a66324abfaa11ef7fe4319a697 (diff)
downloadsystemd-13bde177e4423a2f2646bbda724eb57ee7d7a3a0.tar.gz
repart: Allow passing target to format_verity_hash()
Let's allow specifying where the verity hash data should be written as preparation for adding verity hash partition minimize support.
Diffstat (limited to 'src/partition')
-rw-r--r--src/partition/repart.c25
1 files changed, 16 insertions, 9 deletions
diff --git a/src/partition/repart.c b/src/partition/repart.c
index 08ca4f4c0b..02b09c175c 100644
--- a/src/partition/repart.c
+++ b/src/partition/repart.c
@@ -3547,6 +3547,7 @@ static int partition_encrypt(Context *context, Partition *p, const char *node) {
static int partition_format_verity_hash(
Context *context,
Partition *p,
+ const char *node,
const char *data_node) {
#if HAVE_LIBCRYPTSETUP
@@ -3575,11 +3576,15 @@ static int partition_format_verity_hash(
if (r < 0)
return log_error_errno(r, "libcryptsetup not found, cannot setup verity: %m");
- r = partition_target_prepare(context, p, p->new_size, /*need_path=*/ true, &t);
- if (r < 0)
- return r;
+ if (!node) {
+ r = partition_target_prepare(context, p, p->new_size, /*need_path=*/ true, &t);
+ if (r < 0)
+ return r;
- r = sym_crypt_init(&cd, partition_target_path(t));
+ node = partition_target_path(t);
+ }
+
+ r = sym_crypt_init(&cd, node);
if (r < 0)
return log_error_errno(r, "Failed to allocate libcryptsetup context: %m");
@@ -3608,9 +3613,11 @@ static int partition_format_verity_hash(
return log_error_errno(r, "Failed to setup verity hash data: %m");
}
- r = partition_target_sync(context, p, t);
- if (r < 0)
- return r;
+ if (t) {
+ r = partition_target_sync(context, p, t);
+ if (r < 0)
+ return r;
+ }
r = sym_crypt_get_volume_key_size(cd);
if (r < 0)
@@ -3810,7 +3817,7 @@ static int context_copy_blocks(Context *context) {
if (p->siblings[VERITY_HASH] && !partition_defer(p->siblings[VERITY_HASH])) {
r = partition_format_verity_hash(context, p->siblings[VERITY_HASH],
- partition_target_path(t));
+ /* node = */ NULL, partition_target_path(t));
if (r < 0)
return r;
}
@@ -4228,7 +4235,7 @@ static int context_mkfs(Context *context) {
if (p->siblings[VERITY_HASH] && !partition_defer(p->siblings[VERITY_HASH])) {
r = partition_format_verity_hash(context, p->siblings[VERITY_HASH],
- partition_target_path(t));
+ /* node = */ NULL, partition_target_path(t));
if (r < 0)
return r;
}