Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions ocaml/qcow-stream-tool/qcow_stream_tool.ml
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,18 @@ module Impl = struct
let* virtual_size, cluster_bits, _, data_cluster_map =
Qcow_stream.start_stream_decode fd
in
let clusters = Qcow_types.Cluster.Map.bindings data_cluster_map in
(* TODO: List.map becomes tail-recursive in OCaml 5.1, and could be used here instead *)
let clusters =
List.map
(fun (_, virt_address) ->
data_cluster_map
|> Qcow_types.Cluster.Map.to_seq
|> Seq.map (fun (_, virt_address) ->
let ( >> ) = Int64.shift_right_logical in
let address =
Int64.to_int (virt_address >> Int32.to_int cluster_bits)
in
`Int address
)
clusters
)
|> List.of_seq
in
let json =
`Assoc
Expand Down
Loading