[Libguestfs] [PATCH v6 7/7] daemon: list-ilesystems: Filter out MBR extended partitions.

Mykola Ivanets stenavin at gmail.com
Tue May 1 00:54:04 UTC 2018


Extended MBR partitions cannot hold filesystems - filter them out.
---
 daemon/listfs.ml | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/daemon/listfs.ml b/daemon/listfs.ml
index fa7813378..2ed7da6e3 100644
--- a/daemon/listfs.ml
+++ b/daemon/listfs.ml
@@ -83,7 +83,7 @@ and is_not_partitioned_device device =
  * to read them will cause errors (RHBZ#887520).  Assuming that
  * libguestfs was compiled with ldm support, we'll get the filesystems
  * on these later.  We also ignore Microsoft Reserved Partition and
- * Windows Snapshot Partition.
+ * Windows Snapshot Partition as well as MBR extended partitions.
  *)
 and is_partition_can_hold_filesystem partition =
   let device = Devsparts.part_to_dev partition in
@@ -106,10 +106,17 @@ and is_partition_can_hold_filesystem partition =
       | "E3C9E316-0B5C-4DB8-817D-F92DF00215AE"
       (* Windows Snapshot Partition. *)
       | "CADDEBF1-4400-4DE8-B103-12117DCF3CCF" -> false
-    | _ -> true
+    | _ -> not (is_mbr_extended parttype device partnum)
   )
   else true
 
+and is_mbr_extended parttype device partnum =
+  if parttype = "msdos" then (
+    let mbr_type = Parted.part_get_mbr_part_type device partnum in
+    mbr_type = "extended"
+  )
+  else false
+
 (* Use vfs-type to check for a filesystem of some sort of [device].
  * Returns [Some [device, vfs_type; ...]] if found (there may be
  * multiple devices found in the case of btrfs), else [None] if nothing
-- 
2.17.0




More information about the Libguestfs mailing list