Added bitmap structure. Run ownership tests for sample block device.
[virt-df.git] / lib / diskimage.mli
index b926193..5d2a420 100644 (file)
@@ -203,6 +203,7 @@ and disk_content =
 
 and partitions = {
   parts_plugin_id : parts_plugin_id;   (** Partitioning scheme. *)
+  parts_dev : device;                  (** Partitions (whole) device. *)
   parts : partition list;              (** Partitions. *)
 }
 and partition = {
@@ -239,6 +240,7 @@ and filesystem = {
 and pv = {
   lvm_plugin_id : lvm_plugin_id;        (** The LVM plug-in which detected
                                            this. *)
+  pv_dev : device;                     (** Device covering whole PV. *)
   pv_uuid : string;                    (** UUID. *)
 }
 and lv = {
@@ -256,7 +258,9 @@ val name_of_filesystem : fs_plugin_id -> string
 val name_of_lvm : lvm_plugin_id -> string
   (** Convert plug-in IDs to printable strings. *)
 
-(** {2 Scanning functions} *)
+(** {2 Functions} *)
+
+(** {3 Create 'machine'} *)
 
 val open_machine : string -> (string * string) list -> machine
   (** [open_machine m_name devs]
@@ -278,6 +282,8 @@ val close_machine : machine -> unit
       opened by these devices.
   *)
 
+(** {3 Scanning for filesystems} *)
+
 val scan_machine : machine -> machine
   (** This does a complete scan of all devices owned by a machine,
       identifying all partitions, filesystems, physical and logical
@@ -288,6 +294,45 @@ val scan_machine : machine -> machine
       Returns an updated {!machine} structure with the scan results.
   *)
 
+(** {3 Create ownership tables} *)
+
+type ownership
+
+val create_ownership : machine -> ownership
+  (** This creates the ownership tables (mapping disk blocks to the
+      ultimate filesystem, etc., which owns each one).
+  *)
+
+type owner =
+    [ `Filesystem of filesystem
+    | `Partitions of partitions
+    | `PhysicalVolume of pv ]
+
+val get_owners_lookup : machine -> ownership -> block_device ->
+  (Int63.t -> (owner * Int63.t) list)
+  (** [get_owners_lookup machine disk] returns a specialized
+      function for looking up owners (filesystems, etc.)
+      which reside on block device [disk].
+
+      [disk] must be a block device of the machine.
+
+      The specialized lookup function that is returned
+      can be called as [lookup offset] to look up the
+      owners of byte offset [offset].
+
+      Returns a list of [(owner, owner_offset)] where [owner]
+      is the filesystem, etc., and [owner_offset] is the byte
+      offset relative to the owner.
+
+      It is common for there to be multiple owners: for example
+      in the case where a filesystem is created on a partition,
+      both the filesystem ([`Filesystem fs]) and
+      partition scheme ([`Partitions parts]) will be returned.
+
+      The specialized function is efficient.  {!create_ownership}
+      creates a tree structure which allows ownership to be determined
+      in just a few steps. *)
+
 (** {2 Debugging} *)
 
 val debug : bool ref