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