diff options
author | Karel Zak | 2017-11-10 12:55:11 +0100 |
---|---|---|
committer | Karel Zak | 2017-11-10 12:55:11 +0100 |
commit | 4545ba62764779f50327f43e8af7e0400116f070 (patch) | |
tree | c4cabc5ca2d03dab1d344d00006e044be3877fe1 /libblkid | |
parent | libmount: fix access() utab write test (diff) | |
download | kernel-qcow2-util-linux-4545ba62764779f50327f43e8af7e0400116f070.tar.gz kernel-qcow2-util-linux-4545ba62764779f50327f43e8af7e0400116f070.tar.xz kernel-qcow2-util-linux-4545ba62764779f50327f43e8af7e0400116f070.zip |
libblkid: improve FreeBSD partitions parsing
FreeBSD since version 10 uses relative offsets for nested partitions.
Based on Richard Narron changes in kernel:block/partitions/msdos.c.
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'libblkid')
-rw-r--r-- | libblkid/src/partitions/bsd.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/libblkid/src/partitions/bsd.c b/libblkid/src/partitions/bsd.c index d83f2cf02..c74517334 100644 --- a/libblkid/src/partitions/bsd.c +++ b/libblkid/src/partitions/bsd.c @@ -37,6 +37,7 @@ static int probe_bsd_pt(blkid_probe pr, const struct blkid_idmag *mag) int i, nparts = BSD_MAXPARTITIONS; unsigned char *data; int rc = BLKID_PROBE_NONE; + uint32_t abs_offset = 0; if (blkid_partitions_need_typeonly(pr)) /* caller does not ask for details about partitions */ @@ -62,6 +63,7 @@ static int probe_bsd_pt(blkid_probe pr, const struct blkid_idmag *mag) switch(blkid_partition_get_type(parent)) { case MBR_FREEBSD_PARTITION: name = "freebsd"; + abs_offset = blkid_partition_get_start(parent); break; case MBR_NETBSD_PARTITION: name = "netbsd"; @@ -96,13 +98,20 @@ static int probe_bsd_pt(blkid_probe pr, const struct blkid_idmag *mag) blkid_partition par; uint32_t start, size; - /* TODO: in fdisk-mode returns all non-zero (p_size) partitions */ if (p->p_fstype == BSD_FS_UNUSED) continue; start = le32_to_cpu(p->p_offset); size = le32_to_cpu(p->p_size); + /* FreeBSD since version 10 uses relative offsets. We can use + * 3rd partition (special wholedisk partition) to detect this + * situation. + */ + if (abs_offset && nparts >= 3 + && le32_to_cpu(l->d_partitions[2].p_offset) == 0) + start += abs_offset; + if (parent && blkid_partition_get_start(parent) == start && blkid_partition_get_size(parent) == size) { DBG(LOWPROBE, ul_debug( |