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