(* Create ownership tables. *)
let ownership = Diskimage.create_ownership machine in
+ (* Create ownership bitmap for each disk. *)
(* Redirect output through external pipe if asked. *)
(* Return the ownership structure. *)
ownership
-let get_owners machine ownership disk offset =
+let get_owners_lookup machine ownership disk =
(* Get the correct tree. *)
let tree = List.assoc disk ownership in
- let rec query = function
- | Leaf (_, segments) -> segments
- | Node ((Leaf ((_, leftend), _) | Node (_, ((_, leftend), _), _) as left),
- (_, segments),
- right) ->
- let subsegments =
- if offset < leftend then query left else query right in
- segments @ subsegments
- in
- let owners = query tree in
+ fun offset ->
+ let rec query = function
+ | Leaf (_, segments) -> segments
+ | Node ((Leaf ((_, leftend), _) | Node (_, ((_, leftend), _), _) as left),
+ (_, segments),
+ right) ->
+ let subsegments =
+ if offset < leftend then query left else query right in
+ segments @ subsegments
+ in
+ let owners = query tree in
- List.map (
- fun (_, _, owner, owner_offset) -> (owner, offset -^ owner_offset)
- ) owners
+ List.map (
+ fun (_, _, owner, owner_offset) -> (owner, offset -^ owner_offset)
+ ) owners
| `Partitions of partitions
| `PhysicalVolume of pv ]
-val get_owners :
- machine -> ownership -> device -> Int63.t -> (owner * Int63.t) list
- (** [get_owners machine ownership disk offset] returns the
- owners (filesystems, etc.) which reside on block device [disk]
- at the given byte offset. [disk] must be a block device
- of the machine.
+val get_owners_lookup : machine -> ownership -> 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
both the filesystem ([`Filesystem fs]) and
partition scheme ([`Partitions parts]) will be returned.
- This function is efficient. {!create_ownership} creates
- a tree structure which allows ownership to be determined
+ The specialized function is efficient. {!create_ownership}
+ creates a tree structure which allows ownership to be determined
in just a few steps. *)
(** {2 Debugging} *)