xref: /freebsd/lib/libbe/be_impl.h (revision fa30d9ed75e203b823842a0d59a6f849c907be6a)
1b179da01SKyle Evans /*-
2b179da01SKyle Evans  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
328f16a0fSKyle Evans  *
428f16a0fSKyle Evans  * Copyright (c) 2017 Kyle J. Kneitinger <kyle@kneit.in>
528f16a0fSKyle Evans  * All rights reserved.
628f16a0fSKyle Evans  *
728f16a0fSKyle Evans  * Redistribution and use in source and binary forms, with or without
828f16a0fSKyle Evans  * modification, are permitted provided that the following conditions
928f16a0fSKyle Evans  * are met:
1028f16a0fSKyle Evans  * 1. Redistributions of source code must retain the above copyright
1128f16a0fSKyle Evans  *    notice, this list of conditions and the following disclaimer.
1228f16a0fSKyle Evans  * 2. Redistributions in binary form must reproduce the above copyright
1328f16a0fSKyle Evans  *    notice, this list of conditions and the following disclaimer in the
1428f16a0fSKyle Evans  *    documentation and/or other materials provided with the distribution.
1528f16a0fSKyle Evans  *
1628f16a0fSKyle Evans  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
1728f16a0fSKyle Evans  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1828f16a0fSKyle Evans  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1928f16a0fSKyle Evans  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
2028f16a0fSKyle Evans  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2128f16a0fSKyle Evans  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2228f16a0fSKyle Evans  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2328f16a0fSKyle Evans  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2428f16a0fSKyle Evans  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2528f16a0fSKyle Evans  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2628f16a0fSKyle Evans  * SUCH DAMAGE.
27b6e7c421SKyle Evans  *
28b6e7c421SKyle Evans  * $FreeBSD$
2928f16a0fSKyle Evans  */
3028f16a0fSKyle Evans 
3128f16a0fSKyle Evans #ifndef _LIBBE_IMPL_H
3228f16a0fSKyle Evans #define _LIBBE_IMPL_H
3328f16a0fSKyle Evans 
3428f16a0fSKyle Evans #include <libzfs.h>
3528f16a0fSKyle Evans 
3628f16a0fSKyle Evans #include "be.h"
3728f16a0fSKyle Evans 
3828f16a0fSKyle Evans struct libbe_handle {
3955b0e92bSKyle Evans 	char root[BE_MAXPATHLEN];
4055b0e92bSKyle Evans 	char rootfs[BE_MAXPATHLEN];
4155b0e92bSKyle Evans 	char bootfs[BE_MAXPATHLEN];
42fc13fc1cSKyle Evans 	size_t altroot_len;
43fc13fc1cSKyle Evans 	zpool_handle_t *active_phandle;
44fc13fc1cSKyle Evans 	libzfs_handle_t *lzh;
4528f16a0fSKyle Evans 	be_error_t error;
4628f16a0fSKyle Evans 	bool print_on_err;
4728f16a0fSKyle Evans };
4828f16a0fSKyle Evans 
4928f16a0fSKyle Evans struct libbe_deep_clone {
5028f16a0fSKyle Evans 	libbe_handle_t *lbh;
51b29bf2f8SKyle Evans 	const char *bename;
52b29bf2f8SKyle Evans 	const char *snapname;
53*fa30d9edSKyle Evans 	int depth;
54*fa30d9edSKyle Evans 	int depth_limit;
5528f16a0fSKyle Evans };
5628f16a0fSKyle Evans 
5728f16a0fSKyle Evans struct libbe_dccb {
58fc13fc1cSKyle Evans 	libbe_handle_t *lbh;
5928f16a0fSKyle Evans 	zfs_handle_t *zhp;
6028f16a0fSKyle Evans 	nvlist_t *props;
6128f16a0fSKyle Evans };
6228f16a0fSKyle Evans 
63843e39ceSKyle Evans typedef struct prop_data {
64843e39ceSKyle Evans 	nvlist_t *list;
65843e39ceSKyle Evans 	libbe_handle_t *lbh;
664146029bSKyle Evans 	bool single_object;	/* list will contain props directly */
67843e39ceSKyle Evans } prop_data_t;
68843e39ceSKyle Evans 
69843e39ceSKyle Evans int prop_list_builder_cb(zfs_handle_t *, void *);
705468566eSKyle Evans int be_proplist_update(prop_data_t *);
71843e39ceSKyle Evans 
72fc13fc1cSKyle Evans char *be_mountpoint_augmented(libbe_handle_t *lbh, char *mountpoint);
73fc13fc1cSKyle Evans 
7420b7b8d8SKyle Evans /* Clobbers any previous errors */
7528f16a0fSKyle Evans int set_error(libbe_handle_t *, be_error_t);
7628f16a0fSKyle Evans 
7728f16a0fSKyle Evans #endif  /* _LIBBE_IMPL_H */
78