[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[Libguestfs] [PATCH v4 4/7] resize: add partition type LogicalPartition



Signed-off-by: Hu Tao <hutao cn fujitsu com>
---
 resize/resize.ml | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/resize/resize.ml b/resize/resize.ml
index f1861d9..7ac2dc2 100644
--- a/resize/resize.ml
+++ b/resize/resize.ml
@@ -75,6 +75,7 @@ and partition_id =
 
 type partition_type =
   | PrimaryPartition
+  | LogicalPartition
 
 let rec debug_partition p =
   eprintf "%s:\n" p.p_name;
@@ -449,13 +450,15 @@ read the man page virt-resize(1).
   let find_partitions part_type =
     let parts = Array.to_list (g#part_list "/dev/sda") in
 
-    (* Filter out logical partitions.  See note above. *)
     let parts =
       match part_type with
       (* for GPT, all partitions are regarded as Primary Partition,
        * e.g. there is no Extended Partition or Logical Partition. *)
       | PrimaryPartition ->
         List.filter (fun p -> parttype <> MBR || p.G.part_num <= 4_l)
+        parts
+      | LogicalPartition ->
+        List.filter (fun p -> parttype = MBR && p.G.part_num >= 5_l)
         parts in
 
     let partitions =
@@ -518,10 +521,12 @@ read the man page virt-resize(1).
     partitions in
 
   let partitions = find_partitions PrimaryPartition in
+  let logical_partitions = find_partitions LogicalPartition in
 
   if verbose then (
-    eprintf "%d partitions found\n" (List.length partitions);
-    List.iter debug_partition partitions
+    eprintf "%d partitions found\n" (List.length partitions + List.length logical_partitions);
+    List.iter debug_partition partitions;
+    List.iter debug_partition logical_partitions
     );
 
   (* Build a data structure describing LVs on the source disk. *)
-- 
1.9.3


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]