]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libblkid: set PTUUID for GPT and DOS
authorKarel Zak <kzak@redhat.com>
Thu, 13 Jun 2013 12:35:34 +0000 (14:35 +0200)
committerKarel Zak <kzak@redhat.com>
Thu, 13 Jun 2013 12:35:34 +0000 (14:35 +0200)
Signed-off-by: Karel Zak <kzak@redhat.com>
libblkid/src/partitions/dos.c
libblkid/src/partitions/gpt.c

index 3a0a6d73edbefbbdb443784fe781be1bf381dcfc..a9c79c34ad4461d341167da136dfafa3d73b664e 100644 (file)
@@ -138,6 +138,8 @@ static int probe_dos_pt(blkid_probe pr,
        struct dos_partition *p0, *p;
        unsigned char *data;
        uint32_t start, size, id;
+       char idstr[37];
+
 
        data = blkid_probe_get_sector(pr, 0);
        if (!data)
@@ -181,12 +183,20 @@ static int probe_dos_pt(blkid_probe pr,
        blkid_probe_use_wiper(pr, BLKID_MSDOS_PT_OFFSET,
                                  512 - BLKID_MSDOS_PT_OFFSET);
 
+       id = dos_parttable_id(data);
+       if (id)
+               snprintf(idstr, sizeof(idstr), "0x%08x", id);
+
        /*
         * Well, all checks pass, it's MS-DOS partiton table
         */
-       if (blkid_partitions_need_typeonly(pr))
-               /* caller does not ask for details about partitions */
+       if (blkid_partitions_need_typeonly(pr)) {
+               /* Non-binary interface -- caller does not ask for details
+                * about partitions, just set generic varibles only. */
+               if (id)
+                       blkid_partitions_strcpy_ptuuid(pr, idstr);
                return 0;
+       }
 
        ls = blkid_probe_get_partlist(pr);
 
@@ -200,14 +210,8 @@ static int probe_dos_pt(blkid_probe pr,
        if (!tab)
                goto err;
 
-       id = dos_parttable_id(data);
-       if (id) {
-               char buf[37];
-
-               snprintf(buf, sizeof(buf), "0x%08x", id);
-               blkid_parttable_set_id(tab, (unsigned char *) buf);
-       }
-
+       if (id)
+               blkid_parttable_set_id(tab, (unsigned char *) idstr);
 
        /* Parse primary partitions */
        for (p = p0, i = 0; i < 4; i++, p++) {
index 4441939297ca21938dbcc9ab53b4380f9265b20c..ee98154a30046c42aaa9a12906b79c7be5d24781 100644 (file)
@@ -322,9 +322,15 @@ static int probe_gpt_pt(blkid_probe pr,
                              (unsigned char *) GPT_HEADER_SIGNATURE_STR))
                goto err;
 
-       if (blkid_partitions_need_typeonly(pr))
-               /* caller does not ask for details about partitions */
+       guid = h->disk_guid;
+       swap_efi_guid(&guid);
+
+       if (blkid_partitions_need_typeonly(pr)) {
+               /* Non-binary interface -- caller does not ask for details
+                * about partitions, just set generic varibles only. */
+               blkid_partitions_set_ptuuid(pr, (unsigned char *) &guid);
                return 0;
+       }
 
        ls = blkid_probe_get_partlist(pr);
        if (!ls)
@@ -334,8 +340,6 @@ static int probe_gpt_pt(blkid_probe pr,
        if (!tab)
                goto err;
 
-       guid = h->disk_guid;
-       swap_efi_guid(&guid);
        blkid_parttable_set_id(tab, (const unsigned char *) &guid);
 
        ssf = blkid_probe_get_sectorsize(pr) / 512;