Merge pull request #28756 from DaanDeMeyer/repart-fix

repart --copy-from followups
This commit is contained in:
Daan De Meyer
2023-08-10 14:36:02 +02:00
committed by GitHub
2 changed files with 22 additions and 18 deletions

View File

@@ -443,9 +443,13 @@
<varlistentry>
<term><option>--copy-from=</option><arg>IMAGE</arg></term>
<listitem><para>Instructs <command>systemd-repart</command> to copy the partitions from the given
image. The partitions from the given image are synthesized into partition definitions that are
parsed before the partition definition files.</para></listitem>
<listitem><para>Instructs <command>systemd-repart</command> to synthesize partition definitions from
the partition table in the given image. The generated definitions will copy the partitions into the
destination partition table. The copied partitions will have the same size, metadata and contents but
might have a different partition number and might be located at a different offset in the destination
partition table. These definitions can be combined with partition definitions read from regular
partition definition files. The synthesized definitions take precedence over the definitions read
from partition definition files.</para></listitem>
</varlistentry>
<xi:include href="standard-options.xml" xpointer="help" />

View File

@@ -432,20 +432,20 @@ static void partition_foreignize(Partition *p) {
p->verity = VERITY_OFF;
}
static bool partition_type_exclude(GptPartitionType type) {
static bool partition_type_exclude(const GptPartitionType *type) {
if (arg_filter_partitions_type == FILTER_PARTITIONS_NONE)
return false;
for (size_t i = 0; i < arg_n_filter_partitions; i++)
if (sd_id128_equal(type.uuid, arg_filter_partitions[i].uuid))
if (sd_id128_equal(type->uuid, arg_filter_partitions[i].uuid))
return arg_filter_partitions_type == FILTER_PARTITIONS_EXCLUDE;
return arg_filter_partitions_type == FILTER_PARTITIONS_INCLUDE;
}
static bool partition_type_defer(GptPartitionType type) {
static bool partition_type_defer(const GptPartitionType *type) {
for (size_t i = 0; i < arg_n_defer_partitions; i++)
if (sd_id128_equal(type.uuid, arg_defer_partitions[i].uuid))
if (sd_id128_equal(type->uuid, arg_defer_partitions[i].uuid))
return true;
return false;
@@ -1662,7 +1662,7 @@ static int partition_read_definition(Partition *p, const char *path, const char
if (r < 0)
return r;
if (partition_type_exclude(p->type))
if (partition_type_exclude(&p->type))
return 0;
if (p->size_min != UINT64_MAX && p->size_max != UINT64_MAX && p->size_min > p->size_max)
@@ -1990,7 +1990,7 @@ static int context_copy_from(Context *context) {
assert(start <= UINT64_MAX/secsz);
start *= secsz;
if (partition_type_exclude(type))
if (partition_type_exclude(&type))
continue;
np = partition_new();
@@ -3277,7 +3277,7 @@ static int context_wipe_and_discard(Context *context) {
if (!p->allocated_to_area)
continue;
if (partition_type_defer(p->type))
if (partition_type_defer(&p->type))
continue;
r = context_wipe_partition(context, p);
@@ -4102,7 +4102,7 @@ static int context_copy_blocks(Context *context) {
if (PARTITION_EXISTS(p)) /* Never copy over existing partitions */
continue;
if (partition_type_defer(p->type))
if (partition_type_defer(&p->type))
continue;
assert(p->new_size != UINT64_MAX);
@@ -4143,14 +4143,14 @@ static int context_copy_blocks(Context *context) {
if (r < 0)
return r;
if (p->siblings[VERITY_HASH] && !partition_type_defer(p->siblings[VERITY_HASH]->type)) {
if (p->siblings[VERITY_HASH] && !partition_type_defer(&p->siblings[VERITY_HASH]->type)) {
r = partition_format_verity_hash(context, p->siblings[VERITY_HASH],
/* node = */ NULL, partition_target_path(t));
if (r < 0)
return r;
}
if (p->siblings[VERITY_SIG] && !partition_type_defer(p->siblings[VERITY_SIG]->type)) {
if (p->siblings[VERITY_SIG] && !partition_type_defer(&p->siblings[VERITY_SIG]->type)) {
r = partition_format_verity_sig(context, p->siblings[VERITY_SIG]);
if (r < 0)
return r;
@@ -4545,7 +4545,7 @@ static int context_mkfs(Context *context) {
if (p->copy_blocks_fd >= 0)
continue;
if (partition_type_defer(p->type))
if (partition_type_defer(&p->type))
continue;
assert(p->offset != UINT64_MAX);
@@ -4629,14 +4629,14 @@ static int context_mkfs(Context *context) {
if (r < 0)
return r;
if (p->siblings[VERITY_HASH] && !partition_type_defer(p->siblings[VERITY_HASH]->type)) {
if (p->siblings[VERITY_HASH] && !partition_type_defer(&p->siblings[VERITY_HASH]->type)) {
r = partition_format_verity_hash(context, p->siblings[VERITY_HASH],
/* node = */ NULL, partition_target_path(t));
if (r < 0)
return r;
}
if (p->siblings[VERITY_SIG] && !partition_type_defer(p->siblings[VERITY_SIG]->type)) {
if (p->siblings[VERITY_SIG] && !partition_type_defer(&p->siblings[VERITY_SIG]->type)) {
r = partition_format_verity_sig(context, p->siblings[VERITY_SIG]);
if (r < 0)
return r;
@@ -4974,7 +4974,7 @@ static int context_mangle_partitions(Context *context) {
if (p->dropped)
continue;
if (partition_type_defer(p->type))
if (partition_type_defer(&p->type))
continue;
assert(p->new_size != UINT64_MAX);
@@ -5223,7 +5223,7 @@ static int context_split(Context *context) {
if (!p->split_path)
continue;
if (partition_type_defer(p->type))
if (partition_type_defer(&p->type))
continue;
fdt = open(p->split_path, O_WRONLY|O_NOCTTY|O_CLOEXEC|O_NOFOLLOW|O_CREAT|O_EXCL, 0666);