repart: open target devices before UUID creation
authorMichael Ferrari <nekkodroid404@gmail.com>
Thu, 3 Oct 2024 12:02:12 +0000 (14:02 +0200)
committerLuca Boccassi <luca.boccassi@gmail.com>
Tue, 8 Oct 2024 15:39:12 +0000 (16:39 +0100)
This is to ensure that the UUIDs from the CopyBlocks= devices are copied
to the corresponding new partition instead of creating a new UUID for
it. With this verity partitions can be copied, keeping their UUIDs to
ensure that they still match up with what is specified in roothash=.

(cherry picked from commit f106fd2dbdbd9debfc2d2ed4d96ae3108a29c79b)

src/partition/repart.c

index 67fcf1469943e8170e2263b8184f68c7b030c90d..375f953dcc2f5fe6205221785f48a815e34021f0 100644 (file)
@@ -8285,11 +8285,6 @@ static int run(int argc, char *argv[]) {
                         return r;
         }
 
-        /* Make sure each partition has a unique UUID and unique label */
-        r = context_acquire_partition_uuids_and_labels(context);
-        if (r < 0)
-                return r;
-
         /* Open all files to copy blocks from now, since we want to take their size into consideration */
         r = context_open_copy_block_paths(
                         context,
@@ -8299,6 +8294,11 @@ static int run(int argc, char *argv[]) {
         if (r < 0)
                 return r;
 
+        /* Make sure each partition has a unique UUID and unique label */
+        r = context_acquire_partition_uuids_and_labels(context);
+        if (r < 0)
+                return r;
+
         r = context_fstab(context);
         if (r < 0)
                 return r;