3 # The above line is parsed by OCaml as an opening comment and by the
4 # shell as an impossible command which is ignored. The line below is
5 # run by the shell and ignored by OCaml.
7 exec nbdkit cc "$0" CC=ocamlopt CFLAGS="-output-obj -runtime-variant _pic unix.cmxa NBDKit.cmx -cclib -lnbdkitocaml" "$@"
12 let disk = ref (Bytes.make
(1024*1024) '
\000'
)
17 let size = NBDKit.parse_size v
in
18 let size = Int64.to_int
size in
19 disk := Bytes.make
size '
\000'
21 failwith
(sprintf
"unknown parameter: %s" k
)
23 let open_connection _
= ()
25 let get_size () = Bytes.length
!disk |> Int64.of_int
27 let pread () count offset _
=
28 let buf = Bytes.create count
in
29 Bytes.blit
!disk (Int64.to_int offset
) buf 0 count
;
30 Bytes.unsafe_to_string
buf
32 let pwrite () buf offset _
=
33 let len = String.length
buf in
34 let offset = Int64.to_int
offset in
35 String.blit
buf 0 !disk offset len
38 NBDKit.register_plugin
39 ~name
: "cc-shebang.ml"
40 ~version
: (NBDKit.version
())