repart: keep foreign partitions' UUID and label across partition table reloads
With --size=auto, repart unloads and reloads the partition table after context_acquire_partition_uuids_and_labels() ran. The reload recreates the foreign partitions (those without a definition) with a null new UUID and no new label, so context_mangle_partitions() sees them as changed and hits assert(!PARTITION_IS_FOREIGN(p)) when adding a partition to an existing image: Initializing UUID of existing partition 0. Setting partition label of existing partition 0. Assertion '!PARTITION_IS_FOREIGN(p)' failed. Set the new UUID and label of a foreign partition when it is loaded, so a reload keeps them. (cherry picked from commit 4fc4f6bac772ff3749ba7e0bbcd607175694420c)
This commit is contained in:
committed by
Luca Boccassi
parent
b2c8372d32
commit
5fe12bc9de
+10
-11
@@ -4130,6 +4130,14 @@ static int context_load_partition_table(Context *context) {
|
||||
np->partno = partno;
|
||||
np->current_label = TAKE_PTR(label_copy);
|
||||
|
||||
/* Never touch foreign partitions: keep their UUID and label. Set here rather than in
|
||||
* context_acquire_partition_uuids_and_labels(), as --size=auto reloads the partition
|
||||
* table after that ran, which recreates the foreign partitions. */
|
||||
np->new_uuid = id;
|
||||
r = strdup_to(&np->new_label, np->current_label);
|
||||
if (r < 0)
|
||||
return log_oom();
|
||||
|
||||
np->current_partition = p;
|
||||
sym_fdisk_ref_partition(p);
|
||||
|
||||
@@ -7863,18 +7871,9 @@ static int context_acquire_partition_uuids_and_labels(Context *context) {
|
||||
LIST_FOREACH(partitions, p, context->partitions) {
|
||||
sd_id128_t uuid;
|
||||
|
||||
/* Never touch foreign partitions */
|
||||
if (PARTITION_IS_FOREIGN(p)) {
|
||||
p->new_uuid = p->current_uuid;
|
||||
|
||||
if (p->current_label) {
|
||||
r = free_and_strdup_warn(&p->new_label, strempty(p->current_label));
|
||||
if (r < 0)
|
||||
return r;
|
||||
}
|
||||
|
||||
/* Never touch foreign partitions, their UUID and label are set when loading them. */
|
||||
if (PARTITION_IS_FOREIGN(p))
|
||||
continue;
|
||||
}
|
||||
|
||||
(void) context_notify(context, PROGRESS_ACQUIRING_PARTITION_LABELS, p->definition_path, UINT_MAX);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user