1.\" 2.\" Copyright (c) 2017 Kyle Kneitinger 3.\" All rights reserved. 4.\" 5.\" Redistribution and use in source and binary forms, with or without 6.\" modification, are permitted provided that the following conditions 7.\" are met: 8.\" 1. Redistributions of source code must retain the above copyright 9.\" notice, this list of conditions and the following disclaimer. 10.\" 2. Redistributions in binary form must reproduce the above copyright 11.\" notice, this list of conditions and the following disclaimer in the 12.\" documentation and/or other materials provided with the distribution. 13.\" 14.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24.\" SUCH DAMAGE. 25.\" 26.\" This manual page is based on the mp(3X) manual page from Sun Release 27.\" 4.1, dated 7 September 1989. It's an old, crufty, and relatively ugly 28.\" manual page, but it does document what appears to be the "traditional" 29.\" libmp interface. 30.\" 31.\" $FreeBSD$ 32.\" 33.Dd August 28, 2017 34.Dt LIBBE 3 35.Os 36.Sh NAME 37.Nm libbe 38.Nd library for creating, destroying and modifying ZFS boot environments. 39.Sh SYNOPSIS 40.In be.h 41.Pp 42Function prototypes are given in the main body of the text. 43.Pp 44Applications using this interface must be linked with 45.Fl l Ns Ar be 46.Sh DESCRIPTION 47.Pp 48.Nm 49interfaces with libzfs to provide a set of functions for various operations 50regarding ZFS boot environments including "deep" boot environments in which 51a boot environments has child datasets. 52.Pp 53A context structure is passed to each function, allowing for a small amount 54of state to be retained, such as errors from previous operations. 55.\" TODO: describe break on err functionality 56.Pp 57.Ft "libbe_handle_t *" Ns 58.Fn libbe_init "void" ; 59.Pp 60.Ft void 61.Fn libbe_close "libbe_handle_t *" ; 62.Pp 63.Ft "const char *" Ns 64.Fn be_active_name "libbe_handle_t *" ; 65.Pp 66.Ft "const char *" Ns 67.Fn be_active_path "libbe_handle_t *" ; 68.Pp 69.Ft "const char *" Ns 70.Fn be_root_path "libbe_handle_t *" ; 71.Pp 72.Ft "nvlist_t *" Ns 73.Fn libbe_handle_t "libbe_handle_t " ; 74.Pp 75.Ft int 76.Fn be_create "libbe_handle_t *, char *" ; 77.Pp 78.Ft int 79.Fn be_create_from_existing "libbe_handle_t *, char *, char *" ; 80.Pp 81.Ft int 82.Fn be_rename "libbe_handle_t *, char *, char *" ; 83.Pp 84.\" TODO: Write up of destroy options 85.\" typedef enum { 86.\" BE_DESTROY_FORCE = 1 << 0, 87.\" } be_destroy_opt_t; 88.Ft int 89.Fn be_destroy "libbe_handle_t *, char *, int" ; 90.Pp 91.\" TODO: Write up of mount options 92.\" typedef enum { 93.\" BE_MNT_FORCE = 1 << 0, 94.\" BE_MNT_DEEP = 1 << 1, 95.\" } be_mount_opt_t; 96.Ft int 97.Fn be_mount "libbe_handle_t *, char *, char *, int" ; 98.Pp 99.Ft int 100.Fn be_unmount "libbe_handle_t *, char *, int" ; 101.Pp 102.Ft int 103.Fn libbe_errno "libbe_handle_t *" ; 104.Pp 105.Ft "const char *" Ns 106.Fn libbe_error_description "libbe_handle_t *" ; 107.Pp 108.Ft void 109.Fn libbe_print_on_error "libbe_handle_t *, bool" ; 110.Pp 111.Ft int 112.Fn be_root_concat "libbe_handle_t *, char *, char *" ; 113.Pp 114.Ft int 115.Fn be_validate_name "libbe_handle_t *, char *" ; 116.Pp 117.Ft int 118.Fn be_validate_snap "libbe_handle_t *, char *" ; 119.Pp 120.Ft bool 121.Fn be_exists "libbe_handle_t *, char *" ; 122.Pp 123.Ft int 124.Fn be_export "libbe_handle_t *, char *, int fd" ; 125.Pp 126.Ft int 127.Fn be_import "libbe_handle_t *, char *, int fd" ; 128.Pp 129.Ft int 130.Fn be_add_child "libbe_handle_t *, char *, bool" ; 131.Pp 132.\" .Ft void 133.\" .Fn mp_mfree "MINT *mp" ; 134.\" .Bd -ragged -offset indent 135.\" .Fn mp_itom 136.\" returns an 137.\" .Vt MINT 138.\" with the value of 139.\" .Fa n . 140.\" .Fn mp_xtom 141.\" returns an 142.\" .Vt MINT 143.\" with the value of 144.\" .Fa s , 145.\" which is treated to be in hexadecimal. 146.\" The return values from 147.\" .Fn mp_itom 148.\" and 149.\" .Fn mp_xtom 150.\" must be released with 151.\" .Fn mp_mfree 152.\" when they are no longer needed. 153.\" .Fn mp_mtox 154.\" returns a null-terminated hexadecimal string having the value of 155.\" .Fa mp ; 156.\" its return value must be released with 157.\" .Fn free 158.\" .Pq Xr free 3 159.\" when it is no longer needed. 160.\" .Ed 161.\" .Pp 162.Sh DIAGNOSTICS 163Upon error, one of the following values will be returned. 164.\" TODO: make each entry on its own line. 165.Bd -ragged -offset indent 166BE_ERR_SUCCESS, 167BE_ERR_INVALIDNAME, 168BE_ERR_EXISTS, 169BE_ERR_NOENT, 170BE_ERR_PERMS, 171BE_ERR_DESTROYACT, 172BE_ERR_DESTROYMNT, 173BE_ERR_PATHLEN, 174BE_ERR_INVORIGIN, 175BE_ERR_NOORIGIN, 176BE_ERR_MOUNTED, 177BE_ERR_NOMOUNT, 178BE_ERR_ZFSOPEN, 179BE_ERR_ZFSCLONE, 180BE_ERR_UNKNOWN 181.Ed 182.Sh SEE ALSO 183.Xr be 1 , 184.Sh HISTORY 185.Nm 186and it's corresponding command, 187.Xr be 3 , 188were written as a 2017 Google Summer of Code project with Allan Jude serving 189as a mentor. 190.\" TODO: update when implementation complete. 191.\" .Sh BUGS 192 193