[Pkg-libvirt-commits] [libguestfs] 07/66: add function div_roundup64
Hilko Bengen
bengen at moszumanska.debian.org
Fri Oct 3 14:47:35 UTC 2014
This is an automated email from the git hooks/post-receive script.
bengen pushed a commit to annotated tag debian/1%1.27.54-1
in repository libguestfs.
commit d9f8746ea5a5f22ac71ac494c9d93e59354b4d10
Author: Hu Tao <hutao at cn.fujitsu.com>
Date: Fri Sep 19 15:39:04 2014 +0800
add function div_roundup64
Signed-off-by: Hu Tao <hutao at cn.fujitsu.com>
---
mllib/common_utils.ml | 1 +
mllib/common_utils.mli | 1 +
resize/resize.ml | 4 ++--
3 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/mllib/common_utils.ml b/mllib/common_utils.ml
index 5aa41c2..62d0782 100644
--- a/mllib/common_utils.ml
+++ b/mllib/common_utils.ml
@@ -33,6 +33,7 @@ let ( ~^ ) = Int64.lognot
(* Return 'i' rounded up to the next multiple of 'a'. *)
let roundup64 i a = let a = a -^ 1L in (i +^ a) &^ (~^ a)
+let div_roundup64 i a = (i +^ a -^ 1L) /^ a
let int_of_le32 str =
assert (String.length str = 4);
diff --git a/mllib/common_utils.mli b/mllib/common_utils.mli
index e77fcd2..5bf4fba 100644
--- a/mllib/common_utils.mli
+++ b/mllib/common_utils.mli
@@ -28,6 +28,7 @@ val ( ~^ ) : int64 -> int64
(** Various int64 operators. *)
val roundup64 : int64 -> int64 -> int64
+val div_roundup64 : int64 -> int64 -> int64
val int_of_le32 : string -> int64
val le32_of_int : int64 -> string
diff --git a/resize/resize.ml b/resize/resize.ml
index e1634de..794a574 100644
--- a/resize/resize.ml
+++ b/resize/resize.ml
@@ -1026,7 +1026,7 @@ read the man page virt-resize(1).
| OpIgnore | OpCopy -> (* same size *)
(* Size in sectors. *)
- let size = (p.p_part.G.part_size +^ sectsize -^ 1L) /^ sectsize in
+ let size = div_roundup64 p.p_part.G.part_size sectsize in
(* Start of next partition + alignment. *)
let end_ = start +^ size in
let next = roundup64 end_ alignment in
@@ -1040,7 +1040,7 @@ read the man page virt-resize(1).
| OpResize newsize -> (* resized partition *)
(* New size in sectors. *)
- let size = (newsize +^ sectsize -^ 1L) /^ sectsize in
+ let size = div_roundup64 newsize sectsize in
(* Start of next partition + alignment. *)
let next = start +^ size in
let next = roundup64 next alignment in
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-libvirt/libguestfs.git
More information about the Pkg-libvirt-commits
mailing list