[Libguestfs] [RFC PATCH v1 3/3] daemon: list-filesystems: Don't list partitioned md devices

Mykola Ivanets stenavin at gmail.com
Mon Jan 22 22:44:13 UTC 2018


Filter partitioned md devices out the same way as partitioned physical devices are filtered out
---
 daemon/listfs.ml | 22 +++++++++-------------
 1 file changed, 9 insertions(+), 13 deletions(-)

diff --git a/daemon/listfs.ml b/daemon/listfs.ml
index 370ffb4..dc424f5 100644
--- a/daemon/listfs.ml
+++ b/daemon/listfs.ml
@@ -24,24 +24,20 @@ let rec list_filesystems () =
   let has_lvm2 = Lvm.available () in
   let has_ldm = Ldm.available () in
 
-  let devices = Devsparts.list_devices () in
   let partitions = Devsparts.list_partitions () in
-  let mds = Md.list_md_devices () in
 
   (* Look to see if any devices directly contain filesystems
-   * (RHBZ#590167).  However vfs-type will fail to tell us anything
+   * (RHBZ#590167). However vfs-type will fail to tell us anything
    * useful about devices which just contain partitions, so we also
-   * get the list of partitions and exclude the corresponding devices
-   * by using part-to-dev.
+   * get the list of partitions and exclude the corresponding devices.
    *)
-  let devices_containing_partitions = List.fold_left (
-    fun set part ->
-      StringSet.add (Devsparts.part_to_dev part) set
-  ) StringSet.empty partitions in
-  let devices = List.filter (
-    fun dev ->
-      not (StringSet.mem dev devices_containing_partitions)
-  ) devices in
+  let device_without_partitions device =
+    not (Devsparts.is_partitioned_device device) in
+
+  let devices = Devsparts.list_devices () in
+  let devices = List.filter device_without_partitions devices in
+  let mds = Md.list_md_devices () in
+  let mds = List.filter device_without_partitions mds in
 
   (* Use vfs-type to check for filesystems on devices. *)
   let ret = List.filter_map check_with_vfs_type devices in
-- 
2.9.5




More information about the Libguestfs mailing list