mirror of
https://github.com/libguestfs/libguestfs.git
synced 2026-03-21 22:53:37 +00:00
daemon/listfs: don't call "sgdisk -i" on bogus MBR partition table entry
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@redhat.com> Acked-by: Richard W.M. Jones <rjones@redhat.com> Message-Id: <20211125094954.9713-6-lersek@redhat.com>
This commit is contained in:
committed by
Richard W.M. Jones
parent
0efccea844
commit
7b5e00f036
@@ -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).
|
||||
|
||||
Reference in New Issue
Block a user