1NBDKit(3)                                                            NBDKit(3)
2
3
4

NAME

6       NBDKit  -  Interface  between  plugins  written in OCaml and the nbdkit
7       server.
8

Module

10       Module   NBDKit
11

Documentation

13       Module NBDKit
14        : sig end
15
16
17       Interface between plugins written in OCaml and the nbdkit server.
18
19       Read nbdkit-ocaml-plugin(3) first.
20
21
22
23
24
25       type flags = flag list
26
27
28       Flags passed from the server to various callbacks.
29
30
31       type flag =
32        | May_trim
33        | FUA
34        | Req_one
35
36
37
38
39       type fua_flag =
40        | FuaNone
41        | FuaEmulate
42        | FuaNative
43
44
45
46
47       type cache_flag =
48        | CacheNone
49        | CacheEmulate
50        | CacheNop
51
52
53
54
55       type extent = {
56        offset : int64 ;
57        length : int64 ;
58        is_hole : bool ;
59        is_zero : bool ;
60        }
61
62
63       The type of the extent list returned by extents
64
65
66
67       type export = {
68        name : string ;
69        description : string option ;
70        }
71
72
73       The type of the export list returned by list_exports
74
75
76
77       type thread_model =
78        | THREAD_MODEL_SERIALIZE_CONNECTIONS
79        | THREAD_MODEL_SERIALIZE_ALL_REQUESTS
80        | THREAD_MODEL_SERIALIZE_REQUESTS
81        | THREAD_MODEL_PARALLEL
82
83
84       The type of the thread model returned by thread_model
85
86
87
88
89       val  register_plugin  :  name:string  ->  ?longname:string   ->   ?ver‐
90       sion:string   ->   ?description:string   ->  ?load:(unit  ->  unit)  ->
91       ?get_ready:(unit  ->   unit)   ->   ?after_fork:(unit   ->   unit)   ->
92       ?cleanup:(unit -> unit) -> ?unload:(unit -> unit) -> ?config:(string ->
93       string  ->  unit)  ->  ?config_complete:(unit   ->   unit)   ->   ?con‐
94       fig_help:string  -> ?thread_model:(unit -> thread_model) -> ?magic_con‐
95       fig_key:string -> ?preconnect:(bool -> unit)  ->  open_connection:(bool
96       ->   'a)   ->   ?close:('a  ->  unit)  ->  get_size:('a  ->  int64)  ->
97       ?block_size:('a -> int * int * int64) -> ?can_cache:('a ->  cache_flag)
98       ->   ?can_extents:('a  ->  bool)  ->  ?can_fast_zero:('a  ->  bool)  ->
99       ?can_flush:('a   ->   bool)   ->   ?can_fua:('a   ->    fua_flag)    ->
100       ?can_multi_conn:('a   ->   bool)   ->   ?can_trim:('a   ->   bool)   ->
101       ?can_write:('a -> bool) -> ?can_zero:('a -> bool) -> ?is_rotational:('a
102       ->  bool)  ->  pread:('a  ->  int  ->  int64  ->  flags  ->  string) ->
103       ?pwrite:('a -> string -> int64 -> flags -> unit) -> ?flush:('a -> flags
104       ->  unit) -> ?trim:('a -> int64 -> int64 -> flags -> unit) -> ?zero:('a
105       -> int64 -> int64 -> flags -> unit) -> ?extents:('a -> int64  ->  int64
106       ->  flags  ->  extent list) -> ?cache:('a -> int64 -> int64 -> flags ->
107       unit) -> ?dump_plugin:(unit -> unit) -> ?list_exports:(bool -> bool  ->
108       export list) -> ?default_export:(bool -> bool -> string) -> ?export_de‐
109       scription:('a -> string) -> unit -> unit
110
111       Register the plugin with nbdkit.
112
113       The 'a parameter is the handle type returned  by  your  open_connection
114       method and passed back to all connected calls.
115
116
117
118       val set_error : Unix.error -> unit
119
120       Set the errno returned over the NBD protocol to the client.
121
122       Notice  however  that the NBD protocol only supports a small handful of
123       errno values.  Any other errno will be translated into EINVAL .
124
125
126
127       val parse_size : string -> int64
128
129       Bindings   for   nbdkit_parse_size   ,   nbdkit_parse_bool   and   nbd‐
130       kit_read_password  .   See nbdkit-plugin(3) for information about these
131       functions.
132
133       On error these functions all raise Invalid_argument .  The actual error
134       is  sent  to  the  nbdkit error log and is not available from the OCaml
135       code.  It is usually best to let the exception escape.
136
137
138
139       val parse_bool : string -> bool
140
141
142
143
144       val read_password : string -> string
145
146
147
148
149       val realpath : string -> string
150
151       Binding for nbdkit_realpath .  Returns the canonical path from  a  path
152       parameter.
153
154
155
156       val nanosleep : int -> int -> unit
157
158       Binding for nbdkit_nanosleep .  Sleeps for seconds and nanoseconds.
159
160
161
162       val export_name : unit -> string
163
164       Binding for nbdkit_export_name .  Returns the name of the export as re‐
165       quested by the client.
166
167
168
169       val shutdown : unit -> unit
170
171       Binding for nbdkit_shutdown .  Requests the server shut down.
172
173
174
175       val debug : ('a, unit, string, unit) Stdlib.format4 -> 'a
176
177       Print a debug message when nbdkit is in verbose mode.
178
179
180
181       val version : unit -> string
182
183       Return the version of nbdkit that the plugin was compiled with.
184
185
186
187       val peer_pid : unit -> int64
188
189       Binding for nbdkit_peer_pid .
190
191
192
193       val peer_uid : unit -> int64
194
195       Binding for nbdkit_peer_uid .
196
197
198
199       val peer_gid : unit -> int64
200
201       Binding for nbdkit_peer_gid .
202
203
204
205
206
207OCamldoc                          2022-07-10                         NBDKit(3)
Impressum