2N/A/*
2N/A * CDDL HEADER START
2N/A *
2N/A * The contents of this file are subject to the terms of the
2N/A * Common Development and Distribution License (the "License").
2N/A * You may not use this file except in compliance with the License.
2N/A *
2N/A * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
2N/A * or http://www.opensolaris.org/os/licensing.
2N/A * See the License for the specific language governing permissions
2N/A * and limitations under the License.
2N/A *
2N/A * When distributing Covered Code, include this CDDL HEADER in each
2N/A * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
2N/A * If applicable, add the following below this CDDL HEADER, with the
2N/A * fields enclosed by brackets "[]" replaced with your own identifying
2N/A * information: Portions Copyright [yyyy] [name of copyright owner]
2N/A *
2N/A * CDDL HEADER END
2N/A */
2N/A
2N/A/*
2N/A * Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved.
2N/A */
2N/A
2N/A#ifndef _LIBBE_PRIV_H
2N/A#define _LIBBE_PRIV_H
2N/A
2N/A#include <libnvpair.h>
2N/A#include <libzfs.h>
2N/A#include <instzones_api.h>
2N/A
2N/A#ifdef __cplusplus
2N/Aextern "C" {
2N/A#endif
2N/A
2N/A#define ARCH_LENGTH MAXNAMELEN
2N/A#define BE_AUTO_NAME_MAX_TRY 3
2N/A#define BE_AUTO_NAME_DELIM '-'
2N/A#define BE_CONTAINER_DS_NAME "ROOT"
2N/A#define BE_ZONE_RPOOL_NAME "rpool"
2N/A#define BE_POLICY_PROPERTY "org.opensolaris.libbe:policy"
2N/A#define BE_UUID_PROPERTY "org.opensolaris.libbe:uuid"
2N/A#define BE_PLCY_STATIC "static"
2N/A#define BE_PLCY_VOLATILE "volatile"
2N/A
2N/A#define ZFS_CLOSE(_zhp) \
2N/A if (_zhp) { \
2N/A zfs_close(_zhp); \
2N/A _zhp = NULL; \
2N/A }
2N/A
2N/A#define BE_ZONE_PARENTBE_PROPERTY "org.opensolaris.libbe:parentbe"
2N/A#define BE_ZONE_ACTIVE_PROPERTY "org.opensolaris.libbe:active"
2N/A#define BE_ZONE_SUPPORTED_BRANDS "solaris labeled"
2N/A#define BE_ZONE_SUPPORTED_BRANDS_DELIM " "
2N/A
2N/A#define BE_NBE_HANDLE_PROPERTY "com.oracle.libbe:nbe_handle"
2N/A
2N/A/* Maximum length for the BE name. */
2N/A#define BE_NAME_MAX_LEN 64
2N/A
2N/A#define MAX(a, b) ((a) > (b) ? (a) : (b))
2N/A#define MIN(a, b) ((a) < (b) ? (a) : (b))
2N/A
2N/Atypedef struct be_transaction_data {
2N/A char *obe_name; /* Original BE name */
2N/A char *obe_root_ds; /* Original BE root dataset */
2N/A char *obe_zpool; /* Original BE pool */
2N/A char *obe_snap_name; /* Original BE snapshot name */
2N/A char *obe_altroot; /* Original BE altroot */
2N/A char *nbe_name; /* New BE name */
2N/A char *nbe_root_ds; /* New BE root dataset */
2N/A char *nbe_zpool; /* New BE pool */
2N/A char *nbe_desc; /* New BE description */
2N/A nvlist_t *nbe_zfs_props; /* New BE dataset properties */
2N/A char *policy; /* BE policy type */
2N/A char *zoneroot; /* zoneroot, relative to altroots */
2N/A} be_transaction_data_t;
2N/A
2N/Atypedef struct be_mount_data {
2N/A char *altroot; /* Location of where to mount BE */
2N/A boolean_t shared_fs; /* Mount shared file sytsems */
2N/A boolean_t shared_rw; /* Mount shared file systems rw */
2N/A} be_mount_data_t;
2N/A
2N/Atypedef struct be_unmount_data {
2N/A char *altroot; /* Location of where BE is mounted */
2N/A boolean_t force; /* Forcibly unmount */
2N/A} be_unmount_data_t;
2N/A
2N/Atypedef struct be_destroy_data {
2N/A boolean_t destroy_snaps; /* Destroy snapshots of BE */
2N/A boolean_t force_unmount; /* Forcibly unmount BE if mounted */
2N/A uuid_t gz_be_uuid; /* UUID of the global zone BE */
2N/A} be_destroy_data_t;
2N/A
2N/Atypedef struct be_demote_data {
2N/A zfs_handle_t *clone_zhp; /* clone dataset to promote */
2N/A time_t origin_creation; /* snapshot creation time of clone */
2N/A const char *snapshot; /* snapshot of dataset being demoted */
2N/A boolean_t find_in_BE; /* flag noting to find clone in BE */
2N/A} be_demote_data_t;
2N/A
2N/Atypedef struct be_fs_list_data {
2N/A char *altroot;
2N/A char **fs_list;
2N/A int fs_num;
2N/A} be_fs_list_data_t;
2N/A
2N/Atypedef struct be_plcy_list {
2N/A char *be_plcy_name;
2N/A int be_num_max;
2N/A int be_num_min;
2N/A time_t be_age_max;
2N/A int be_usage_pcnt;
2N/A struct be_plcy_list *be_next_plcy;
2N/A} be_plcy_list_t;
2N/A
2N/Atypedef struct rpool_data {
2N/A char **pool_list;
2N/A int pool_count;
2N/A} rpool_data_t;
2N/A
2N/A/* Library globals */
2N/Aextern libzfs_handle_t *g_zfs;
2N/Aextern boolean_t do_print;
2N/A
2N/A/* be_create.c */
2N/Aint be_set_uuid(char *);
2N/Aint be_get_uuid(const char *, uuid_t *);
2N/Aint be_find_zpool_by_bename(char *, char **, int *, char **);
2N/A
2N/A/* be_list.c */
2N/Aint _be_list(char *, be_node_list_t **);
2N/Aint be_get_zone_be_list(char *, char *, be_node_list_t **);
2N/A
2N/A/* be_mount.c */
2N/Aint _be_mount(char *, char *, char **, int);
2N/Aint _be_unmount(char *, char *, int);
2N/Aint be_tmp_mount_ds(zfs_handle_t *);
2N/Aint be_mount_zone_root(zfs_handle_t *, be_mount_data_t *);
2N/Aint be_unmount_zone_root(zfs_handle_t *, be_unmount_data_t *);
2N/Aint be_get_legacy_fs(char *, char *, char *, char *, be_fs_list_data_t *);
2N/Avoid be_free_fs_list(be_fs_list_data_t *);
2N/Achar *be_get_ds_from_dir(char *);
2N/Aint be_make_tmp_mountpoint(char **);
2N/A
2N/A/* be_snapshot.c */
2N/Aint _be_create_snapshot(char *, char *, char **, char *);
2N/Aint _be_destroy_snapshot(char *, char *);
2N/A
2N/A/* be_utils.c */
2N/Aboolean_t be_zfs_init(void);
2N/Avoid be_zfs_fini(void);
2N/Avoid be_make_root_ds(const char *, const char *, char *, int);
2N/Avoid be_make_nested_container_ds(const char *, char *, int);
2N/Avoid be_make_container_ds(const char *, char *, int);
2N/Achar *be_make_name_from_ds(const char *, char *);
2N/Aint be_run_cmd(char *, int *, char *, int, char *, int);
2N/Aint be_update_vfstab(char *, char *, char *, be_fs_list_data_t *, char *);
2N/Aint be_maxsize_avail(zfs_handle_t *, uint64_t *);
2N/Achar *be_auto_snap_name(void);
2N/Achar *be_auto_be_name(char *);
2N/Achar *be_auto_zone_be_name(char *, char *);
2N/Achar *be_default_policy(void);
2N/Aboolean_t valid_be_policy(char *);
2N/Aboolean_t be_valid_auto_snap_name(char *);
2N/Aboolean_t be_valid_be_name(const char *);
2N/Avoid be_print_err(char *, ...);
2N/Aint be_find_current_be(be_transaction_data_t *);
2N/Aint zfs_err_to_be_err(libzfs_handle_t *);
2N/Aint errno_to_be_err(int);
2N/Aint be_check_rozr(void);
2N/Aint be_find_root_pools(char ***, int *);
2N/A
2N/A/* be_activate.c */
2N/Aint _be_activate(char *);
2N/Aint _be_activate_bh(char *, char *, char *);
2N/Aint be_activate_current_be(void);
2N/Aboolean_t be_is_active_on_boot(char *);
2N/Aint _be_get_boot_device_list(char *, char ***, int *);
2N/A
2N/A/* be_zones.c */
2N/Avoid be_make_zoneroot(char *, char *, int);
2N/Aint be_find_active_zone_root(zfs_handle_t *, char *, char *, int);
2N/Aint be_find_mounted_zone_root(char *, char *, char *, int);
2N/Aboolean_t be_zone_supported(char *);
2N/AzoneBrandList_t *be_get_supported_brandlist(void);
2N/Aint be_zone_get_parent_id(const char *, uuid_t *);
2N/Aint be_zone_set_parent_id(const char *, uuid_t);
2N/Aint be_zone_toggle_active(char *root_ds);
2N/Aint be_zone_get_zpool_analog(char *p_analog);
2N/Aboolean_t be_zone_is_bootable(char *root_ds);
2N/Aboolean_t be_zone_is_active(zfs_handle_t *);
2N/A
2N/A/* callback functions */
2N/Aint be_exists_callback(zpool_handle_t *, void *);
2N/Aint be_find_zpool_callback(zpool_handle_t *, void *);
2N/Aint be_zpool_find_current_be_callback(zpool_handle_t *, void *);
2N/Aint be_zfs_find_current_be_callback(zfs_handle_t *, void *);
2N/Aint be_check_be_roots_callback(zpool_handle_t *, void *);
2N/A
2N/A#ifdef __cplusplus
2N/A}
2N/A#endif
2N/A
2N/A#endif /* _LIBBE_PRIV_H */