2 disk
: bytes
; (* The disk image. *)
6 NBDKit.debug
"test ocaml plugin loaded"
9 NBDKit.debug
"test ocaml plugin unloaded"
14 params := (k
, v
) :: !params
16 let test_config_complete () =
17 let params = List.rev
!params in
18 assert (params = [ "a", "1"; "b", "2"; "c", "3" ])
20 let test_open readonly
=
21 NBDKit.debug
"test ocaml plugin handle opened readonly=%b" readonly
;
22 let disk = Bytes.make
(1024*1024) '
\000'
in
29 Int64.of_int
(Bytes.length h
.disk)
31 let test_pread h buf offset _
=
32 let len = Bytes.length buf
in
33 Bytes.blit h
.disk (Int64.to_int offset
) buf
0 len
35 let test_pwrite h buf offset _
=
36 let len = String.length buf
in
37 String.blit buf
0 h
.disk (Int64.to_int offset
) len
40 NBDKit.default_callbacks
with
41 NBDKit.name
= "testocaml";
44 load
= Some
test_load;
45 unload
= Some
test_unload;
46 config
= Some
test_config;
47 config_complete
= Some
test_config_complete;
49 open_connection
= Some
test_open;
50 close
= Some
test_close;
51 get_size
= Some
test_get_size;
52 pread
= Some
test_pread;
53 pwrite
= Some
test_pwrite;
56 let thread_model = NBDKit.THREAD_MODEL_SERIALIZE_CONNECTIONS
58 let () = NBDKit.register_plugin
thread_model plugin