/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright (c) 2004, 2012, Oracle and/or its affiliates. All rights reserved.
*/
/*
* Module: zones.c
* Group: libinstzones
* Description: Provide "zones" interface for libbe. No new consumers shall
* be added - rather they should use zoneadm(1M) or libzonecfg
* interfaces.
*
* Public Methods:
* z_free_zone_list - free contents of zoneList_t object
* z_get_nonglobal_zone_list_by_brand - return zoneList_t object describing
* all non-global zones matching the list of zone brands passed in.
* z_free_brand_list - free contents of a zoneBrandList_t object
* z_make_brand_list - return a zoneBrandList_t object describing the list
* of all zone brands passed in.
* z_get_zonename - return the name of the current zone
* z_global_only - Determine if the global zone is only zone on the spec list
* z_lock_this_zone - lock this zone
* z_running_in_global_zone - Determine if running in the "global" zone
* z_set_output_functions - Link program specific output functions
* z_set_zone_root - Set root for zones library operations
* z_set_zone_spec - Set list of zones on which actions will be performed
* z_unlock_this_zone - unlock this zone
* z_verify_zone_spec - Verify list of zones on which actions will be performed
* z_zlist_get_current_state - Determine the current kernel state of the
* specified zone
* z_zlist_get_zonename - Determine name of specified zone
* z_zones_are_implemented - Determine if any zone operations can be performed
* z_is_zone_brand_in_list - determine if the zone's brand matches the
* brand list passed in.
* z_brands_are_implemented - determine if branded zones are implemented on
* this system
*/
/*
* System includes
*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <ctype.h>
#include <sys/types.h>
#include <sys/param.h>
#include <sys/sysmacros.h>
#include <string.h>
#include <strings.h>
#include <sys/stat.h>
#include <stdarg.h>
#include <limits.h>
#include <errno.h>
#include <time.h>
#include <signal.h>
#include <stropts.h>
#include <wait.h>
#include <zone.h>
#include <sys/brand.h>
#include <libintl.h>
#include <locale.h>
#include <libzonecfg.h>
#include <libcontract.h>
#include <sys/contract/process.h>
#include <sys/ctfs.h>
#include <assert.h>
#include <dlfcn.h>
#include <link.h>
#include <time.h>
/*
* local includes
*/
/*
* When _INSTZONES_LIB_Z_DEFINE_GLOBAL_DATA is defined,
* instzones_lib.h will define the z_global_data structure.
* Otherwise an extern to the structure is inserted.
*/
#define _INSTZONES_LIB_Z_DEFINE_GLOBAL_DATA
#include "instzones_lib.h"
#include "zones_strings.h"
/*
* Private structures
*/
#define CLUSTER_BRAND_NAME "cluster"
/* maximum number of arguments to exec() call */
#define UUID_FORMAT "%02d%02d%02d%03d-%02d%02d%02d%d-%016llx"
/*
* Library Function Prototypes
*/
#define streq(a, b) (strcmp((a), (b)) == 0)
/*
* Local Function Prototypes
*/
/*
* global internal (private) declarations
*/
/*
* *****************************************************************************
* global external (public) functions
* *****************************************************************************
*/
/*
* Name: z_brands_are_implemented
* Description: Determine if any branded zones may be present
* Arguments: void
* Returns: boolean_t
* == B_TRUE - branded zones are supported
* == B_FALSE - branded zones are not supported
*/
boolean_t
z_brands_are_implemented(void)
{
static boolean_t _brandsImplementedDetermined = B_FALSE;
static boolean_t _brandsAreImplemented = B_FALSE;
/* if availability has not been determined, cache it now */
if (!_brandsImplementedDetermined) {
_brandsImplementedDetermined = B_TRUE;
_brandsAreImplemented = _z_brands_are_implemented();
if (_brandsAreImplemented) {
_z_echoDebug(DBG_BRANDS_ARE_IMPLEMENTED);
} else {
_z_echoDebug(DBG_BRANDS_NOT_IMPLEMENTED);
}
}
/* return cached answer */
return (_brandsAreImplemented);
}
/*
* Name: z_free_zone_list
* Description: free contents of zoneList_t object
* Arguments: a_zlst - handle to zoneList_t object to free
* Returns: void
*/
void
z_free_zone_list(zoneList_t a_zlst)
{
int numzones;
/* ignore empty list */
if (a_zlst == (zoneList_t)NULL) {
return;
}
/* free each entry in the zone list */
for (numzones = 0; a_zlst[numzones]._zlName != (char *)NULL;
numzones++) {
zoneListElement_t *zelm = &a_zlst[numzones];
/* free zone name string */
free(zelm->_zlName);
/* free zonepath string */
if (zelm->_zlPath != (char *)NULL) {
free(zelm->_zlPath);
}
}
/* free handle to the list */
free(a_zlst);
}
/*
* Name: z_free_brand_list
* Description: Free contents of zoneBrandList_t object
* Arguments: brands - pointer to zoneBrandList_t object to free
* Returns: void
*/
void
z_free_brand_list(zoneBrandList_t *brands)
{
while (brands != NULL) {
zoneBrandList_t *temp = brands;
free(brands->string_ptr);
brands = brands->next;
free(temp);
}
}
/*
* Name: z_make_brand_list
* Description: Given a string with a list of brand name delimited by
* the delimeter passed in, build a zoneBrandList_t structure
* with the list of brand names and return it to the caller.
* Arguments:
* brands - const char pointer to string list of brand names
* delim - const char pointer to string representing the
* delimeter for brands string.
* Returns: zoneBrandList_t *
* == NULL - error, list could not be generated
* != NULL - success, list returned
* NOTE: Any zoneBrandList_t returned is placed in new storage for the
* calling function. The caller must use 'z_free_brand_list' to
* dispose of the storage once the list is no longer needed.
*/
zoneBrandList_t *
z_make_brand_list(const char *brands, const char *delim)
{
zoneBrandList_t *brand = NULL, *head = NULL;
char *blist = NULL;
char *str = NULL;
if ((blist = strdup(brands)) == NULL)
return (NULL);
if ((str = strtok(blist, delim)) != NULL) {
if ((brand = (zoneBrandList_t *)
malloc(sizeof (struct _zoneBrandList))) == NULL) {
return (NULL);
}
head = brand;
brand->string_ptr = strdup(str);
brand->next = NULL;
while ((str = strtok(NULL, delim)) != NULL) {
if ((brand->next = (zoneBrandList_t *)
malloc(sizeof (struct _zoneBrandList))) == NULL) {
return (NULL);
}
brand = brand->next;
brand->string_ptr = strdup(str);
brand->next = NULL;
}
}
free(blist);
return (head);
}
/*
* Name: z_get_nonglobal_zone_list_by_brand
* Description: return zoneList_t object describing all non-global
* zones matching the list of brands passed in.
* Arguments: brands - The list of zone brands to look for.
* Returns: zoneList_t
* == NULL - error, list could not be generated
* != NULL - success, list returned
* NOTE: Any zoneList_t returned is placed in new storage for the
* calling function. The caller must use 'z_free_zone_list' to
* dispose of the storage once the list is no longer needed.
*/
zoneList_t
z_get_nonglobal_zone_list_by_brand(zoneBrandList_t *brands)
{
FILE *zoneIndexFP;
int numzones = 0;
struct zoneent *ze;
zoneList_t zlst = NULL;
FILE *mapFP;
char zonename[ZONENAME_MAX];
zone_spec_t *zent;
/* if zones are not implemented, return empty list */
if (!z_zones_are_implemented()) {
return ((zoneList_t)NULL);
}
/*
* Open the zone index file. Note that getzoneent_private() handles
* NULL.
*/
zoneIndexFP = setzoneent();
mapFP = zonecfg_open_scratch("", B_FALSE);
/* index file open; scan all zones; see if any are at least installed */
while ((ze = getzoneent_private(zoneIndexFP)) != NULL) {
/* skip the global zone */
if (strcmp(ze->zone_name, GLOBAL_ZONENAME) == 0) {
free(ze);
continue;
}
/*
* skip any zones with brands not on the brand list
*/
if (!z_is_zone_brand_in_list(ze->zone_name, brands)) {
free(ze);
continue;
}
/*
* If the user specified an explicit zone list, then ignore any
* zones that aren't on that list.
*/
if ((zent = _z_global_data._zone_spec) != NULL) {
while (zent != NULL) {
if (strcmp(zent->zl_name, ze->zone_name) == 0)
break;
zent = zent->zl_next;
}
if (zent == NULL) {
free(ze);
continue;
}
}
/* non-global zone: create entry for this zone */
if (numzones == 0) {
zlst = (zoneList_t)_z_calloc(
sizeof (zoneListElement_t)*2);
} else {
zlst = (zoneList_t)_z_realloc(zlst,
sizeof (zoneListElement_t)*(numzones+2));
(void) memset(&zlst[numzones], 0L,
sizeof (zoneListElement_t)*2);
}
/*
* remember the zone name, zonepath and the current
* zone state of the zone.
*/
zlst[numzones]._zlName = _z_strdup(ze->zone_name);
zlst[numzones]._zlPath = _z_strdup(ze->zone_path);
zlst[numzones]._zlState = ze->zone_state;
/*
* For a scratch zone, we need to know the kernel zone name.
*/
if (zonecfg_in_alt_root() && mapFP != NULL &&
zonecfg_find_scratch(mapFP, ze->zone_name,
zonecfg_get_root(), zonename, sizeof (zonename)) != -1) {
free(zlst[numzones]._zlScratchName);
zlst[numzones]._zlScratchName = _z_strdup(zonename);
}
numzones++;
free(ze);
}
/* close the index file */
endzoneent(zoneIndexFP);
if (mapFP != NULL)
zonecfg_close_scratch(mapFP);
/* return generated list */
return (zlst);
}
/*
* Name: z_get_zonename
* Description: return the name of the current zone
* Arguments: void
* Returns: char *
* - pointer to string representing the name of the current
* zone
* NOTE: Any string returned is placed in new storage for the
* calling function. The caller must use 'Free' to dispose
* of the storage once the string is no longer needed.
*/
char *
z_get_zonename(void)
{
ssize_t zonenameLen;
char zonename[ZONENAME_MAX];
zoneid_t zoneid = (zoneid_t)-1;
/* if zones are not implemented, return "" */
if (!z_zones_are_implemented()) {
return (_z_strdup(""));
}
/* get the zone i.d. of the current zone */
zoneid = getzoneid();
/* get the name of the current zone */
zonenameLen = getzonenamebyid(zoneid, zonename, sizeof (zonename));
/* return "" if could not get zonename */
if (zonenameLen < 1) {
return (_z_strdup(""));
}
return (_z_strdup(zonename));
}
/*
* Name: z_global_only
* Description: Determine if the global zone is only zone on the spec list.
* Arguments: None
* Returns: B_TRUE if global zone is the only zone on the list,
* B_FALSE otherwise.
*/
boolean_t
z_global_only(void)
{
/* return true if zones are not implemented - treate as global zone */
if (!z_zones_are_implemented()) {
return (B_TRUE);
}
/* return true if this is the global zone */
if (_z_global_data._zone_spec != NULL &&
_z_global_data._zone_spec->zl_next == NULL &&
strcmp(_z_global_data._zone_spec->zl_name, GLOBAL_ZONENAME) == 0) {
return (B_TRUE);
}
/* return false - not the global zone */
return (B_FALSE);
}
/*
* Name: z_lock_this_zone
* Description: lock this zone
* Arguments: a_lflags - [RO, *RO] - (ZLOCKS_T)
* Flags indicating which locks to acquire
* Returns: boolean_t
* == B_TRUE - success specified locks acquired
* == B_FALSE - failure specified locks not acquired
* NOTE: the lock objects for "this zone" are maintained internally.
*/
boolean_t
z_lock_this_zone(ZLOCKS_T a_lflags)
{
boolean_t b;
char *zoneName;
pid_t pid = (pid_t)0;
/* entry assertions */
assert(a_lflags != ZLOCKS_NONE);
/* entry debugging info */
_z_echoDebug(DBG_ZONES_LCK_THIS, a_lflags);
zoneName = z_get_zonename();
pid = getpid();
/* lock package administration always */
if (a_lflags & ZLOCKS_PKG_ADMIN) {
b = _z_lock_zone_object(&_z_global_data._z_ObjectLocks,
zoneName, LOBJ_PKGADMIN, pid,
MSG_ZONES_LCK_THIS_PKGADM,
ERR_ZONES_LCK_THIS_PKGADM);
if (!b) {
(void) z_unlock_this_zone(a_lflags);
(void) free(zoneName);
return (B_FALSE);
}
}
(void) free(zoneName);
return (B_TRUE);
}
/*
* Name: z_running_in_global_zone
* Description: Determine if running in the "global" zone
* Arguments: void
* Returns: boolean_t
* == B_TRUE - running in global zone
* == B_FALSE - not running in global zone
*/
boolean_t
z_running_in_global_zone(void)
{
static boolean_t _zoneIdDetermined = B_FALSE;
static boolean_t _zoneIsGlobal = B_FALSE;
/* if ID has not been determined, cache it now */
if (!_zoneIdDetermined) {
_zoneIdDetermined = B_TRUE;
_zoneIsGlobal = _z_running_in_global_zone();
}
return (_zoneIsGlobal);
}
/*
* Name: z_set_output_functions
* Description: Link program specific output functions to this library.
* Arguments: a_echo_fcn - (_z_printf_fcn_t)
* Function to call to cause "normal operation" messages
* to be output/displayed
* a_echo_debug_fcn - (_z_printf_fcn_t)
* Function to call to cause "debugging" messages
* to be output/displayed
* a_progerr_fcn - (_z_printf_fcn_t)
* Function to call to cause "program error" messages
* to be output/displayed
* Returns: void
* NOTE: If NULL is specified for any function, then the functionality
* associated with that function is disabled.
* NOTE: The function pointers provided must call a function that
* takes two arguments:
* function(char *format, char *message)
* Any registered function will be called like:
* function("%s", "message")
*/
void
z_set_output_functions(_z_printf_fcn_t a_echo_fcn,
_z_printf_fcn_t a_echo_debug_fcn,
_z_printf_fcn_t a_progerr_fcn)
{
_z_global_data._z_echo = a_echo_fcn;
_z_global_data._z_echo_debug = a_echo_debug_fcn;
_z_global_data._z_progerr = a_progerr_fcn;
}
/*
* Name: z_set_zone_root
* Description: Set root for zones library operations
* Arguments: Path to root of boot environment containing zone; must be
* absolute.
* Returns: None.
* NOTE: Must be called before performing any zone-related operations.
* (Currently called directly by set_inst_root() during -R
* argument handling.)
*/
void
z_set_zone_root(const char *zroot)
{
char *rootdir;
/* if zones are not implemented, just return */
if (!z_zones_are_implemented())
return;
/* entry assertions */
assert(zroot != NULL);
rootdir = _z_strdup((char *)zroot);
z_canoninplace(rootdir);
if (strcmp(rootdir, "/") == 0) {
rootdir[0] = '\0';
}
/* free any existing cached root path */
if (*_z_global_data._z_root_dir != '\0') {
free(_z_global_data._z_root_dir);
_z_global_data._z_root_dir = NULL;
}
/* store duplicate of new zone root path */
if (*rootdir != '\0') {
_z_global_data._z_root_dir = _z_strdup(rootdir);
} else {
_z_global_data._z_root_dir = "";
}
/* set zone root path */
zonecfg_set_root(rootdir);
free(rootdir);
}
/*
* Name: z_set_zone_spec
* Description: Set list of zones on which actions will be performed.
* Arguments: Whitespace-separated list of zone names.
* Returns: 0 on success, -1 on error.
* NOTES: Will call _z_program_error if argument can't be parsed or
* memory not available.
*/
int
z_set_zone_spec(const char *zlist)
{
const char *zend;
ptrdiff_t zlen;
zone_spec_t *zent;
zone_spec_t *zhead;
zone_spec_t **znextp = &zhead;
/* entry assertions */
assert(zlist != NULL);
/* parse list to zone_spec_t list, store in global data */
for (;;) {
while (isspace(*zlist)) {
zlist++;
}
if (*zlist == '\0') {
break;
}
for (zend = zlist; *zend != '\0'; zend++) {
if (isspace(*zend)) {
break;
}
}
zlen = ((ptrdiff_t)zend) - ((ptrdiff_t)zlist);
if (zlen >= ZONENAME_MAX) {
_z_program_error(ERR_ZONE_NAME_ILLEGAL, zlen, zlist);
return (-1);
}
zent = _z_malloc(sizeof (*zent));
(void) memcpy(zent->zl_name, zlist, zlen);
zent->zl_name[zlen] = '\0';
zent->zl_used = B_FALSE;
*znextp = zent;
znextp = &zent->zl_next;
zlist = zend;
}
*znextp = NULL;
if (zhead == NULL) {
_z_program_error(ERR_ZONE_LIST_EMPTY);
return (-1);
}
_z_global_data._zone_spec = zhead;
return (0);
}
/*
* Name: z_unlock_this_zone
* Description: unlock this zone
* Arguments: a_lflags - [RO, *RO] - (ZLOCKS_T)
* Flags indicating which locks to release
* Returns: boolean_t
* == B_TRUE - success specified locks released
* == B_FALSE - failure specified locks may not be released
* NOTE: the lock objects for "this zone" are maintained internally.
*/
boolean_t
z_unlock_this_zone(ZLOCKS_T a_lflags)
{
boolean_t b;
boolean_t errors = B_FALSE;
char *zoneName;
/* entry assertions */
assert(a_lflags != ZLOCKS_NONE);
/* entry debugging info */
_z_echoDebug(DBG_ZONES_ULK_THIS, a_lflags);
/* return if no objects locked */
if ((_z_global_data._z_ObjectLocks == (char *)NULL) ||
(*_z_global_data._z_ObjectLocks == '\0')) {
return (B_TRUE);
}
zoneName = z_get_zonename();
/* unlock package administration */
if (a_lflags & ZLOCKS_PKG_ADMIN) {
b = _z_unlock_zone_object(&_z_global_data._z_ObjectLocks,
zoneName, LOBJ_PKGADMIN, ERR_ZONES_ULK_THIS_PACKAGE);
if (!b) {
errors = B_TRUE;
}
}
(void) free(zoneName);
return (!errors);
}
/*
* Name: z_verify_zone_spec
* Description: Verify list of zones on which actions will be performed.
* Arguments: None.
* Returns: 0 on success, -1 on error.
* NOTES: Will call _z_program_error if there are zones on the specified
* list that don't exist on the system. Requires that
* z_set_zone_root is called first (if it is called at all).
*/
int
z_verify_zone_spec(void)
{
FILE *zoneIndexFP;
boolean_t errors;
char zoneIndexPath[MAXPATHLEN];
struct zoneent *ze;
zone_spec_t *zent;
if (!z_zones_are_implemented()) {
_z_program_error(ERR_ZONES_NOT_IMPLEMENTED);
return (-1);
}
zoneIndexFP = setzoneent();
if (zoneIndexFP == NULL) {
_z_program_error(ERR_ZONEINDEX_OPEN, zoneIndexPath,
strerror(errno));
return (-1);
}
while ((ze = getzoneent_private(zoneIndexFP)) != NULL) {
for (zent = _z_global_data._zone_spec;
zent != NULL; zent = zent->zl_next) {
if (strcmp(zent->zl_name, ze->zone_name) == 0) {
zent->zl_used = B_TRUE;
break;
}
}
free(ze);
}
endzoneent(zoneIndexFP);
errors = B_FALSE;
for (zent = _z_global_data._zone_spec;
zent != NULL; zent = zent->zl_next) {
if (!zent->zl_used) {
_z_program_error(ERR_ZONE_NONEXISTENT, zent->zl_name);
errors = B_TRUE;
}
}
return (errors ? -1 : 0);
}
/*
* Name: z_is_zone_brand_in_list
* Description: Determine whether zone's brand has a match in the list
* brands passed in.
* Arguments: zoneName - name of the zone to check for branding
* list - list of brands to check the zone against
* Returns: boolean_t
* == B_TRUE - zone has a matching brand
* == B_FALSE - zone brand is not in list
*/
boolean_t
z_is_zone_brand_in_list(char *zoneName, zoneBrandList_t *list)
{
char brandname[MAXNAMELEN];
int err;
zoneBrandList_t *sp;
if (zoneName == NULL || list == NULL)
return (B_FALSE);
/* if zones are not implemented, return FALSE */
if (!z_zones_are_implemented()) {
return (B_FALSE);
}
/* if brands are not implemented, return FALSE */
if (!z_brands_are_implemented()) {
return (B_FALSE);
}
err = zone_get_brand(zoneName, brandname, sizeof (brandname));
if (err != Z_OK) {
_z_program_error(ERR_BRAND_GETBRAND, zonecfg_strerror(err));
return (B_FALSE);
}
for (sp = list; sp != NULL; sp = sp->next) {
if (sp->string_ptr != NULL &&
strcmp(sp->string_ptr, brandname) == 0) {
return (B_TRUE);
}
}
return (B_FALSE);
}
/*
* Name: z_zlist_get_current_state
* Description: Determine the current kernel state of the specified zone
* Arguments: a_zlst - handle to zoneList_t object describing all zones
* a_zoneIndex - index into a_zlst of the zone to return
* Returns: zone_state_t
* The current state of the specified zone is returned
*/
zone_state_t
z_zlist_get_current_state(zoneList_t a_zlst, int a_zoneIndex)
{
int i;
/* ignore empty list */
if (a_zlst == (zoneList_t)NULL) {
return (ZONE_STATE_INCOMPLETE);
}
/* find the specified zone in the list */
for (i = 0; (i != a_zoneIndex) &&
(a_zlst[i]._zlName != (char *)NULL); i++)
;
/* return error if the specified zone does not exist */
if (a_zlst[i]._zlName == (char *)NULL) {
return (ZONE_STATE_INCOMPLETE);
}
/* return selected zone's current kernel state */
_z_echoDebug(DBG_ZONES_GET_ZONE_STATE,
a_zlst[i]._zlName ? a_zlst[i]._zlName : "",
a_zlst[i]._zlState);
return (a_zlst[i]._zlState);
}
/*
* Name: z_zlist_get_zonename
* Description: Determine name of specified zone
* Arguments: a_zlst - handle to zoneList_t object describing all zones
* a_zoneIndex - index into a_zlst of the zone to return the
* Return: char *
* == NULL - zone name could not be determined
* != NULL - pointer to string representing zone name
* NOTE: Any zoneList_t returned is placed in static storage that must
* NEVER be free()ed by the caller.
*/
char *
z_zlist_get_zonename(zoneList_t a_zlst, int a_zoneIndex)
{
int i;
/* ignore empty list */
if (a_zlst == (zoneList_t)NULL) {
return ((char *)NULL);
}
/* find the specified zone in the list */
for (i = 0; (i != a_zoneIndex) &&
(a_zlst[i]._zlName != (char *)NULL); i++)
;
/* return error if the specified zone does not exist */
if (a_zlst[i]._zlName == (char *)NULL) {
return (NULL);
}
/* return selected zone's name */
return (a_zlst[i]._zlName);
}
/*
* Name: z_zlist_get_zonepath
* Description: Determine zonepath of specified zone
* Arguments: a_zlst - handle to zoneList_t object describing all zones
* a_zoneIndex - index into a_zlst of the zone to return
* Return: char *
* == NULL - zonepath could not be determined
* != NULL - pointer to string representing zonepath
* NOTE: Any zoneList_t returned is placed in static storage that must
* NEVER be free()ed by the caller.
*/
char *
z_zlist_get_zonepath(zoneList_t a_zlst, int a_zoneIndex)
{
int i;
/* ignore empty list */
if (a_zlst == (zoneList_t)NULL) {
return ((char *)NULL);
}
/* find the specified zone in the list */
for (i = 0; (i != a_zoneIndex) &&
(a_zlst[i]._zlName != (char *)NULL); i++)
;
/* return error if the specified zone does not exist */
if (a_zlst[i]._zlName == (char *)NULL) {
return (NULL);
}
/* return selected zone's zonepath */
return (a_zlst[i]._zlPath);
}
/*
* Name: z_zones_are_implemented
* Description: Determine if any zone operations can be performed
* Arguments: void
* Returns: boolean_t
* == B_TRUE - zone operations are available
* == B_FALSE - no zone operations can be done
*/
boolean_t
z_zones_are_implemented(void)
{
static boolean_t _zonesImplementedDetermined = B_FALSE;
static boolean_t _zonesAreImplemented = B_FALSE;
/* if availability has not been determined, cache it now */
if (!_zonesImplementedDetermined) {
_zonesImplementedDetermined = B_TRUE;
_zonesAreImplemented = _z_zones_are_implemented();
if (!_zonesAreImplemented) {
_z_echoDebug(DBG_ZONES_NOT_IMPLEMENTED);
} else {
_z_echoDebug(DBG_ZONES_ARE_IMPLEMENTED);
}
}
return (_zonesAreImplemented);
}