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_H
2N/A#define _LIBBE_H
2N/A
2N/A#include <libnvpair.h>
2N/A#include <uuid/uuid.h>
2N/A#include <libzfs.h>
2N/A
2N/A#ifdef __cplusplus
2N/Aextern "C" {
2N/A#endif
2N/A
2N/A#define BE_ATTR_ORIG_BE_NAME "orig_be_name"
2N/A#define BE_ATTR_ORIG_BE_POOL "orig_be_pool"
2N/A#define BE_ATTR_SNAP_NAME "snap_name"
2N/A
2N/A#define BE_ATTR_NEW_BE_NAME "new_be_name"
2N/A#define BE_ATTR_NEW_BE_POOL "new_be_pool"
2N/A#define BE_ATTR_NEW_BE_DESC "new_be_desc"
2N/A#define BE_ATTR_NEW_BE_NESTED_BE "new_be_nested_be"
2N/A#define BE_ATTR_NEW_BE_ALLOW_AUTO_NAMING "new_be_allow_auto_naming"
2N/A#define BE_ATTR_NEW_BE_PARENTBE "new_be_parentbe"
2N/A#define BE_ATTR_POLICY "policy"
2N/A#define BE_ATTR_ZFS_PROPERTIES "zfs_properties"
2N/A
2N/A#define BE_ATTR_FS_NAMES "fs_names"
2N/A#define BE_ATTR_FS_ZFS_PROPERTIES "fs_zfs_properties"
2N/A#define BE_ATTR_FS_NUM "fs_num"
2N/A#define BE_ATTR_SHARED_FS_NAMES "shared_fs_names"
2N/A#define BE_ATTR_SHARED_FS_ZFS_PROPERTIES "shared_fs_zfs_properties"
2N/A#define BE_ATTR_SHARED_FS_NUM "shared_fs_num"
2N/A
2N/A#define BE_ATTR_ALT_POOL "alt_pool"
2N/A#define BE_ATTR_MOUNTPOINT "mountpoint"
2N/A#define BE_ATTR_MOUNT_FLAGS "mount_flags"
2N/A#define BE_ATTR_UNMOUNT_FLAGS "unmount_flags"
2N/A#define BE_ATTR_DESTROY_FLAGS "destroy_flags"
2N/A#define BE_ATTR_ROOT_DS "root_ds"
2N/A#define BE_ATTR_UUID_STR "uuid_str"
2N/A
2N/A#define BE_ATTR_ACTIVE "active"
2N/A#define BE_ATTR_ACTIVE_ON_BOOT "active_boot"
2N/A#define BE_ATTR_ACTIVE_UNBOOTABLE "active_unbootable"
2N/A#define BE_ATTR_SPACE "space_used"
2N/A#define BE_ATTR_DATASET "dataset"
2N/A#define BE_ATTR_STATUS "status"
2N/A#define BE_ATTR_DATE "date"
2N/A#define BE_ATTR_MOUNTED "mounted"
2N/A
2N/A/*
2N/A * libbe error codes
2N/A *
2N/A * NOTE: there is a copy of this enum in beadm/messages.py. To keep these
2N/A * in sync please make sure to add any new error messages at the end
2N/A * of this enumeration.
2N/A */
2N/Aenum {
2N/A BE_SUCCESS = 0,
2N/A BE_ERR_ACCESS = 4000, /* permission denied */
2N/A BE_ERR_ACTIVATE_CURR, /* Activation of current BE failed */
2N/A BE_ERR_AUTONAME, /* auto naming failed */
2N/A BE_ERR_BE_NOENT, /* No such BE */
2N/A BE_ERR_BUSY, /* mount busy */
2N/A BE_ERR_CANCELED, /* operation canceled */
2N/A BE_ERR_CLONE, /* BE clone failed */
2N/A BE_ERR_COPY, /* BE copy failed */
2N/A BE_ERR_CREATDS, /* dataset creation failed */
2N/A BE_ERR_CURR_BE_NOT_FOUND, /* Can't find current BE */
2N/A BE_ERR_DESTROY, /* failed to destroy BE or snapshot */
2N/A BE_ERR_DEMOTE, /* BE demotion failed */
2N/A BE_ERR_DSTYPE, /* invalid dataset type */
2N/A BE_ERR_BE_EXISTS, /* BE exists */
2N/A BE_ERR_INIT, /* be_zfs_init failed */
2N/A BE_ERR_INTR, /* interrupted system call */
2N/A BE_ERR_INVAL, /* invalid argument */
2N/A BE_ERR_INVALPROP, /* invalid property for dataset */
2N/A BE_ERR_INVALMOUNTPOINT, /* Unexpected mountpoint */
2N/A BE_ERR_MOUNT, /* mount failed */
2N/A BE_ERR_MOUNTED, /* already mounted */
2N/A BE_ERR_NAMETOOLONG, /* name > BUFSIZ */
2N/A BE_ERR_NOENT, /* Doesn't exist */
2N/A BE_ERR_POOL_NOENT, /* No such pool */
2N/A BE_ERR_NODEV, /* No such device */
2N/A BE_ERR_NOTMOUNTED, /* File system not mounted */
2N/A BE_ERR_NOMEM, /* not enough memory */
2N/A BE_ERR_NONINHERIT, /* property is not inheritable for BE dataset */
2N/A BE_ERR_NXIO, /* No such device or address */
2N/A BE_ERR_NOSPC, /* No space on device */
2N/A BE_ERR_NOTSUP, /* Operation not supported */
2N/A BE_ERR_OPEN, /* open failed */
2N/A BE_ERR_PERM, /* Not owner */
2N/A BE_ERR_UNAVAIL, /* The BE is currently unavailable */
2N/A BE_ERR_PROMOTE, /* BE promotion failed */
2N/A BE_ERR_ROFS, /* read only file system */
2N/A BE_ERR_READONLYDS, /* read only dataset */
2N/A BE_ERR_READONLYPROP, /* read only property */
2N/A BE_ERR_SS_EXISTS, /* snapshot exists */
2N/A BE_ERR_SS_NOENT, /* No such snapshot */
2N/A BE_ERR_UMOUNT, /* unmount failed */
2N/A BE_ERR_UMOUNT_CURR_BE, /* Can't unmount current BE */
2N/A BE_ERR_UMOUNT_SHARED, /* unmount of shared File System failed */
2N/A BE_ERR_UNKNOWN, /* Unknown error */
2N/A BE_ERR_ZFS, /* ZFS returned an error */
2N/A BE_ERR_DESTROY_CURR_BE, /* Cannot destroy current BE */
2N/A BE_ERR_GEN_UUID, /* Failed to generate uuid */
2N/A BE_ERR_PARSE_UUID, /* Failed to parse uuid */
2N/A BE_ERR_NO_UUID, /* BE has no uuid */
2N/A BE_ERR_ZONE_NO_PARENTBE, /* Zone root dataset has no parent uuid */
2N/A BE_ERR_ZONE_MULTIPLE_ACTIVE, /* Zone has multiple active roots */
2N/A BE_ERR_ZONE_NO_ACTIVE_ROOT, /* Zone has no active root for this BE */
2N/A BE_ERR_ZONE_ROOT_NOT_SLASH, /* Zone root dataset mntpt is not / */
2N/A BE_ERR_NO_MOUNTED_ZONE, /* Zone not mounted in alternate BE */
2N/A BE_ERR_MOUNT_ZONEROOT, /* Failed to mount a zone root */
2N/A BE_ERR_UMOUNT_ZONEROOT, /* Failed to unmount a zone root */
2N/A BE_ERR_ZONES_UNMOUNT, /* Unable to unmount a zone. */
2N/A BE_ERR_FAULT, /* Bad Address */
2N/A BE_ERR_RENAME_ACTIVE, /* Renaming the active BE is not supported */
2N/A BE_ERR_DEV_BUSY, /* Device is Busy */
2N/A BE_ERR_ZONE_SS_EXISTS, /* zone snapshot already exists */
2N/A BE_ERR_PKG_VERSION, /* Package versioning error. */
2N/A BE_ERR_ADD_SPLASH_ICT, /* Add_splash_image ICT failed. */
2N/A BE_ERR_PKG, /* Error running pkg(1M). */
2N/A BE_ERR_BOOTFILE_INST, /* Error installing boot files. */
2N/A BE_ERR_EXTCMD, /* External command error */
2N/A BE_ERR_ZONE_NOTSUP, /* Operation not supported for zone BE */
2N/A BE_ERR_ZONE_MPOOL_NOTSUP, /* Operation not supported for zone BE */
2N/A BE_ERR_ZONE_RO_NOTSUP, /* Operation not supported in a R/O zone */
2N/A BE_ERR_NO_MENU_ENTRY, /* Menu entry can't be found */
2N/A BE_ERR_NESTED_PYTHON, /* Attempted to nest Python interpreters */
2N/A BE_ERR_PYTHON, /* Native Python library call failed */
2N/A BE_ERR_PYTHON_EXCEPT, /* Python code raised an exception */
2N/A BE_ERR_RENAME_ACTIVE_ON_BOOT, /* Can not rename active on boot BE */
2N/A BE_ERR_NO_RPOOLS /* No root pools could be found */
2N/A} be_errno_t;
2N/A
2N/A/*
2N/A * Data structures used to return the listing and information of BEs.
2N/A */
2N/Atypedef struct be_dataset_list {
2N/A uint64_t be_ds_space_used;
2N/A boolean_t be_ds_mounted;
2N/A char *be_dataset_name;
2N/A time_t be_ds_creation; /* Date/time stamp when created */
2N/A char *be_ds_mntpt;
2N/A char *be_ds_plcy_type; /* cleanup policy type */
2N/A struct be_dataset_list *be_next_dataset;
2N/A} be_dataset_list_t;
2N/A
2N/Atypedef struct be_snapshot_list {
2N/A uint64_t be_snapshot_space_used; /* bytes of disk space used */
2N/A char *be_snapshot_name;
2N/A time_t be_snapshot_creation; /* Date/time stamp when created */
2N/A char *be_snapshot_type; /* cleanup policy type */
2N/A struct be_snapshot_list *be_next_snapshot;
2N/A} be_snapshot_list_t;
2N/A
2N/Atypedef struct be_node_list {
2N/A boolean_t be_mounted; /* is BE currently mounted */
2N/A boolean_t be_active_on_boot; /* is this BE active on boot */
2N/A boolean_t be_active; /* is this BE active currently */
2N/A boolean_t be_active_unbootable; /* is this BE potentially bootable */
2N/A uint64_t be_space_used;
2N/A char *be_node_name;
2N/A char *be_rpool;
2N/A char *be_root_ds;
2N/A char *be_mntpt;
2N/A char *be_policy_type; /* cleanup policy type */
2N/A char *be_uuid_str; /* string representation of uuid */
2N/A time_t be_node_creation; /* Date/time stamp when created */
2N/A struct be_dataset_list *be_node_datasets;
2N/A uint_t be_node_num_datasets;
2N/A struct be_snapshot_list *be_node_snapshots;
2N/A uint_t be_node_num_snapshots;
2N/A struct be_node_list *be_next_node;
2N/A} be_node_list_t;
2N/A
2N/A/* Flags used with mounting a BE */
2N/A#define BE_MOUNT_FLAG_NULL 0x00000000
2N/A#define BE_MOUNT_FLAG_SHARED_FS 0x00000001
2N/A#define BE_MOUNT_FLAG_SHARED_RW 0x00000002
2N/A#define BE_MOUNT_FLAG_NO_ZONES 0x00000004
2N/A
2N/A/* Flags used with unmounting a BE */
2N/A#define BE_UNMOUNT_FLAG_NULL 0x00000000
2N/A#define BE_UNMOUNT_FLAG_FORCE 0x00000001
2N/A#define BE_UNMOUNT_FLAG_NO_ZONES 0x00000002
2N/A
2N/A/* Flags used with destroying a BE */
2N/A#define BE_DESTROY_FLAG_NULL 0x00000000
2N/A#define BE_DESTROY_FLAG_SNAPSHOTS 0x00000001
2N/A#define BE_DESTROY_FLAG_FORCE_UNMOUNT 0x00000002
2N/A
2N/A/*
2N/A * BE functions
2N/A */
2N/Aint be_init(nvlist_t *);
2N/Aint be_destroy(nvlist_t *);
2N/Aint be_copy(nvlist_t *);
2N/A
2N/Aint be_mount(nvlist_t *);
2N/Aint be_unmount(nvlist_t *);
2N/A
2N/Aint be_rename(nvlist_t *);
2N/A
2N/Aint be_activate(nvlist_t *);
2N/A
2N/Aint be_create_snapshot(nvlist_t *);
2N/Aint be_destroy_snapshot(nvlist_t *);
2N/Aint be_rollback(nvlist_t *);
2N/A
2N/A/*
2N/A * Functions for listing and getting information about existing BEs.
2N/A */
2N/Aint be_list(char *, be_node_list_t **);
2N/Avoid be_free_list(be_node_list_t *);
2N/Aint be_max_avail(char *, uint64_t *);
2N/Achar *be_err_to_str(int);
2N/A
2N/A/*
2N/A * Library functions
2N/A */
2N/Avoid libbe_print_errors(boolean_t);
2N/A
2N/A/*
2N/A * Consolidation Private helper function for utilities involved in fast reboot.
2N/A */
2N/Aint be_get_boot_args_and_mountpt(int, char *, size_t, char *, size_t);
2N/A
2N/A#ifdef __cplusplus
2N/A}
2N/A#endif
2N/A
2N/A#endif /* _LIBBE_H */