xref: /freebsd/lib/libbe/libbe.3 (revision 96c5db5854191eb7ff464c74ea677ee8016b3a9e)
128f16a0fSKyle Evans.\"
228f16a0fSKyle Evans.\" Copyright (c) 2017 Kyle Kneitinger
328f16a0fSKyle Evans.\" All rights reserved.
428f16a0fSKyle Evans.\"
528f16a0fSKyle Evans.\" Redistribution and use in source and binary forms, with or without
628f16a0fSKyle Evans.\" modification, are permitted provided that the following conditions
728f16a0fSKyle Evans.\" are met:
828f16a0fSKyle Evans.\" 1. Redistributions of source code must retain the above copyright
928f16a0fSKyle Evans.\"    notice, this list of conditions and the following disclaimer.
1028f16a0fSKyle Evans.\" 2. Redistributions in binary form must reproduce the above copyright
1128f16a0fSKyle Evans.\"    notice, this list of conditions and the following disclaimer in the
1228f16a0fSKyle Evans.\"    documentation and/or other materials provided with the distribution.
1328f16a0fSKyle Evans.\"
1428f16a0fSKyle Evans.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
1528f16a0fSKyle Evans.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1628f16a0fSKyle Evans.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1728f16a0fSKyle Evans.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
1828f16a0fSKyle Evans.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
1928f16a0fSKyle Evans.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2028f16a0fSKyle Evans.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2128f16a0fSKyle Evans.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2228f16a0fSKyle Evans.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2328f16a0fSKyle Evans.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2428f16a0fSKyle Evans.\" SUCH DAMAGE.
2528f16a0fSKyle Evans.\"
2628f16a0fSKyle Evans.\" This manual page is based on the mp(3X) manual page from Sun Release
2728f16a0fSKyle Evans.\" 4.1, dated 7 September 1989.  It's an old, crufty, and relatively ugly
2828f16a0fSKyle Evans.\" manual page, but it does document what appears to be the "traditional"
2928f16a0fSKyle Evans.\" libmp interface.
3028f16a0fSKyle Evans.\"
3128f16a0fSKyle Evans.\" $FreeBSD$
3228f16a0fSKyle Evans.\"
33b29bf2f8SKyle Evans.Dd July 25, 2018
3428f16a0fSKyle Evans.Dt LIBBE 3
3528f16a0fSKyle Evans.Os
3628f16a0fSKyle Evans.Sh NAME
3728f16a0fSKyle Evans.Nm libbe
3828f16a0fSKyle Evans.Nd library for creating, destroying and modifying ZFS boot environments.
3928f16a0fSKyle Evans.Sh SYNOPSIS
4028f16a0fSKyle Evans.In be.h
4128f16a0fSKyle Evans.Pp
4228f16a0fSKyle EvansFunction prototypes are given in the main body of the text.
4328f16a0fSKyle Evans.Pp
4428f16a0fSKyle EvansApplications using this interface must be linked with
4528f16a0fSKyle Evans.Fl l Ns Ar be
4628f16a0fSKyle Evans.Sh DESCRIPTION
4728f16a0fSKyle Evans.Pp
4828f16a0fSKyle Evans.Nm
4928f16a0fSKyle Evansinterfaces with libzfs to provide a set of functions for various operations
5028f16a0fSKyle Evansregarding ZFS boot environments including "deep" boot environments in which
5128f16a0fSKyle Evansa boot environments has child datasets.
5228f16a0fSKyle Evans.Pp
5328f16a0fSKyle EvansA context structure is passed to each function, allowing for a small amount
5428f16a0fSKyle Evansof state to be retained, such as errors from previous operations.
5528f16a0fSKyle Evans.\" TODO: describe break on err functionality
5628f16a0fSKyle Evans.Pp
5728f16a0fSKyle Evans.Ft "libbe_handle_t *" Ns
5828f16a0fSKyle Evans.Fn libbe_init "void" ;
5928f16a0fSKyle Evans.Pp
6028f16a0fSKyle Evans.Ft void
6128f16a0fSKyle Evans.Fn libbe_close "libbe_handle_t *" ;
6228f16a0fSKyle Evans.Pp
6328f16a0fSKyle Evans.Ft "const char *" Ns
6428f16a0fSKyle Evans.Fn be_active_name "libbe_handle_t *" ;
6528f16a0fSKyle Evans.Pp
6628f16a0fSKyle Evans.Ft "const char *" Ns
6728f16a0fSKyle Evans.Fn be_active_path "libbe_handle_t *" ;
6828f16a0fSKyle Evans.Pp
6928f16a0fSKyle Evans.Ft "const char *" Ns
7028f16a0fSKyle Evans.Fn be_root_path "libbe_handle_t *" ;
7128f16a0fSKyle Evans.Pp
7228f16a0fSKyle Evans.Ft "nvlist_t *" Ns
7328f16a0fSKyle Evans.Fn  libbe_handle_t "libbe_handle_t " ;
7428f16a0fSKyle Evans.Pp
7528f16a0fSKyle Evans.Ft int
7628f16a0fSKyle Evans.Fn be_create "libbe_handle_t *, char *" ;
7728f16a0fSKyle Evans.Pp
7828f16a0fSKyle Evans.Ft int
79b29bf2f8SKyle Evans.Fn be_create_from_existing "libbe_handle_t *, const char *, const char *" ;
8028f16a0fSKyle Evans.Pp
8128f16a0fSKyle Evans.Ft int
8228f16a0fSKyle Evans.Fn be_rename "libbe_handle_t *, char *, char *" ;
8328f16a0fSKyle Evans.Pp
8428f16a0fSKyle Evans.\" TODO: Write up of destroy options
8528f16a0fSKyle Evans.\" typedef enum {
8628f16a0fSKyle Evans.\"	BE_DESTROY_FORCE = 1 << 0,
8728f16a0fSKyle Evans.\" } be_destroy_opt_t;
8828f16a0fSKyle Evans.Ft int
8928f16a0fSKyle Evans.Fn be_destroy "libbe_handle_t *, char *, int" ;
9028f16a0fSKyle Evans.Pp
919b1662e6SKyle Evans.Ft void
929b1662e6SKyle Evans.Fn be_nicenum "uint64_t, char *, size_t" ;
939b1662e6SKyle Evans.Pp
9428f16a0fSKyle Evans.\" TODO: Write up of mount options
9528f16a0fSKyle Evans.\" typedef enum {
9628f16a0fSKyle Evans.\"	BE_MNT_FORCE		= 1 << 0,
9728f16a0fSKyle Evans.\"	BE_MNT_DEEP		= 1 << 1,
9828f16a0fSKyle Evans.\" } be_mount_opt_t;
9928f16a0fSKyle Evans.Ft int
10028f16a0fSKyle Evans.Fn be_mount "libbe_handle_t *, char *, char *, int" ;
10128f16a0fSKyle Evans.Pp
10228f16a0fSKyle Evans.Ft int
103843e39ceSKyle Evans.Fn be_mounted_at "libbe_handle_t *, const char *, nvlist_t" ;
104843e39ceSKyle Evans.Pp
105843e39ceSKyle Evans.Ft int
10628f16a0fSKyle Evans.Fn be_unmount "libbe_handle_t *, char *, int" ;
10728f16a0fSKyle Evans.Pp
10828f16a0fSKyle Evans.Ft int
10928f16a0fSKyle Evans.Fn libbe_errno "libbe_handle_t *" ;
11028f16a0fSKyle Evans.Pp
11128f16a0fSKyle Evans.Ft "const char *" Ns
11228f16a0fSKyle Evans.Fn libbe_error_description "libbe_handle_t *" ;
11328f16a0fSKyle Evans.Pp
11428f16a0fSKyle Evans.Ft void
11528f16a0fSKyle Evans.Fn libbe_print_on_error "libbe_handle_t *, bool" ;
11628f16a0fSKyle Evans.Pp
11728f16a0fSKyle Evans.Ft int
118b29bf2f8SKyle Evans.Fn be_root_concat "libbe_handle_t *, const char *, char *" ;
11928f16a0fSKyle Evans.Pp
12028f16a0fSKyle Evans.Ft int
121b29bf2f8SKyle Evans.Fn be_validate_name "libbe_handle_t *, const char *" ;
12228f16a0fSKyle Evans.Pp
12328f16a0fSKyle Evans.Ft int
124b29bf2f8SKyle Evans.Fn be_validate_snap "libbe_handle_t *, const char *" ;
12528f16a0fSKyle Evans.Pp
12628f16a0fSKyle Evans.Ft bool
12728f16a0fSKyle Evans.Fn be_exists "libbe_handle_t *, char *" ;
12828f16a0fSKyle Evans.Pp
12928f16a0fSKyle Evans.Ft int
13028f16a0fSKyle Evans.Fn be_export "libbe_handle_t *, char *, int fd" ;
13128f16a0fSKyle Evans.Pp
13228f16a0fSKyle Evans.Ft int
13328f16a0fSKyle Evans.Fn be_import "libbe_handle_t *, char *, int fd" ;
13428f16a0fSKyle Evans.Pp
13528f16a0fSKyle Evans.Ft int
13628f16a0fSKyle Evans.Fn be_add_child "libbe_handle_t *, char *, bool" ;
13728f16a0fSKyle Evans.Pp
138734e362fSKyle Evans.Ft int
139734e362fSKyle Evans.Fn be_prop_list_alloc "nvlist_t **" ;
140734e362fSKyle Evans.Pp
141734e362fSKyle Evans.Ft int
142734e362fSKyle Evans.Fn be_get_bootenv_props "libbe_handle_t *, nvlist_t *" ;
143734e362fSKyle Evans.Pp
1444146029bSKyle Evans.Ft int
1459b1662e6SKyle Evans.Fn be_get_dataset_props "libbe_handle_t *, const char *, nvlist_t *" ;
1464146029bSKyle Evans.Pp
147*96c5db58SKyle Evans.Ft int
148*96c5db58SKyle Evans.Fn be_get_dataset_snapshots "libbe_handle_t *, const char *, nvlist_t *" ;
149*96c5db58SKyle Evans.Pp
150734e362fSKyle Evans.Ft void
151734e362fSKyle Evans.Fn be_prop_list_free "nvlist_t *" ;
15228f16a0fSKyle Evans.\" .Ft void
15328f16a0fSKyle Evans.\" .Fn mp_mfree "MINT *mp" ;
15428f16a0fSKyle Evans.\" .Bd -ragged -offset indent
15528f16a0fSKyle Evans.\" .Fn mp_itom
15628f16a0fSKyle Evans.\" returns an
15728f16a0fSKyle Evans.\" .Vt MINT
15828f16a0fSKyle Evans.\" with the value of
15928f16a0fSKyle Evans.\" .Fa n .
16028f16a0fSKyle Evans.\" .Fn mp_xtom
16128f16a0fSKyle Evans.\" returns an
16228f16a0fSKyle Evans.\" .Vt MINT
16328f16a0fSKyle Evans.\" with the value of
16428f16a0fSKyle Evans.\" .Fa s ,
16528f16a0fSKyle Evans.\" which is treated to be in hexadecimal.
16628f16a0fSKyle Evans.\" The return values from
16728f16a0fSKyle Evans.\" .Fn mp_itom
16828f16a0fSKyle Evans.\" and
16928f16a0fSKyle Evans.\" .Fn mp_xtom
17028f16a0fSKyle Evans.\" must be released with
17128f16a0fSKyle Evans.\" .Fn mp_mfree
17228f16a0fSKyle Evans.\" when they are no longer needed.
17328f16a0fSKyle Evans.\" .Fn mp_mtox
17428f16a0fSKyle Evans.\" returns a null-terminated hexadecimal string having the value of
17528f16a0fSKyle Evans.\" .Fa mp ;
17628f16a0fSKyle Evans.\" its return value must be released with
17728f16a0fSKyle Evans.\" .Fn free
17828f16a0fSKyle Evans.\" .Pq Xr free 3
17928f16a0fSKyle Evans.\" when it is no longer needed.
18028f16a0fSKyle Evans.\" .Ed
18128f16a0fSKyle Evans.\" .Pp
18228f16a0fSKyle Evans.Sh DIAGNOSTICS
18328f16a0fSKyle EvansUpon error, one of the following values will be returned.
18428f16a0fSKyle Evans.\" TODO: make each entry on its own line.
18528f16a0fSKyle Evans.Bd -ragged -offset indent
18628f16a0fSKyle EvansBE_ERR_SUCCESS,
18728f16a0fSKyle EvansBE_ERR_INVALIDNAME,
18828f16a0fSKyle EvansBE_ERR_EXISTS,
18928f16a0fSKyle EvansBE_ERR_NOENT,
19028f16a0fSKyle EvansBE_ERR_PERMS,
19128f16a0fSKyle EvansBE_ERR_DESTROYACT,
19228f16a0fSKyle EvansBE_ERR_DESTROYMNT,
19328f16a0fSKyle EvansBE_ERR_PATHLEN,
19428f16a0fSKyle EvansBE_ERR_INVORIGIN,
19528f16a0fSKyle EvansBE_ERR_NOORIGIN,
19628f16a0fSKyle EvansBE_ERR_MOUNTED,
19728f16a0fSKyle EvansBE_ERR_NOMOUNT,
19828f16a0fSKyle EvansBE_ERR_ZFSOPEN,
19928f16a0fSKyle EvansBE_ERR_ZFSCLONE,
20028f16a0fSKyle EvansBE_ERR_UNKNOWN
20128f16a0fSKyle Evans.Ed
20228f16a0fSKyle Evans.Sh SEE ALSO
20328f16a0fSKyle Evans.Xr be 1 ,
20428f16a0fSKyle Evans.Sh HISTORY
20528f16a0fSKyle Evans.Nm
20628f16a0fSKyle Evansand it's corresponding command,
20728f16a0fSKyle Evans.Xr be 3 ,
20828f16a0fSKyle Evanswere written as a 2017 Google Summer of Code project with Allan Jude serving
20928f16a0fSKyle Evansas a mentor.
21028f16a0fSKyle Evans.\" TODO: update when implementation complete.
21128f16a0fSKyle Evans.\" .Sh BUGS
21228f16a0fSKyle Evans
213