]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
dissect: return the GPT partition UUID, too
authorLennart Poettering <lennart@poettering.net>
Thu, 15 Dec 2016 16:17:43 +0000 (17:17 +0100)
committerLennart Poettering <lennart@poettering.net>
Wed, 21 Dec 2016 18:09:30 +0000 (19:09 +0100)
This is useful as we can match up the EFI UUID with the one the firmware
supposedly used.

src/dissect/dissect.c
src/shared/dissect-image.c
src/shared/dissect-image.h

index aa06894037e68f5f252a09df2433c473effcac58..78ec88fa35475c4423761e5651702b4fb52ff3eb 100644 (file)
@@ -221,6 +221,9 @@ int main(int argc, char *argv[]) {
                                p->rw ? "writable" : "read-only",
                                partition_designator_to_string(i));
 
+                        if (!sd_id128_is_null(p->uuid))
+                                printf(" (UUID " SD_ID128_FORMAT_STR ")", SD_ID128_FORMAT_VAL(p->uuid));
+
                         if (p->fstype)
                                 printf(" of type %s", p->fstype);
 
index 10d53eab4533adfecb3ba8b85190212ce2051198..5b6e78dd3d2ba15a13c46dce3dd6b3402655f6f8 100644 (file)
@@ -95,6 +95,7 @@ int dissect_image(int fd, const void *root_hash, size_t root_hash_size, DissectI
         _cleanup_blkid_free_probe_ blkid_probe b = NULL;
         _cleanup_udev_unref_ struct udev *udev = NULL;
         _cleanup_free_ char *generic_node = NULL;
+        sd_id128_t generic_uuid = SD_ID128_NULL;
         const char *pttype = NULL;
         struct udev_list_entry *first, *item;
         blkid_partlist pl;
@@ -427,6 +428,7 @@ int dissect_image(int fd, const void *root_hash, size_t root_hash_size, DissectI
                                 else {
                                         generic_nr = nr;
                                         generic_rw = !(pflags & GPT_FLAG_READ_ONLY);
+                                        generic_uuid = id;
                                         generic_node = strdup(node);
                                         if (!generic_node)
                                                 return -ENOMEM;
@@ -457,6 +459,7 @@ int dissect_image(int fd, const void *root_hash, size_t root_hash_size, DissectI
                                         .architecture = architecture,
                                         .node = n,
                                         .fstype = t,
+                                        .uuid = id,
                                 };
 
                                 n = t = NULL;
@@ -507,6 +510,7 @@ int dissect_image(int fd, const void *root_hash, size_t root_hash_size, DissectI
                                 .partno = generic_nr,
                                 .architecture = _ARCHITECTURE_INVALID,
                                 .node = generic_node,
+                                .uuid = generic_uuid,
                         };
 
                         generic_node = NULL;
index b424dac665458e546d4994570b2fad46941f16da..76104e578071ec1a88b58a6912d4c3bc9ba42bbd 100644 (file)
@@ -32,6 +32,7 @@ struct DissectedPartition {
         bool rw:1;
         int partno;        /* -1 if there was no partition and the images contains a file system directly */
         int architecture;  /* Intended architecture: either native, secondary or unset (-1). */
+        sd_id128_t uuid;   /* Partition entry UUID as reported by the GPT */
         char *fstype;
         char *node;
         char *decrypted_node;