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 NBDKit.plugin.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 NBDKit.plugin.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 NBDKit.plugin.thread_model
85
86
87
88       type 'a plugin = {
89        name : string ;  (* required field
90        *)
91        longname : string ;
92        version : string ;
93        description : string ;
94        load : (unit -> unit) option ;
95        get_ready : (unit -> unit) option ;
96        after_fork : (unit -> unit) option ;
97        cleanup : (unit -> unit) option ;
98        unload : (unit -> unit) option ;
99        config : (string -> string -> unit) option ;
100        config_complete : (unit -> unit) option ;
101        config_help : string ;
102        thread_model : (unit -> thread_model) option ;
103        preconnect : (bool -> unit) option ;
104        open_connection : (bool -> 'a) option ;  (* required field
105        *)
106        close : ('a -> unit) option ;
107        get_size : ('a -> int64) option ;  (* required field
108        *)
109        can_cache : ('a -> cache_flag) option ;
110        can_extents : ('a -> bool) option ;
111        can_fast_zero : ('a -> bool) option ;
112        can_flush : ('a -> bool) option ;
113        can_fua : ('a -> fua_flag) option ;
114        can_multi_conn : ('a -> bool) option ;
115        can_trim : ('a -> bool) option ;
116        can_write : ('a -> bool) option ;
117        can_zero : ('a -> bool) option ;
118        is_rotational : ('a -> bool) option ;
119        pread : ('a -> int32 -> int64 -> flags -> string)  option  ;   (*  re‐
120       quired field
121        *)
122        pwrite : ('a -> string -> int64 -> flags -> unit) option ;
123        flush : ('a -> flags -> unit) option ;
124        trim : ('a -> int32 -> int64 -> flags -> unit) option ;
125        zero : ('a -> int32 -> int64 -> flags -> unit) option ;
126        extents : ('a -> int32 -> int64 -> flags -> extent list) option ;
127        cache : ('a -> int32 -> int64 -> flags -> unit) option ;
128        dump_plugin : (unit -> unit) option ;
129        list_exports : (bool -> bool -> export list) option ;
130        default_export : (bool -> bool -> string) option ;
131        export_description : ('a -> string) option ;
132        }
133
134
135       The plugin fields and callbacks.
136
137       The  'a  parameter  is the handle type returned by your open_connection
138       method and passed back to all connected calls.
139
140
141
142       val default_callbacks : 'a plugin
143
144       The plugin with all fields set to  None  ,  so  you  can  write  {  de‐
145       fault_callbacks with field1 = Some foo1; field2 = Some foo2 }
146
147
148
149
150       val register_plugin : 'a plugin -> unit
151
152       Register the plugin with nbdkit.
153
154
155
156       val set_error : Unix.error -> unit
157
158       Set the errno returned over the NBD protocol to the client.
159
160       Notice  however  that the NBD protocol only supports a small handful of
161       errno values.  Any other errno will be translated into EINVAL .
162
163
164
165       val parse_size : string -> int64
166
167       Bindings   for   nbdkit_parse_size   ,   nbdkit_parse_bool   and   nbd‐
168       kit_read_password  .   See nbdkit-plugin(3) for information about these
169       functions.
170
171       On error these functions all raise Invalid_argument .  The actual error
172       is  sent  to  the  nbdkit error log and is not available from the OCaml
173       code.  It is usually best to let the exception escape.
174
175
176
177       val parse_bool : string -> bool
178
179
180
181
182       val read_password : string -> string
183
184
185
186
187       val realpath : string -> string
188
189       Binding for nbdkit_realpath .  Returns the canonical path from  a  path
190       parameter.
191
192
193
194       val nanosleep : int -> int -> unit
195
196       Binding for nbdkit_nanosleep .  Sleeps for seconds and nanoseconds.
197
198
199
200       val export_name : unit -> string
201
202       Binding for nbdkit_export_name .  Returns the name of the export as re‐
203       quested by the client.
204
205
206
207       val shutdown : unit -> unit
208
209       Binding for nbdkit_shutdown .  Requests the server shut down.
210
211
212
213       val debug : ('a, unit, string, unit) Stdlib.format4 -> 'a
214
215       Print a debug message when nbdkit is in verbose mode.
216
217
218
219       val version : unit -> string
220
221       Return the version of nbdkit that the plugin was compiled with.
222
223
224
225       val peer_pid : unit -> int64
226
227       Binding for nbdkit_peer_pid .
228
229
230
231       val peer_uid : unit -> int64
232
233       Binding for nbdkit_peer_uid .
234
235
236
237       val peer_gid : unit -> int64
238
239       Binding for nbdkit_peer_gid .
240
241
242
243
244
245OCamldoc                          2021-11-09                         NBDKit(3)
Impressum