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

[Libguestfs] [PATCH v2 01/11] resize: move loop check from find_partitions



As logical partitions laid inside extended partition,
overlap check will not work.
make loop as a individual function,
which could do a seperate check on logical/extended partitions.

Signed-off-by: Chen Hanxiao <chenhanxiao cn fujitsu com>
---
 resize/resize.ml | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/resize/resize.ml b/resize/resize.ml
index 602a583..4c97405 100644
--- a/resize/resize.ml
+++ b/resize/resize.ml
@@ -521,20 +521,20 @@ read the man page virt-resize(1).
       | _ -> ()
     ) partitions;
 
-    (* Check partitions don't overlap. *)
-    let rec loop end_of_prev = function
-      | [] -> ()
-      | { p_name = name; p_part = { G.part_start = part_start } } :: _
-          when end_of_prev > part_start ->
-        error (f_"%s: this partition overlaps the previous one") name
-      | { p_part = { G.part_end = part_end } } :: parts -> loop part_end parts
-    in
-    loop 0L partitions;
-
     partitions in
 
   let partitions = find_partitions () in
 
+  (* Check partitions don't overlap. *)
+  let rec loop end_of_prev = function
+    | [] -> ()
+    | { p_name = name; p_part = { G.part_start = part_start } } :: _
+        when end_of_prev > part_start ->
+      error (f_"%s: this partition overlaps the previous one") name
+    | { p_part = { G.part_end = part_end } } :: parts -> loop part_end parts
+  in
+  loop 0L partitions;
+
   if verbose () then (
     printf "%d partitions found\n" (List.length partitions);
     List.iter (debug_partition ~sectsize) partitions
-- 
2.1.0


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