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 * See the License for the specific language governing permissions 2N/A * and limitations under the License. 2N/A * When distributing Covered Code, include this CDDL HEADER in each 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 * Copyright (c) 2004, 2012, Oracle and/or its affiliates. All rights reserved. 2N/A * Group: libinstzones 2N/A * Description: Provide "zones" interface for libbe. No new consumers shall 2N/A * be added - rather they should use zoneadm(1M) or libzonecfg 2N/A * z_free_zone_list - free contents of zoneList_t object 2N/A * z_get_nonglobal_zone_list_by_brand - return zoneList_t object describing 2N/A * all non-global zones matching the list of zone brands passed in. 2N/A * z_free_brand_list - free contents of a zoneBrandList_t object 2N/A * z_make_brand_list - return a zoneBrandList_t object describing the list 2N/A * of all zone brands passed in. 2N/A * z_get_zonename - return the name of the current zone 2N/A * z_global_only - Determine if the global zone is only zone on the spec list 2N/A * z_lock_this_zone - lock this zone 2N/A * z_running_in_global_zone - Determine if running in the "global" zone 2N/A * z_set_output_functions - Link program specific output functions 2N/A * z_set_zone_root - Set root for zones library operations 2N/A * z_set_zone_spec - Set list of zones on which actions will be performed 2N/A * z_unlock_this_zone - unlock this zone 2N/A * z_verify_zone_spec - Verify list of zones on which actions will be performed 2N/A * z_zlist_get_current_state - Determine the current kernel state of the 2N/A * z_zlist_get_zonename - Determine name of specified zone 2N/A * z_zones_are_implemented - Determine if any zone operations can be performed 2N/A * z_is_zone_brand_in_list - determine if the zone's brand matches the 2N/A * brand list passed in. 2N/A * z_brands_are_implemented - determine if branded zones are implemented on 2N/A * When _INSTZONES_LIB_Z_DEFINE_GLOBAL_DATA is defined, 2N/A * Otherwise an extern to the structure is inserted. 2N/A * Private structures 2N/A/* maximum number of arguments to exec() call */ 2N/A * Library Function Prototypes 2N/A * Local Function Prototypes 2N/A * global internal (private) declarations 2N/A * ***************************************************************************** 2N/A * global external (public) functions 2N/A * ***************************************************************************** 2N/A * Name: z_brands_are_implemented 2N/A * Description: Determine if any branded zones may be present 2N/A * Returns: boolean_t 2N/A * == B_TRUE - branded zones are supported 2N/A * == B_FALSE - branded zones are not supported 2N/A /* if availability has not been determined, cache it now */ 2N/A /* return cached answer */ 2N/A * Name: z_free_zone_list 2N/A * Description: free contents of zoneList_t object 2N/A * Arguments: a_zlst - handle to zoneList_t object to free 2N/A /* ignore empty list */ 2N/A /* free each entry in the zone list */ 2N/A /* free zone name string */ 2N/A /* free zonepath string */ 2N/A /* free handle to the list */ 2N/A * Name: z_free_brand_list 2N/A * Description: Free contents of zoneBrandList_t object 2N/A * Arguments: brands - pointer to zoneBrandList_t object to free 2N/A * Name: z_make_brand_list 2N/A * Description: Given a string with a list of brand name delimited by 2N/A * the delimeter passed in, build a zoneBrandList_t structure 2N/A * with the list of brand names and return it to the caller. 2N/A * brands - const char pointer to string list of brand names 2N/A * delim - const char pointer to string representing the 2N/A * delimeter for brands string. 2N/A * Returns: zoneBrandList_t * 2N/A * == NULL - error, list could not be generated 2N/A * != NULL - success, list returned 2N/A * NOTE: Any zoneBrandList_t returned is placed in new storage for the 2N/A * calling function. The caller must use 'z_free_brand_list' to 2N/A * dispose of the storage once the list is no longer needed. 2N/A * Name: z_get_nonglobal_zone_list_by_brand 2N/A * Description: return zoneList_t object describing all non-global 2N/A * zones matching the list of brands passed in. 2N/A * Arguments: brands - The list of zone brands to look for. 2N/A * Returns: zoneList_t 2N/A * == NULL - error, list could not be generated 2N/A * != NULL - success, list returned 2N/A * NOTE: Any zoneList_t returned is placed in new storage for the 2N/A * calling function. The caller must use 'z_free_zone_list' to 2N/A * dispose of the storage once the list is no longer needed. 2N/A /* if zones are not implemented, return empty list */ 2N/A * Open the zone index file. Note that getzoneent_private() handles 2N/A /* index file open; scan all zones; see if any are at least installed */ 2N/A /* skip the global zone */ 2N/A * skip any zones with brands not on the brand list 2N/A * If the user specified an explicit zone list, then ignore any 2N/A * zones that aren't on that list. 2N/A /* non-global zone: create entry for this zone */ 2N/A * remember the zone name, zonepath and the current 2N/A * zone state of the zone. 2N/A * For a scratch zone, we need to know the kernel zone name. 2N/A /* close the index file */ 2N/A /* return generated list */ 2N/A * Name: z_get_zonename 2N/A * Description: return the name of the current zone 2N/A * - pointer to string representing the name of the current 2N/A * NOTE: Any string returned is placed in new storage for the 2N/A * calling function. The caller must use 'Free' to dispose 2N/A * of the storage once the string is no longer needed. 2N/A /* if zones are not implemented, return "" */ 2N/A /* get the zone i.d. of the current zone */ 2N/A /* get the name of the current zone */ 2N/A /* return "" if could not get zonename */ 2N/A * Name: z_global_only 2N/A * Description: Determine if the global zone is only zone on the spec list. 2N/A * Returns: B_TRUE if global zone is the only zone on the list, 2N/A * B_FALSE otherwise. 2N/A /* return true if zones are not implemented - treate as global zone */ 2N/A /* return true if this is the global zone */ 2N/A /* return false - not the global zone */ 2N/A * Name: z_lock_this_zone 2N/A * Description: lock this zone 2N/A * Arguments: a_lflags - [RO, *RO] - (ZLOCKS_T) 2N/A * Flags indicating which locks to acquire 2N/A * Returns: boolean_t 2N/A * == B_TRUE - success specified locks acquired 2N/A * == B_FALSE - failure specified locks not acquired 2N/A * NOTE: the lock objects for "this zone" are maintained internally. 2N/A /* entry assertions */ 2N/A /* entry debugging info */ 2N/A /* lock package administration always */ 2N/A * Name: z_running_in_global_zone 2N/A * Description: Determine if running in the "global" zone 2N/A * Returns: boolean_t 2N/A * == B_TRUE - running in global zone 2N/A * == B_FALSE - not running in global zone 2N/A /* if ID has not been determined, cache it now */ 2N/A * Name: z_set_output_functions 2N/A * Description: Link program specific output functions to this library. 2N/A * Arguments: a_echo_fcn - (_z_printf_fcn_t) 2N/A * Function to call to cause "normal operation" messages 2N/A * a_echo_debug_fcn - (_z_printf_fcn_t) 2N/A * Function to call to cause "debugging" messages 2N/A * a_progerr_fcn - (_z_printf_fcn_t) 2N/A * Function to call to cause "program error" messages 2N/A * NOTE: If NULL is specified for any function, then the functionality 2N/A * associated with that function is disabled. 2N/A * NOTE: The function pointers provided must call a function that 2N/A * takes two arguments: 2N/A * function(char *format, char *message) 2N/A * Any registered function will be called like: 2N/A * function("%s", "message") 2N/A * Name: z_set_zone_root 2N/A * Description: Set root for zones library operations 2N/A * Arguments: Path to root of boot environment containing zone; must be 2N/A * NOTE: Must be called before performing any zone-related operations. 2N/A * (Currently called directly by set_inst_root() during -R 2N/A * argument handling.) 2N/A /* if zones are not implemented, just return */ 2N/A /* entry assertions */ 2N/A /* free any existing cached root path */ 2N/A /* store duplicate of new zone root path */ 2N/A /* set zone root path */ 2N/A * Name: z_set_zone_spec 2N/A * Description: Set list of zones on which actions will be performed. 2N/A * Arguments: Whitespace-separated list of zone names. 2N/A * Returns: 0 on success, -1 on error. 2N/A * NOTES: Will call _z_program_error if argument can't be parsed or 2N/A * memory not available. 2N/A /* entry assertions */ 2N/A /* parse list to zone_spec_t list, store in global data */ 2N/A * Name: z_unlock_this_zone 2N/A * Description: unlock this zone 2N/A * Arguments: a_lflags - [RO, *RO] - (ZLOCKS_T) 2N/A * Flags indicating which locks to release 2N/A * Returns: boolean_t 2N/A * == B_TRUE - success specified locks released 2N/A * == B_FALSE - failure specified locks may not be released 2N/A * NOTE: the lock objects for "this zone" are maintained internally. 2N/A /* entry assertions */ 2N/A /* entry debugging info */ 2N/A /* return if no objects locked */ 2N/A /* unlock package administration */ 2N/A * Name: z_verify_zone_spec 2N/A * Description: Verify list of zones on which actions will be performed. 2N/A * Returns: 0 on success, -1 on error. 2N/A * NOTES: Will call _z_program_error if there are zones on the specified 2N/A * list that don't exist on the system. Requires that 2N/A * z_set_zone_root is called first (if it is called at all). 2N/A * Name: z_is_zone_brand_in_list 2N/A * Description: Determine whether zone's brand has a match in the list 2N/A * Arguments: zoneName - name of the zone to check for branding 2N/A * list - list of brands to check the zone against 2N/A * Returns: boolean_t 2N/A * == B_TRUE - zone has a matching brand 2N/A * == B_FALSE - zone brand is not in list 2N/A /* if zones are not implemented, return FALSE */ 2N/A /* if brands are not implemented, return FALSE */ 2N/A * Name: z_zlist_get_current_state 2N/A * Description: Determine the current kernel state of the specified zone 2N/A * Arguments: a_zlst - handle to zoneList_t object describing all zones 2N/A * a_zoneIndex - index into a_zlst of the zone to return 2N/A * Returns: zone_state_t 2N/A * The current state of the specified zone is returned 2N/A /* ignore empty list */ 2N/A /* find the specified zone in the list */ 2N/A /* return error if the specified zone does not exist */ 2N/A /* return selected zone's current kernel state */ 2N/A * Name: z_zlist_get_zonename 2N/A * Description: Determine name of specified zone 2N/A * Arguments: a_zlst - handle to zoneList_t object describing all zones 2N/A * a_zoneIndex - index into a_zlst of the zone to return the 2N/A * == NULL - zone name could not be determined 2N/A * != NULL - pointer to string representing zone name 2N/A * NOTE: Any zoneList_t returned is placed in static storage that must 2N/A * NEVER be free()ed by the caller. 2N/A /* ignore empty list */ 2N/A /* find the specified zone in the list */ 2N/A /* return error if the specified zone does not exist */ 2N/A /* return selected zone's name */ 2N/A * Name: z_zlist_get_zonepath 2N/A * Description: Determine zonepath of specified zone 2N/A * Arguments: a_zlst - handle to zoneList_t object describing all zones 2N/A * a_zoneIndex - index into a_zlst of the zone to return 2N/A * == NULL - zonepath could not be determined 2N/A * != NULL - pointer to string representing zonepath 2N/A * NOTE: Any zoneList_t returned is placed in static storage that must 2N/A * NEVER be free()ed by the caller. 2N/A /* ignore empty list */ 2N/A /* find the specified zone in the list */ 2N/A /* return error if the specified zone does not exist */ 2N/A /* return selected zone's zonepath */ 2N/A * Name: z_zones_are_implemented 2N/A * Description: Determine if any zone operations can be performed 2N/A * Returns: boolean_t 2N/A * == B_TRUE - zone operations are available 2N/A * == B_FALSE - no zone operations can be done 2N/A /* if availability has not been determined, cache it now */