Chen Hanxiao
2015-May-14 05:19 UTC
[Libguestfs] [PATCH] resize: show sector infor in debug_partition
Show partition sector data and target partition sector data
in debug_partition.
Also, if --verbose, call debug_partition again before
parted partitions.
Signed-off-by: Chen Hanxiao <chenhanxiao@cn.fujitsu.com>
---
resize/resize.ml | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/resize/resize.ml b/resize/resize.ml
index 8e69d44..ae8339d 100644
--- a/resize/resize.ml
+++ b/resize/resize.ml
@@ -80,11 +80,15 @@ and partition_type | LogicalPartition
| NoTypePartition
-let rec debug_partition p +let rec debug_partition ?(sectsize=512L) p printf
"%s:\n" p.p_name;
printf "\tpartition data: %ld %Ld-%Ld (%Ld bytes)\n"
p.p_part.G.part_num p.p_part.G.part_start p.p_part.G.part_end
p.p_part.G.part_size;
+ printf "\tpartition sector data: %Ld-%Ld\n"
+ (p.p_part.G.part_start /^ sectsize) (p.p_part.G.part_end /^ sectsize);
+ printf "\ttarget partition sector data: %Ld-%Ld \n"
+ p.p_target_start p.p_target_end;
printf "\tbootable: %b\n" p.p_bootable;
printf "\tpartition ID: %s\n"
(match p.p_id with
@@ -545,7 +549,7 @@ read the man page virt-resize(1).
if verbose then (
printf "%d partitions found\n" (List.length partitions);
- List.iter debug_partition partitions
+ List.iter (debug_partition ~sectsize:sectsize) partitions
);
(* Build a data structure describing LVs on the source disk. *)
@@ -1119,6 +1123,11 @@ read the man page virt-resize(1).
calculate_target_partitions 1 start ~create_surplus:true partitions in
+ if verbose then (
+ printf "After calculate target partitions:\n";
+ List.iter (debug_partition ~sectsize:sectsize) partitions
+ );
+
let mbr_part_type x match parttype, x.p_part.G.part_num <= 4_l,
x.p_type with
(* for GPT, all partitions are regarded as Primary Partition. *)
--
2.1.0
Richard W.M. Jones
2015-May-14 11:23 UTC
Re: [Libguestfs] [PATCH] resize: show sector infor in debug_partition
On Thu, May 14, 2015 at 01:19:36AM -0400, Chen Hanxiao wrote:> - List.iter debug_partition partitions > + List.iter (debug_partition ~sectsize:sectsize) partitions`~a:a' can be abbreviated as just `~a'. I made this change and pushed it: https://github.com/libguestfs/libguestfs/commit/7eb1ed8cb4c686f24809dd7904227b5e33d02f9d Thanks, Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com Fedora Windows cross-compiler. Compile Windows programs, test, and build Windows installers. Over 100 libraries supported. http://fedoraproject.org/wiki/MinGW
Maybe Matching Threads
- [PATCH] resize: add sector size in debug_partition
- [PATCH v2] resize: add sector size in debug_partition
- Re: [PATCH] resize: add sector size in debug_partition
- [PATCH RFC] resize: add p_mbr_p_type as member of type partition
- [PATCH] resize: properly restore GPT partition types