xref: /freebsd/lib/libbe/be_impl.h (revision 5086b6ec32d5c82c3d0894eb7bd74a9b81480644)
1b179da01SKyle Evans /*-
24d846d26SWarner Losh  * SPDX-License-Identifier: BSD-2-Clause
328f16a0fSKyle Evans  *
428f16a0fSKyle Evans  * Copyright (c) 2017 Kyle J. Kneitinger <kyle@kneit.in>
528f16a0fSKyle Evans  *
628f16a0fSKyle Evans  * Redistribution and use in source and binary forms, with or without
728f16a0fSKyle Evans  * modification, are permitted provided that the following conditions
828f16a0fSKyle Evans  * are met:
928f16a0fSKyle Evans  * 1. Redistributions of source code must retain the above copyright
1028f16a0fSKyle Evans  *    notice, this list of conditions and the following disclaimer.
1128f16a0fSKyle Evans  * 2. Redistributions in binary form must reproduce the above copyright
1228f16a0fSKyle Evans  *    notice, this list of conditions and the following disclaimer in the
1328f16a0fSKyle Evans  *    documentation and/or other materials provided with the distribution.
1428f16a0fSKyle Evans  *
1528f16a0fSKyle Evans  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
1628f16a0fSKyle Evans  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1728f16a0fSKyle Evans  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1828f16a0fSKyle Evans  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
1928f16a0fSKyle Evans  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2028f16a0fSKyle Evans  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2128f16a0fSKyle Evans  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2228f16a0fSKyle Evans  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2328f16a0fSKyle Evans  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2428f16a0fSKyle Evans  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2528f16a0fSKyle Evans  * SUCH DAMAGE.
2628f16a0fSKyle Evans  */
2728f16a0fSKyle Evans 
2828f16a0fSKyle Evans #ifndef _LIBBE_IMPL_H
2928f16a0fSKyle Evans #define _LIBBE_IMPL_H
3028f16a0fSKyle Evans 
3128f16a0fSKyle Evans #include <libzfs.h>
3228f16a0fSKyle Evans 
3328f16a0fSKyle Evans #include "be.h"
3428f16a0fSKyle Evans 
3528f16a0fSKyle Evans struct libbe_handle {
3655b0e92bSKyle Evans 	char root[BE_MAXPATHLEN];
3755b0e92bSKyle Evans 	char rootfs[BE_MAXPATHLEN];
3855b0e92bSKyle Evans 	char bootfs[BE_MAXPATHLEN];
39*5086b6ecSR. Christian McDonald 	char *bootonce;
40fc13fc1cSKyle Evans 	size_t altroot_len;
41fc13fc1cSKyle Evans 	zpool_handle_t *active_phandle;
42fc13fc1cSKyle Evans 	libzfs_handle_t *lzh;
4328f16a0fSKyle Evans 	be_error_t error;
4428f16a0fSKyle Evans 	bool print_on_err;
4528f16a0fSKyle Evans };
4628f16a0fSKyle Evans 
4728f16a0fSKyle Evans struct libbe_deep_clone {
4828f16a0fSKyle Evans 	libbe_handle_t *lbh;
49b29bf2f8SKyle Evans 	const char *bename;
50b29bf2f8SKyle Evans 	const char *snapname;
51fa30d9edSKyle Evans 	int depth;
52fa30d9edSKyle Evans 	int depth_limit;
5328f16a0fSKyle Evans };
5428f16a0fSKyle Evans 
5528f16a0fSKyle Evans struct libbe_dccb {
56fc13fc1cSKyle Evans 	libbe_handle_t *lbh;
5728f16a0fSKyle Evans 	zfs_handle_t *zhp;
5828f16a0fSKyle Evans 	nvlist_t *props;
5928f16a0fSKyle Evans };
6028f16a0fSKyle Evans 
61843e39ceSKyle Evans typedef struct prop_data {
62843e39ceSKyle Evans 	nvlist_t *list;
63843e39ceSKyle Evans 	libbe_handle_t *lbh;
644146029bSKyle Evans 	bool single_object;	/* list will contain props directly */
65e307eb94SToomas Soome 	char *bootonce;
66843e39ceSKyle Evans } prop_data_t;
67843e39ceSKyle Evans 
68843e39ceSKyle Evans int prop_list_builder_cb(zfs_handle_t *, void *);
695468566eSKyle Evans int be_proplist_update(prop_data_t *);
70843e39ceSKyle Evans 
71fc13fc1cSKyle Evans char *be_mountpoint_augmented(libbe_handle_t *lbh, char *mountpoint);
72fc13fc1cSKyle Evans 
7320b7b8d8SKyle Evans /* Clobbers any previous errors */
7428f16a0fSKyle Evans int set_error(libbe_handle_t *, be_error_t);
7528f16a0fSKyle Evans 
7628f16a0fSKyle Evans #endif  /* _LIBBE_IMPL_H */
77