The "is_partition_can_hold_filesystem" function calls
"Parted.part_get_gpt_type" on the partition if:
- the partition table type is GPT,
- or the partition table type is MBR, and the partition is primary or
logical.
The one entry in the fake MBR partition table described in the previous
patch passes the second branch of this check, therefore
"Parted.part_get_gpt_type" is reached, and it invokes "sgdisk -i 1" on
the
disk.
Surprisingly (not), while "sgdisk -i" copes fine with valid MBR partition
tables, it chokes on the fake one. The output does not contain the
"Partition GUID code" line, and so "sgdisk_info_extract_field" throws
an
exception.
Prevent calling "Parted.part_get_gpt_type" on a bogus MBR partition table,
similarly to the "extended entry in MBR partition table" case; the
difference is that the bogus primary entry, unlike a valid extended entry,
*can* hold a filesystem.
Bugzilla:
https://bugzilla.redhat.com/show_bug.cgi?id=1931821
Signed-off-by: Laszlo Ersek <lersek(a)redhat.com>
Acked-by: Richard W.M. Jones <rjones(a)redhat.com>
---
Notes:
v3:
- pick up Rich's ACK
v2:
- new patch (sigh)
daemon/listfs.ml | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/daemon/listfs.ml b/daemon/listfs.ml
index d8add5005ade..63ced260a14d 100644
--- a/daemon/listfs.ml
+++ b/daemon/listfs.ml
@@ -109,6 +109,8 @@ and is_partition_can_hold_filesystem partition =
if is_gpt_or_mbr then (
if is_mbr_extended parttype device partnum then
false
+ else if is_mbr_bogus parttype device partnum then
+ true
else (
(* MBR partition id will be converted into corresponding GPT type. *)
let gpt_type = Parted.part_get_gpt_type device partnum in
@@ -130,6 +132,9 @@ and is_mbr_extended parttype device partnum =
parttype = "msdos" &&
Parted.part_get_mbr_part_type device partnum = "extended"
+and is_mbr_bogus parttype device partnum =
+ parttype = "msdos" && partnum = 1 && Utils.has_bogus_mbr
device
+
(* Use vfs-type to check for a filesystem of some sort of [device].
* Appends (device, vfs_type) to the ret parameter (there may be
* multiple devices found in the case of btrfs).
--
2.19.1.3.g30247aa5d201