Added bitmap structure. Run ownership tests for sample block device.
[virt-df.git] / diskzip / diskzip_bitmap.mli
diff --git a/diskzip/diskzip_bitmap.mli b/diskzip/diskzip_bitmap.mli
new file mode 100644 (file)
index 0000000..85821fd
--- /dev/null
@@ -0,0 +1,54 @@
+(* 'diskzip' command for intelligently compressing disk images.
+   (C) Copyright 2007 Richard W.M. Jones, Red Hat Inc.
+   http://libvirt.org/
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*)
+
+(**
+   Unlimited-length fixed-size bitmap type.
+
+   The only reason we need this is because strings are limited to 16
+   MBytes on 32 bit platforms (which would limit the size of a disk
+   image we could process to around 64 GB, assuming 512 byte sectors).
+   This module hides multiple strings on 32 bit, or a single long
+   string on 64 bit but is very efficient in either case.
+
+   Also it uses the 'int63' type which makes arithmetic convenient.
+*)
+
+type t
+
+val create : Int63.t -> t
+  (** Create a bitmap of the given length in bits. *)
+
+val set : t -> Int63.t -> unit
+
+val clear : t -> Int63.t -> unit
+
+val set_bool : t -> Int63.t -> bool -> unit
+
+val set_int : t -> Int63.t -> int -> unit
+  (** Treats the integer as a C-like boolean. *)
+
+val get : t -> Int63.t -> bool
+
+val iter : (Int63.t -> bool -> unit) -> t -> unit
+  (** [iter f bitmap] iterates over the bitmap, calling [f] for each bit. *)
+
+val iter_set : (Int63.t -> bool -> bool) -> t -> unit
+  (** [iter_set f bitmap] iterates over the bitmap, calling [f] for each
+      bit.  The return value of [f] is used to set or clear the bit
+      in the bitmap. *)