Scroll to navigation

libnbd-ocaml(3) LIBNBD libnbd-ocaml(3)

NAME

libnbd-ocaml - how to use libnbd from OCaml

SYNOPSIS

 let nbd = NBD.create () in
 NBD.connect_uri nbd "nbd://localhost";
 let size = NBD.get_size nbd in
 printf "%Ld\n" size

DESCRIPTION

This manual page documents how to use libnbd to access Network Block Device (NBD) servers from the OCaml programming language.

The OCaml bindings work very similarly to the C bindings so you should start by reading libnbd(3).

For OCaml API documentation see NBD(3).

HANDLES

Create a libnbd handle of type "NBD.t" by calling "NBD.create ()".

You can either close the handle explicitly by calling "NBD.close" or it will be closed automatically when it is garbage collected. If you call any other method on a handle which you have explicitly closed then the API will throw an "NBD.Closed" exception.

ERRORS

Libnbd errors are turned automatically into "NBD.Error (str, errno)" exceptions. This exception has two parameters. The first is a string which is the printable error message. The second is the raw "errno", if available (see nbd_get_errno(3)). The raw "errno" is not compatible with errors in the OCaml "Unix" module unfortunately.

EXAMPLES

This directory contains examples written in OCaml:

https://github.com/libguestfs/libnbd/tree/master/ocaml/examples

SEE ALSO

libnbd(3), NBD(3).

AUTHORS

Richard W.M. Jones

COPYRIGHT

Copyright (C) 2019-2020 Red Hat Inc.

LICENSE

This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA

2021-02-09 libnbd-1.6.1