diff options
author | Karel Zak | 2013-06-13 14:35:34 +0200 |
---|---|---|
committer | Karel Zak | 2013-06-13 14:35:34 +0200 |
commit | 6e9dfa41f2b52d0104cae5f7a9839599be64baab (patch) | |
tree | a3fe6a2efd599abb675578f6a7a1ec7ae2c216c9 /libblkid/src/partitions/dos.c | |
parent | libblkid: add functions to set PTUUID (diff) | |
download | kernel-qcow2-util-linux-6e9dfa41f2b52d0104cae5f7a9839599be64baab.tar.gz kernel-qcow2-util-linux-6e9dfa41f2b52d0104cae5f7a9839599be64baab.tar.xz kernel-qcow2-util-linux-6e9dfa41f2b52d0104cae5f7a9839599be64baab.zip |
libblkid: set PTUUID for GPT and DOS
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'libblkid/src/partitions/dos.c')
-rw-r--r-- | libblkid/src/partitions/dos.c | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/libblkid/src/partitions/dos.c b/libblkid/src/partitions/dos.c index 3a0a6d73e..a9c79c34a 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++) { |