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 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_bool   and   nbd‐
131       kit_read_password .  See nbdkit-plugin(3) for information  about  these
132       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_bool : string -> bool
141
142
143
144
145       val read_password : string -> string
146
147
148
149
150       val realpath : string -> string
151
152       Binding  for  nbdkit_realpath .  Returns the canonical path from a path
153       parameter.
154
155
156
157       val nanosleep : int -> int -> unit
158
159       Binding for nbdkit_nanosleep .  Sleeps for seconds and nanoseconds.
160
161
162
163       val export_name : unit -> string
164
165       Binding for nbdkit_export_name .  Returns the name of the export as re‐
166       quested by the client.
167
168
169
170       val shutdown : unit -> unit
171
172       Binding for nbdkit_shutdown .  Requests the server shut down.
173
174
175
176       val disconnect : bool -> unit
177
178       Binding for nbdkit_disconnect .  Requests disconnecting current client.
179
180
181
182       val debug : ('a, unit, string, unit) Stdlib.format4 -> 'a
183
184       Print a debug message when nbdkit is in verbose mode.
185
186
187
188       val version : unit -> string
189
190       Return the version of nbdkit that the plugin was compiled with.
191
192
193
194       val api_version : unit -> int
195
196       Return the nbdkit API version used by the plugin.
197
198       See NBDKIT_API_VERSION in nbdkit-plugin(3).
199
200
201
202       val peer_pid : unit -> int64
203
204       Binding for nbdkit_peer_pid .
205
206
207
208       val peer_uid : unit -> int64
209
210       Binding for nbdkit_peer_uid .
211
212
213
214       val peer_gid : unit -> int64
215
216       Binding for nbdkit_peer_gid .
217
218
219
220
221
222OCamldoc                          2023-09-26                         NBDKit(3)
Impressum