xref: /freebsd/lib/libbe/libbe.3 (revision d2a6bc9fa5b1dad61efcd1824e4c48d0a42576af)
128f16a0fSKyle Evans.\"
2b179da01SKyle Evans.\" SPDX-License-Identifier: BSD-2-Clause-FreeBSD
3b179da01SKyle Evans.\"
428f16a0fSKyle Evans.\" Copyright (c) 2017 Kyle Kneitinger
528f16a0fSKyle Evans.\" All rights reserved.
67c2cc9b2SKyle Evans.\" Copyright (c) 2018 Kyle Evans <kevans@FreeBSD.org>
728f16a0fSKyle Evans.\"
828f16a0fSKyle Evans.\" Redistribution and use in source and binary forms, with or without
928f16a0fSKyle Evans.\" modification, are permitted provided that the following conditions
1028f16a0fSKyle Evans.\" are met:
1128f16a0fSKyle Evans.\" 1. Redistributions of source code must retain the above copyright
1228f16a0fSKyle Evans.\"    notice, this list of conditions and the following disclaimer.
1328f16a0fSKyle Evans.\" 2. Redistributions in binary form must reproduce the above copyright
1428f16a0fSKyle Evans.\"    notice, this list of conditions and the following disclaimer in the
1528f16a0fSKyle Evans.\"    documentation and/or other materials provided with the distribution.
1628f16a0fSKyle Evans.\"
1728f16a0fSKyle Evans.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
1828f16a0fSKyle Evans.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1928f16a0fSKyle Evans.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2028f16a0fSKyle Evans.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
2128f16a0fSKyle Evans.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2228f16a0fSKyle Evans.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2328f16a0fSKyle Evans.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2428f16a0fSKyle Evans.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2528f16a0fSKyle Evans.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2628f16a0fSKyle Evans.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2728f16a0fSKyle Evans.\" SUCH DAMAGE.
2828f16a0fSKyle Evans.\"
2928f16a0fSKyle Evans.\" $FreeBSD$
3028f16a0fSKyle Evans.\"
3111f2a123SKyle Evans.Dd August 10, 2018
3228f16a0fSKyle Evans.Dt LIBBE 3
3328f16a0fSKyle Evans.Os
3428f16a0fSKyle Evans.Sh NAME
3528f16a0fSKyle Evans.Nm libbe
3684e61219SKyle Evans.Nd library for creating, destroying and modifying ZFS boot environments
3784e61219SKyle Evans.Sh LIBRARY
387c2cc9b2SKyle Evans.Lb libbe
3928f16a0fSKyle Evans.Sh SYNOPSIS
4028f16a0fSKyle Evans.In be.h
417c2cc9b2SKyle Evans.Ft "libbe_handle_t *hdl" Ns
427c2cc9b2SKyle Evans.Fn libbe_init void
4328f16a0fSKyle Evans.Pp
447c2cc9b2SKyle Evans.Ft void
457c2cc9b2SKyle Evans.Fn libbe_close "libbe_handle_t *hdl"
4628f16a0fSKyle Evans.Pp
477c2cc9b2SKyle Evans.Ft const char * Ns
487c2cc9b2SKyle Evans.Fn be_active_name "libbe_handle_t *hdl"
497c2cc9b2SKyle Evans.Pp
507c2cc9b2SKyle Evans.Ft const char * Ns
517c2cc9b2SKyle Evans.Fn be_active_path "libbe_handle_t *hdl"
527c2cc9b2SKyle Evans.Pp
537c2cc9b2SKyle Evans.Ft const char * Ns
547c2cc9b2SKyle Evans.Fn be_nextboot_name "libbe_handle_t *hdl"
557c2cc9b2SKyle Evans.Pp
567c2cc9b2SKyle Evans.Ft const char * Ns
577c2cc9b2SKyle Evans.Fn be_nextboot_path "libbe_handle_t *hdl"
587c2cc9b2SKyle Evans.Pp
597c2cc9b2SKyle Evans.Ft const char * Ns
607c2cc9b2SKyle Evans.Fn be_root_path "libbe_handle_t *hdl"
617c2cc9b2SKyle Evans.Pp
627c2cc9b2SKyle Evans.Ft int
637c2cc9b2SKyle Evans.Fn be_create "libbe_handle_t *hdl" "const char *be_name"
647c2cc9b2SKyle Evans.Pp
657c2cc9b2SKyle Evans.Ft int
667c2cc9b2SKyle Evans.Fn be_create_from_existing "libbe_handle_t *hdl" "const char *be_name" "const char *be_origin"
677c2cc9b2SKyle Evans.Pp
687c2cc9b2SKyle Evans.Ft int
697c2cc9b2SKyle Evans.Fn be_create_from_existing_snap "libbe_handle_t *hdl" "const char *be_name" "const char *snap"
707c2cc9b2SKyle Evans.Pp
717c2cc9b2SKyle Evans.Ft int
727c2cc9b2SKyle Evans.Fn be_rename "libbe_handle_t *hdl" "const char *be_old" "const char *be_new"
737c2cc9b2SKyle Evans.Pp
747c2cc9b2SKyle Evans.Ft int
757c2cc9b2SKyle Evans.Fn be_activate "libbe_handle_t *hdl" "const char *be_name" "bool temporary"
767c2cc9b2SKyle Evans.Ft int
777c2cc9b2SKyle Evans.Fn be_destroy "libbe_handle_t *hdl" "const char *be_name" "int options"
787c2cc9b2SKyle Evans.Pp
797c2cc9b2SKyle Evans.Ft void
807c2cc9b2SKyle Evans.Fn be_nicenum "uint64_t num" "char *buf" "size_t bufsz"
817c2cc9b2SKyle Evans.Pp
827c2cc9b2SKyle Evans.\" TODO: Write up of mount options
837c2cc9b2SKyle Evans.\" typedef enum {
847c2cc9b2SKyle Evans.\"	BE_MNT_FORCE		= 1 << 0,
857c2cc9b2SKyle Evans.\"	BE_MNT_DEEP		= 1 << 1,
867c2cc9b2SKyle Evans.\" } be_mount_opt_t
877c2cc9b2SKyle Evans.Ft int
887c2cc9b2SKyle Evans.Fn be_mount "libbe_handle_t *hdl" "char *be_name" "char *mntpoint" "int flags" "char *result"
897c2cc9b2SKyle Evans.Pp
907c2cc9b2SKyle Evans.Ft int
917c2cc9b2SKyle Evans.Fn be_mounted_at "libbe_handle_t *hdl" "const char *path" "nvlist_t *details"
927c2cc9b2SKyle Evans.Pp
937c2cc9b2SKyle Evans.Ft int
947c2cc9b2SKyle Evans.Fn be_unmount "libbe_handle_t *hdl" "char *be_name" "int flags"
957c2cc9b2SKyle Evans.Pp
967c2cc9b2SKyle Evans.Ft int
977c2cc9b2SKyle Evans.Fn libbe_errno "libbe_handle_t *hdl"
987c2cc9b2SKyle Evans.Pp
997c2cc9b2SKyle Evans.Ft const char * Ns
1007c2cc9b2SKyle Evans.Fn libbe_error_description "libbe_handle_t *hdl"
1017c2cc9b2SKyle Evans.Pp
1027c2cc9b2SKyle Evans.Ft void
1037c2cc9b2SKyle Evans.Fn libbe_print_on_error "libbe_handle_t *hdl" "bool doprint"
1047c2cc9b2SKyle Evans.Pp
1057c2cc9b2SKyle Evans.Ft int
1067c2cc9b2SKyle Evans.Fn be_root_concat "libbe_handle_t *hdl" "const char *be_name" "char *result"
1077c2cc9b2SKyle Evans.Pp
1087c2cc9b2SKyle Evans.Ft int
1097c2cc9b2SKyle Evans.Fn be_validate_name "libbe_handle_t *hdl" "const char *be_name"
1107c2cc9b2SKyle Evans.Pp
1117c2cc9b2SKyle Evans.Ft int
1127c2cc9b2SKyle Evans.Fn be_validate_snap "libbe_handle_t *hdl" "const char *snap"
1137c2cc9b2SKyle Evans.Pp
1147c2cc9b2SKyle Evans.Ft bool
1157c2cc9b2SKyle Evans.Fn be_exists "libbe_handle_t *hdl" "char *be_name"
1167c2cc9b2SKyle Evans.Pp
1177c2cc9b2SKyle Evans.Ft int
1187c2cc9b2SKyle Evans.Fn be_export "libbe_handle_t *hdl" "const char *be_name" "int fd"
1197c2cc9b2SKyle Evans.Pp
1207c2cc9b2SKyle Evans.Ft int
1217c2cc9b2SKyle Evans.Fn be_import "libbe_handle_t *hdl" "const char *be_name" "int fd"
1227c2cc9b2SKyle Evans.Pp
1237c2cc9b2SKyle Evans.Ft int
1247c2cc9b2SKyle Evans.Fn be_prop_list_alloc "nvlist_t **prop_list"
1257c2cc9b2SKyle Evans.Pp
1267c2cc9b2SKyle Evans.Ft int
1277c2cc9b2SKyle Evans.Fn be_get_bootenv_props "libbe_handle_t *hdl" "nvlist_t *be_list"
1287c2cc9b2SKyle Evans.Pp
1297c2cc9b2SKyle Evans.Ft int
1307c2cc9b2SKyle Evans.Fn be_get_dataset_props "libbe_handle_t *hdl" "const char *ds_name" "nvlist_t *props"
1317c2cc9b2SKyle Evans.Pp
1327c2cc9b2SKyle Evans.Ft int
1337c2cc9b2SKyle Evans.Fn be_get_dataset_snapshots "libbe_handle_t *hdl" "const char *ds_name" "nvlist_t *snap_list"
1347c2cc9b2SKyle Evans.Pp
1357c2cc9b2SKyle Evans.Ft void
1367c2cc9b2SKyle Evans.Fn be_prop_list_free "nvlist_t *prop_list"
13728f16a0fSKyle Evans.Sh DESCRIPTION
13828f16a0fSKyle Evans.Nm
13928f16a0fSKyle Evansinterfaces with libzfs to provide a set of functions for various operations
14028f16a0fSKyle Evansregarding ZFS boot environments including "deep" boot environments in which
14128f16a0fSKyle Evansa boot environments has child datasets.
14228f16a0fSKyle Evans.Pp
14328f16a0fSKyle EvansA context structure is passed to each function, allowing for a small amount
14428f16a0fSKyle Evansof state to be retained, such as errors from previous operations.
1457c2cc9b2SKyle Evans.Nm
1467c2cc9b2SKyle Evansmay be configured to print the corresponding error message to
1477c2cc9b2SKyle Evans.Dv stderr
1487c2cc9b2SKyle Evanswhen an error is encountered with
1497c2cc9b2SKyle Evans.Fn libbe_print_on_error .
15028f16a0fSKyle Evans.Pp
1517c2cc9b2SKyle EvansAll functions returning an
1527c2cc9b2SKyle Evans.Vt int
1537c2cc9b2SKyle Evansreturn 0 on success, or a
1547c2cc9b2SKyle Evans.Nm
1557c2cc9b2SKyle Evanserrno otherwise as described in
1567c2cc9b2SKyle Evans.Sx DIAGNOSTICS .
15728f16a0fSKyle Evans.Pp
1587c2cc9b2SKyle EvansThe
1597c2cc9b2SKyle Evans.Fn libbe_init
1607c2cc9b2SKyle Evansfunction initializes
1617c2cc9b2SKyle Evans.Nm ,
1627c2cc9b2SKyle Evansreturning a
1637c2cc9b2SKyle Evans.Vt "libbe_handle_t *"
1647c2cc9b2SKyle Evanson success, or
1657c2cc9b2SKyle Evans.Dv NULL
1667c2cc9b2SKyle Evanson error.
1677c2cc9b2SKyle EvansAn error may occur if:
1687c2cc9b2SKyle Evans.Bl -column
1697c2cc9b2SKyle Evans.It /boot and / are not on the same filesystem and device,
1707c2cc9b2SKyle Evans.It libzfs fails to initialize,
1717c2cc9b2SKyle Evans.It The system has not been properly booted with a ZFS boot
1727c2cc9b2SKyle Evansenvironment,
173*d2a6bc9fSKyle Evans.It Nm
1747c2cc9b2SKyle Evansfails to open the zpool the active boot environment resides on, or
175*d2a6bc9fSKyle Evans.It Nm
1767c2cc9b2SKyle Evansfails to locate the boot environment that is currently mounted.
1777c2cc9b2SKyle Evans.El
17828f16a0fSKyle Evans.Pp
1797c2cc9b2SKyle EvansThe
1807c2cc9b2SKyle Evans.Fn libbe_close
1817c2cc9b2SKyle Evansfunction frees all resources previously acquired in
1827c2cc9b2SKyle Evans.Fn libbe_init ,
1837c2cc9b2SKyle Evansinvalidating the handle in the process.
18428f16a0fSKyle Evans.Pp
1857c2cc9b2SKyle EvansThe
1867c2cc9b2SKyle Evans.Fn be_active_name
1877c2cc9b2SKyle Evansfunction returns the name of the currently booted boot environment,
18884e61219SKyle Evans.Pp
1897c2cc9b2SKyle EvansThe
1907c2cc9b2SKyle Evans.Fn be_active_path
1917c2cc9b2SKyle Evansfunction returns the full path of the currently booted boot environment.
19284e61219SKyle Evans.Pp
1937c2cc9b2SKyle EvansThe
1947c2cc9b2SKyle Evans.Fn be_nextboot_name
1957c2cc9b2SKyle Evansfunction returns the name of the boot environment that will be active on reboot.
19628f16a0fSKyle Evans.Pp
1977c2cc9b2SKyle EvansThe
1987c2cc9b2SKyle Evans.Fn be_nextboot_path
1997c2cc9b2SKyle Evansfunction returns the full path of the boot environment that will be
2007c2cc9b2SKyle Evansactive on reboot.
20128f16a0fSKyle Evans.Pp
2027c2cc9b2SKyle EvansThe
2037c2cc9b2SKyle Evans.Fn be_root_path
2047c2cc9b2SKyle Evansfunction returns the boot environment root path.
20528f16a0fSKyle Evans.Pp
2067c2cc9b2SKyle EvansThe
2077c2cc9b2SKyle Evans.Fn be_create
2087c2cc9b2SKyle Evansfunction creates a boot environment with the given name.
2097c2cc9b2SKyle EvansIt will be created from a snapshot of the currently booted boot environment.
21028f16a0fSKyle Evans.Pp
2117c2cc9b2SKyle EvansThe
2127c2cc9b2SKyle Evans.Fn be_create_from_existing
2137c2cc9b2SKyle Evansfunction creates a boot environment with the given name from the name of an
2147c2cc9b2SKyle Evansexisting boot environment.
2157c2cc9b2SKyle EvansA snapshot will be made of the base boot environment, and the new boot
2167c2cc9b2SKyle Evansenvironment will be created from that.
21728f16a0fSKyle Evans.Pp
2187c2cc9b2SKyle EvansThe
2197c2cc9b2SKyle Evans.Fn be_create_from_existing_snap
2207c2cc9b2SKyle Evansfunction creates a boot environment with the given name from an existing
2217c2cc9b2SKyle Evanssnapshot.
22228f16a0fSKyle Evans.Pp
2237c2cc9b2SKyle EvansThe
2247c2cc9b2SKyle Evans.Fn be_rename
2257c2cc9b2SKyle Evansfunction renames a boot environment.
2269b1662e6SKyle Evans.Pp
2277c2cc9b2SKyle EvansThe
2287c2cc9b2SKyle Evans.Fn be_activate
2297c2cc9b2SKyle Evansfunction makes a boot environment active on the next boot.
2307c2cc9b2SKyle EvansIf the
2317c2cc9b2SKyle Evans.Fa temporary
2327c2cc9b2SKyle Evansflag is set, then it will be active for the next boot only, as done by
2337c2cc9b2SKyle Evans.Xr zfsbootcfg 8 .
2347c2cc9b2SKyle EvansNext boot functionality is currently only available when booting in x86 BIOS
2357c2cc9b2SKyle Evansmode.
23628f16a0fSKyle Evans.Pp
2377c2cc9b2SKyle EvansThe
2387c2cc9b2SKyle Evans.Fn be_destroy
2397c2cc9b2SKyle Evansfunction will recursively destroy the given boot environment.
2407c2cc9b2SKyle EvansIt will not destroy a mounted boot environment unless the
2417c2cc9b2SKyle Evans.Dv BE_DESTROY_FORCE
2427c2cc9b2SKyle Evansoption is set in
2437c2cc9b2SKyle Evans.Fa options .
244843e39ceSKyle Evans.Pp
2457c2cc9b2SKyle EvansThe
2467c2cc9b2SKyle Evans.Fn be_nicenum
2477c2cc9b2SKyle Evansfunction will format
2487c2cc9b2SKyle Evans.Fa name
2497c2cc9b2SKyle Evansin a traditional ZFS humanized format, similar to
2507c2cc9b2SKyle Evans.Xr humanize_number 3 .
2517c2cc9b2SKyle EvansThis function effectively proxies
2527c2cc9b2SKyle Evans.Fn zfs_nicenum
2537c2cc9b2SKyle Evansfrom libzfs.
25428f16a0fSKyle Evans.Pp
2557c2cc9b2SKyle EvansThe
2567c2cc9b2SKyle Evans.Fn be_mount
2577c2cc9b2SKyle Evansfunction will mount the given boot environment.
2587c2cc9b2SKyle EvansIf
2597c2cc9b2SKyle Evans.Fa mountpoint
2607c2cc9b2SKyle Evansis
2617c2cc9b2SKyle Evans.Dv NULL ,
2627c2cc9b2SKyle Evansa mount point will be generated in
2637c2cc9b2SKyle Evans.Pa /tmp
2647c2cc9b2SKyle Evansusing
2657c2cc9b2SKyle Evans.Xr mkdtemp 3 .
2667c2cc9b2SKyle EvansIf
2677c2cc9b2SKyle Evans.Fa result
2687c2cc9b2SKyle Evansis not
2697c2cc9b2SKyle Evans.Dv NULL ,
2707c2cc9b2SKyle Evansthe final mount point will be copied into it.
2717c2cc9b2SKyle EvansSetting the
2727c2cc9b2SKyle Evans.Dv BE_MNT_FORCE
2737c2cc9b2SKyle Evansflag will pass
2747c2cc9b2SKyle Evans.Dv MNT_FORCE
2757c2cc9b2SKyle Evansto the underlying
2767c2cc9b2SKyle Evans.Xr mount 2
2777c2cc9b2SKyle Evanscall.
27828f16a0fSKyle Evans.Pp
2797c2cc9b2SKyle EvansThe
2807c2cc9b2SKyle Evans.Fn be_mounted_at
2817c2cc9b2SKyle Evansfunction will check if there is a boot environment mounted at the given
2827c2cc9b2SKyle Evans.Fa path .
2837c2cc9b2SKyle EvansIf
2847c2cc9b2SKyle Evans.Fa details
2857c2cc9b2SKyle Evansis not
2867c2cc9b2SKyle Evans.Dv NULL ,
2877c2cc9b2SKyle Evansit will be populated with a list of the mounted dataset's properties.
2887c2cc9b2SKyle EvansThis list of properties matches the properties collected by
2897c2cc9b2SKyle Evans.Fn be_get_bootenv_props .
29028f16a0fSKyle Evans.Pp
2917c2cc9b2SKyle EvansThe
2927c2cc9b2SKyle Evans.Fn be_unmount
2937c2cc9b2SKyle Evansfunction will unmount the given boot environment.
2947c2cc9b2SKyle EvansSetting the
2957c2cc9b2SKyle Evans.Dv BE_MNT_FORCE
2967c2cc9b2SKyle Evansflag will pass
2977c2cc9b2SKyle Evans.Dv MNT_FORCE
2987c2cc9b2SKyle Evansto the underlying
2997c2cc9b2SKyle Evans.Xr mount 2
3007c2cc9b2SKyle Evanscall.
30128f16a0fSKyle Evans.Pp
3027c2cc9b2SKyle EvansThe
3037c2cc9b2SKyle Evans.Fn libbe_errno
3047c2cc9b2SKyle Evansfunction returns the
3057c2cc9b2SKyle Evans.Nm
3067c2cc9b2SKyle Evanserrno.
30728f16a0fSKyle Evans.Pp
3087c2cc9b2SKyle EvansThe
3097c2cc9b2SKyle Evans.Fn libbe_error_description
3107c2cc9b2SKyle Evansfunction returns a string description of the currently set
3117c2cc9b2SKyle Evans.Nm
3127c2cc9b2SKyle Evanserrno.
31328f16a0fSKyle Evans.Pp
3147c2cc9b2SKyle EvansThe
3157c2cc9b2SKyle Evans.Fn libbe_print_on_error
3167c2cc9b2SKyle Evansfunction will change whether or not
3177c2cc9b2SKyle Evans.Nm
3187c2cc9b2SKyle Evansprints the description of any encountered error to
3197c2cc9b2SKyle Evans.Dv stderr ,
3207c2cc9b2SKyle Evansbased on
3217c2cc9b2SKyle Evans.Fa doprint .
32228f16a0fSKyle Evans.Pp
3237c2cc9b2SKyle EvansThe
3247c2cc9b2SKyle Evans.Fn be_root_concat
3257c2cc9b2SKyle Evansfunction will concatenate the boot environment root and the given boot
3267c2cc9b2SKyle Evansenvironment name into
3277c2cc9b2SKyle Evans.Fa result .
32828f16a0fSKyle Evans.Pp
3297c2cc9b2SKyle EvansThe
3307c2cc9b2SKyle Evans.Fn be_validate_name
3317c2cc9b2SKyle Evansfunction will validate the given boot environment name.
33228f16a0fSKyle Evans.Pp
3337c2cc9b2SKyle EvansThe
3347c2cc9b2SKyle Evans.Fn be_validate_snap
3357c2cc9b2SKyle Evansfunction will validate the given snapshot name.
3367c2cc9b2SKyle EvansThe snapshot must have a valid name, exist, and have a mountpoint of
3377c2cc9b2SKyle Evans.Pa / .
3387c2cc9b2SKyle EvansThis function does not set the internal library error state.
33928f16a0fSKyle Evans.Pp
3407c2cc9b2SKyle EvansThe
3417c2cc9b2SKyle Evans.Fn be_exists
3427c2cc9b2SKyle Evansfunction will check whether the given boot environment exists and has a
3437c2cc9b2SKyle Evansmountpoint of
3447c2cc9b2SKyle Evans.Pa / .
345734e362fSKyle Evans.Pp
3467c2cc9b2SKyle EvansThe
3477c2cc9b2SKyle Evans.Fn be_export
3487c2cc9b2SKyle Evansfunction will export the given boot environment to the file specified by
3497c2cc9b2SKyle Evans.Fa fd .
3507c2cc9b2SKyle EvansA snapshot will be created of the boot environment prior to export.
351734e362fSKyle Evans.Pp
3527c2cc9b2SKyle EvansThe
3537c2cc9b2SKyle Evans.Fn be_import
3547c2cc9b2SKyle Evansfunction will import the boot environment in the file specified by
3557c2cc9b2SKyle Evans.Fa fd ,
3567c2cc9b2SKyle Evansand give it the name
3577c2cc9b2SKyle Evans.Fa be_name .
3584146029bSKyle Evans.Pp
3597c2cc9b2SKyle EvansThe
3607c2cc9b2SKyle Evans.Fn be_prop_list_alloc
3617c2cc9b2SKyle Evansfunction allocates a property list suitable for passing to
3627c2cc9b2SKyle Evans.Fn be_get_bootenv_props ,
3637c2cc9b2SKyle Evans.Fn be_get_dataset_props ,
3647c2cc9b2SKyle Evansor
3657c2cc9b2SKyle Evans.Fn be_get_dataset_snapshots .
3667c2cc9b2SKyle EvansIt should be freed later by
3677c2cc9b2SKyle Evans.Fa be_prop_list_free .
36896c5db58SKyle Evans.Pp
3697c2cc9b2SKyle EvansThe
3707c2cc9b2SKyle Evans.Fn be_get_bootenv_props
3717c2cc9b2SKyle Evansfunction will populate
3727c2cc9b2SKyle Evans.Fa be_list
3737c2cc9b2SKyle Evanswith
3747c2cc9b2SKyle Evans.Vt nvpair_t
3757c2cc9b2SKyle Evansof boot environment names paired with an
3767c2cc9b2SKyle Evans.Vt nvlist_t
3777c2cc9b2SKyle Evansof their properties.
3787c2cc9b2SKyle EvansThe following properties are currently collected as appropriate:
3797c2cc9b2SKyle Evans.Bl -column "Returned name"
3807c2cc9b2SKyle Evans.It Sy Returned name Ta Sy Description
3817c2cc9b2SKyle Evans.It dataset Ta -
3827c2cc9b2SKyle Evans.It name Ta Boot environment name
3837c2cc9b2SKyle Evans.It mounted Ta Current mount point
3847c2cc9b2SKyle Evans.It mountpoint Ta Do mountpoint Dc property
3857c2cc9b2SKyle Evans.It origin Ta Do origin Dc property
3867c2cc9b2SKyle Evans.It creation Ta Do creation Dc property
3877c2cc9b2SKyle Evans.It active Ta Currently booted environment
3887c2cc9b2SKyle Evans.It used Ta Literal Do used Dc property
3897c2cc9b2SKyle Evans.It usedds Ta Literal Do usedds Dc property
3907c2cc9b2SKyle Evans.It usedsnap Ta Literal Do usedrefreserv Dc property
3917c2cc9b2SKyle Evans.It referenced Ta Literal Do referenced Dc property
3927c2cc9b2SKyle Evans.It nextboot Ta Active on next boot
3937c2cc9b2SKyle Evans.El
3947c2cc9b2SKyle Evans.Pp
3957c2cc9b2SKyle EvansOnly the
3967c2cc9b2SKyle Evans.Dq dataset ,
3977c2cc9b2SKyle Evans.Dq name ,
3987c2cc9b2SKyle Evans.Dq active ,
3997c2cc9b2SKyle Evansand
4007c2cc9b2SKyle Evans.Dq nextboot
4017c2cc9b2SKyle Evansreturned values will always be present.
4027c2cc9b2SKyle EvansAll other properties may be omitted if not available.
4037c2cc9b2SKyle Evans.Pp
4047c2cc9b2SKyle EvansThe
4057c2cc9b2SKyle Evans.Fn be_get_dataset_props
4067c2cc9b2SKyle Evansfunction will get properties of the specified dataset.
4077c2cc9b2SKyle Evans.Fa props
4087c2cc9b2SKyle Evansis populated directly with a list of the properties as returned by
4097c2cc9b2SKyle Evans.Fn be_get_bootenv_props .
4107c2cc9b2SKyle Evans.Pp
4117c2cc9b2SKyle EvansThe
4127c2cc9b2SKyle Evans.Fn be_get_dataset_snapshots
4137c2cc9b2SKyle Evansfunction will retrieve all snapshots of the given dataset.
4147c2cc9b2SKyle Evans.Fa snap_list
4157c2cc9b2SKyle Evanswill be populated with a list of
4167c2cc9b2SKyle Evans.Vt nvpair_t
4177c2cc9b2SKyle Evansexactly as specified by
4187c2cc9b2SKyle Evans.Fn be_get_bootenv_props .
4197c2cc9b2SKyle Evans.Pp
4207c2cc9b2SKyle EvansThe
4217c2cc9b2SKyle Evans.Fn be_prop_list_free
4227c2cc9b2SKyle Evansfunction will free the property list.
42328f16a0fSKyle Evans.Sh DIAGNOSTICS
42428f16a0fSKyle EvansUpon error, one of the following values will be returned.
42528f16a0fSKyle Evans.\" TODO: make each entry on its own line.
42628f16a0fSKyle Evans.Bd -ragged -offset indent
42728f16a0fSKyle EvansBE_ERR_SUCCESS,
42828f16a0fSKyle EvansBE_ERR_INVALIDNAME,
42928f16a0fSKyle EvansBE_ERR_EXISTS,
43028f16a0fSKyle EvansBE_ERR_NOENT,
43128f16a0fSKyle EvansBE_ERR_PERMS,
43228f16a0fSKyle EvansBE_ERR_DESTROYACT,
43328f16a0fSKyle EvansBE_ERR_DESTROYMNT,
434f1ca70d3SKyle EvansBE_ERR_BADPATH,
435f1ca70d3SKyle EvansBE_ERR_PATHBUSY,
43628f16a0fSKyle EvansBE_ERR_PATHLEN,
43728f16a0fSKyle EvansBE_ERR_INVORIGIN,
43828f16a0fSKyle EvansBE_ERR_NOORIGIN,
43928f16a0fSKyle EvansBE_ERR_MOUNTED,
44028f16a0fSKyle EvansBE_ERR_NOMOUNT,
44128f16a0fSKyle EvansBE_ERR_ZFSOPEN,
44228f16a0fSKyle EvansBE_ERR_ZFSCLONE,
443f1ca70d3SKyle EvansBE_ERR_IO,
44411f2a123SKyle EvansBE_ERR_NOPOOL,
44511f2a123SKyle EvansBE_ERR_NOMEM,
44628f16a0fSKyle EvansBE_ERR_UNKNOWN
44728f16a0fSKyle Evans.Ed
44828f16a0fSKyle Evans.Sh SEE ALSO
44984e61219SKyle Evans.Xr be 1
45028f16a0fSKyle Evans.Sh HISTORY
45128f16a0fSKyle Evans.Nm
45284e61219SKyle Evansand its corresponding command,
45384e61219SKyle Evans.Xr bectl 8 ,
45428f16a0fSKyle Evanswere written as a 2017 Google Summer of Code project with Allan Jude serving
45528f16a0fSKyle Evansas a mentor.
4567c2cc9b2SKyle EvansLater work was done by
4577c2cc9b2SKyle Evans.An Kyle Evans Aq Mt kevans@FreeBSD.org .
458*d2a6bc9fSKyle Evans.Sh BUGS
459*d2a6bc9fSKyle EvansThe
460*d2a6bc9fSKyle Evans.Fn be_import
461*d2a6bc9fSKyle Evansfunction does not destroy the temporary boot environment it creates for import,
462*d2a6bc9fSKyle Evansbecause the snapshot created to do the import may not be deleted since it is the
463*d2a6bc9fSKyle Evansorigin of the new boot environment.
464