From: Karel Zak Date: Thu, 13 Jun 2013 12:35:34 +0000 (+0200) Subject: libblkid: set PTUUID for GPT and DOS X-Git-Tag: v2.24-rc1~497 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6e9dfa41f2b52d0104cae5f7a9839599be64baab;p=thirdparty%2Futil-linux.git libblkid: set PTUUID for GPT and DOS Signed-off-by: Karel Zak --- diff --git a/libblkid/src/partitions/dos.c b/libblkid/src/partitions/dos.c index 3a0a6d73ed..a9c79c34ad 100644 --- a/libblkid/src/partitions/dos.c +++ b/libblkid/src/partitions/dos.c @@ -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++) { diff --git a/libblkid/src/partitions/gpt.c b/libblkid/src/partitions/gpt.c index 4441939297..ee98154a30 100644 --- a/libblkid/src/partitions/gpt.c +++ b/libblkid/src/partitions/gpt.c @@ -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;