The callbacks trim, zero, extents and cache pass an int64 offset to
the OCaml code. However we were using caml_copy_int32 to create this
value which is obviously incorrect. (This would work on little endian
machines for offsets < 4G, unfortunately, which is why we didn't spot
this. Also it is not covered by any tests.)
This mistake goes right back to the original commit which added the
plugin, commit e3abac4e55 ("ocaml: New plugin lets you write plugins
as natively compiled OCaml programs.")
Fixes: commit e3abac4e5519b0d51c9a34a41af97f63920f3f32
---
plugins/ocaml/plugin.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/plugins/ocaml/plugin.c b/plugins/ocaml/plugin.c
index 53b23eb7..b6964046 100644
--- a/plugins/ocaml/plugin.c
+++ b/plugins/ocaml/plugin.c
@@ -657,7 +657,7 @@ trim_wrapper (void *h, uint32_t count, uint64_t offset, uint32_t
flags)
LEAVE_BLOCKING_SECTION_FOR_CURRENT_SCOPE ();
countv = caml_copy_int32 (count);
- offsetv = caml_copy_int32 (offset);
+ offsetv = caml_copy_int64 (offset);
flagsv = Val_flags (flags);
value args[] = { *(value *) h, countv, offsetv, flagsv };
@@ -678,7 +678,7 @@ zero_wrapper (void *h, uint32_t count, uint64_t offset, uint32_t
flags)
LEAVE_BLOCKING_SECTION_FOR_CURRENT_SCOPE ();
countv = caml_copy_int32 (count);
- offsetv = caml_copy_int32 (offset);
+ offsetv = caml_copy_int64 (offset);
flagsv = Val_flags (flags);
value args[] = { *(value *) h, countv, offsetv, flagsv };
@@ -700,7 +700,7 @@ extents_wrapper (void *h, uint32_t count, uint64_t offset, uint32_t
flags,
LEAVE_BLOCKING_SECTION_FOR_CURRENT_SCOPE ();
countv = caml_copy_int32 (count);
- offsetv = caml_copy_int32 (offset);
+ offsetv = caml_copy_int64 (offset);
flagsv = Val_flags (flags);
value args[] = { *(value *) h, countv, offsetv, flagsv };
@@ -740,7 +740,7 @@ cache_wrapper (void *h, uint32_t count, uint64_t offset, uint32_t
flags)
LEAVE_BLOCKING_SECTION_FOR_CURRENT_SCOPE ();
countv = caml_copy_int32 (count);
- offsetv = caml_copy_int32 (offset);
+ offsetv = caml_copy_int64 (offset);
flagsv = Val_flags (flags);
value args[] = { *(value *) h, countv, offsetv, flagsv };
--
2.32.0