1libnbd-ocaml(3) LIBNBD libnbd-ocaml(3)
2
3
4
6 libnbd-ocaml - how to use libnbd from OCaml
7
9 let nbd = NBD.create () in
10 NBD.connect_uri nbd "nbd://localhost";
11 let size = NBD.get_size nbd in
12 printf "%Ld\n" size
13
15 This manual page documents how to use libnbd to access Network Block
16 Device (NBD) servers from the OCaml programming language.
17
18 The OCaml bindings work very similarly to the C bindings so you should
19 start by reading libnbd(3).
20
21 For OCaml API documentation see NBD(3).
22
24 Create a libnbd handle of type "NBD.t" by calling "NBD.create ()".
25
26 You can either close the handle explicitly by calling "NBD.close" or it
27 will be closed automatically when it is garbage collected. If you call
28 any other method on a handle which you have explicitly closed then the
29 API will throw an "NBD.Closed" exception.
30
32 Libnbd errors are turned automatically into "NBD.Error (str, errno)"
33 exceptions. This exception has two parameters. The first is a string
34 which is the printable error message. The second is the raw "errno",
35 if available (see nbd_get_errno(3)). The raw "errno" is not compatible
36 with errors in the OCaml "Unix" module unfortunately.
37
39 This directory contains examples written in OCaml:
40
41 https://github.com/libguestfs/libnbd/tree/master/ocaml/examples
42
44 libnbd(3), NBD(3).
45
47 Richard W.M. Jones
48
50 Copyright (C) 2019-2020 Red Hat Inc.
51
53 This library is free software; you can redistribute it and/or modify it
54 under the terms of the GNU Lesser General Public License as published
55 by the Free Software Foundation; either version 2 of the License, or
56 (at your option) any later version.
57
58 This library is distributed in the hope that it will be useful, but
59 WITHOUT ANY WARRANTY; without even the implied warranty of
60 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
61 Lesser General Public License for more details.
62
63 You should have received a copy of the GNU Lesser General Public
64 License along with this library; if not, write to the Free Software
65 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
66 02110-1301 USA
67
68
69
70libnbd-1.6.2 2021-03-02 libnbd-ocaml(3)