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. The OCaml
17 bindings work very similarly to the C bindings so you should start by
18 reading libnbd(3)..
19
21 Create a libnbd handle of type "NBD.t" by calling "NBD.create ()".
22
23 You can either close the handle explicitly by calling "NBD.close" or it
24 will be closed automatically when it is garbage collected. If you call
25 any other method on a handle which you have explicitly closed then the
26 API will throw an "NBD.Closed" exception.
27
29 Libnbd errors are turned automatically into "NBD.Error (str, errno)"
30 exceptions. This exception has two parameters. The first is a string
31 which is the printable error message. The second is the raw "errno",
32 if available (see nbd_get_errno(3)). The raw "errno" is not compatible
33 with errors in the OCaml "Unix" module unfortunately.
34
36 This directory contains examples written in OCaml:
37
38 https://github.com/libguestfs/libnbd/tree/master/ocaml/examples
39
41 libnbd(3).
42
44 Richard W.M. Jones
45
47 Copyright (C) 2019 Red Hat Inc.
48
50 This library is free software; you can redistribute it and/or modify it
51 under the terms of the GNU Lesser General Public License as published
52 by the Free Software Foundation; either version 2 of the License, or
53 (at your option) any later version.
54
55 This library is distributed in the hope that it will be useful, but
56 WITHOUT ANY WARRANTY; without even the implied warranty of
57 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
58 Lesser General Public License for more details.
59
60 You should have received a copy of the GNU Lesser General Public
61 License along with this library; if not, write to the Free Software
62 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
63 02110-1301 USA
64
65
66
67libnbd-1.2.1 2019-11-14 libnbd-ocaml(3)