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) 2009, 2010, Oracle and/or its affiliates. All rights reserved. 2N/A * Group: libinstzones 2N/A * Description: Provide "zones" interface for install consolidation code 2N/A * _z_close_file_descriptors - close a file descriptor "a_fd" not in the 2N/A * _z_echo - Output an interactive message if interaction is enabled 2N/A * _z_echoDebug - Output a debugging message if debugging is enabled 2N/A * _z_is_directory - determine if specified path exists and is a directory 2N/A * _z_program_error - Output an error message to the appropriate destinations 2N/A * _z_running_in_global_zone - Determine if this process is running in the 2N/A * _z_zones_are_implemented - Determine if zones are supported by the 2N/A * _z_brands_are_implemented - determine if branded zones are implemented on 2N/A * Private structures 2N/A * these dynamic libraries are required in order to use the branded zones 2N/A * functionality. If these libraries are not available at runtime, 2N/A * then the zones we find are assumed to be native zones. 2N/A * Library Function Prototypes 2N/A * Local Function Prototypes 2N/A/* ----------------------- private functions -------------------------- */ 2N/A * Abort routine. An exit code of '2' is used by all applications 2N/A * to indicate a non-recoverable fatal error. 2N/A * error_num - error index number: 2N/A * ***************************************************************************** 2N/A * global external (public) functions 2N/A * ***************************************************************************** 2N/A * Name: _z_close_file_descriptors 2N/A * Description: close a file descriptor "a_fd" not in the list "a_fds" 2N/A * This function is called from the fdwalk() library function. 2N/A * If the file descriptor passed in is NOT in the list passed in, 2N/A * the file is closed. 2N/A * Arguments: a_fds - [RO, *RO] - (void *) 2N/A * Pointer to list of file descriptors to keep open 2N/A * a_fd - [RO, *RO] - (int) 2N/A * File descriptor to check 2N/A /* do not close standard input, output, or error file descriptors */ 2N/A /* if no file descriptor retention list, close this file */ 2N/A * retention list provided, skip this descriptor if its in the list 2N/A for (i = 0;
fds[i] != -
1; i++) {
2N/A /* this descriptor not in retention list - close this file */ 2N/A * Synopsis: Output an interactive message if interaction is enabled 2N/A * Description: Main method for outputting an interactive message; call to 2N/A * output interactive message if interation has not been disabled 2N/A * by a previous call to echoSetFlag(0). 2N/A * Arguments: format - [RO, RO*] (char *) 2N/A * printf-style format for debugging message to be output 2N/A * VARG_LIST - [RO] (?) 2N/A * arguments as appropriate to 'format' specified 2N/A /* entry assertions */ 2N/A /* return if no progerr function registered */ 2N/A /* capture message */ 2N/A /* pass message to registered function */ 2N/A * Name: _z_echoDebug 2N/A * Synopsis: Output a debugging message if debugging is enabled 2N/A * Description: Main method for outputting a debugging message; call to 2N/A * output debugging message if debugging has been enabled 2N/A * by a previous call to _z_echoDebugSetFlag(1). 2N/A * Arguments: format - [RO, RO*] (char *) 2N/A * printf-style format for debugging message to be output 2N/A * VARG_LIST - [RO] (?) 2N/A * arguments as appropriate to 'format' specified 2N/A * NOTE: format of message will be: 2N/A * # [ aaa bbb ccc ] message 2N/A * where: aaa - process i.d. 2N/A * ccc - name of program 2N/A * # [ 25685 0 pkgadd ] unable to get package list 2N/A /* entry assertions */ 2N/A /* return if no progerr function registered */ 2N/A /* capture message */ 2N/A /* pass message to registered function */ 2N/A * Name: _z_is_directory 2N/A * Description: determine if specified path exists and is a directory 2N/A * Arguments: path - pointer to string representing the path to verify 2N/A * returns: 0 - directory exists 2N/A * 1 - directory does not exist or is not a directory 2N/A * NOTE: errno is set appropriately 2N/A /* entry assertions */ 2N/A /* return error if path does not exist */ 2N/A /* return error if path is not a directory */ 2N/A /* path exists and is a directory */ 2N/A * Name: _z_pluginCatchSigint 2N/A * Description: Catch the "SIGINT" and "SIGHUP" signals: 2N/A * -> increment _z_SigReceived global variable 2N/A * -> propagate signal to "_z_ChildProcessId" if registered (!= -1) 2N/A * Arguments: signo - [RO, *RO] - (int) 2N/A * Signal number that was caught 2N/A /* bump signals received count */ 2N/A /* if child process registered, propagate signal to child */ 2N/A * Name: _z_program_error 2N/A * Description: Output an error message to the appropriate destinations 2N/A * Arguments: format - [RO, RO*] (char *) 2N/A * printf-style format for debugging message to be output 2N/A * VARG_LIST - [RO] (?) 2N/A * arguments as appropriate to 'format' specified 2N/A * NOTE: format of message will be: 2N/A * [aaa: ] ERROR: message 2N/A * where: aaa - program name (if set) 2N/A * message - results of format and arguments 2N/A * ERROR: unable to get package list 2N/A /* entry assertions */ 2N/A /* return if no progerr function registered */ 2N/A /* capture message */ 2N/A /* pass message to registered function */ 2N/A * Name: _z_running_in_global_zone 2N/A * Synopsis: Determine if this process is running in the global zone 2N/A * Returns: boolean_t 2N/A * == B_TRUE - this process is running in the global zone 2N/A * == B_FALSE - this process is running in a nonglobal zone 2N/A * if zones are not implemented, there is no way to tell if zones 2N/A * are supported or not - in this case, we can only be running in the 2N/A * global zone (since non-global zones cannot exist) so return TRUE 2N/A /* get the zone i.d. of the current zone */ 2N/A /* return TRUE if this is the global zone i.d. */ 2N/A /* return FALSE - not in the global zone */ 2N/A * Name: _z_zones_are_implemented 2N/A * Synopsis: Determine if zones are supported by the current system 2N/A * Returns: boolean_t 2N/A * == B_TRUE - zones are supported 2N/A * == B_FALSE - zones are not supported 2N/A /* locate zone cfg library */ 2N/A /* return false if library not available */ 2N/A /* library available - close handle */ 2N/A /* locate contract filesystem library */ 2N/A /* return false if library not available */ 2N/A /* library available - close handle */ 2N/A /* return success */ 2N/A /* locate brand library */ 2N/A /* return false if library not available */ 2N/A /* library available - close handle */ 2N/A /* return success */ 2N/A * Allocate 'size' bytes from the heap using calloc() 2N/A * size - number of bytes to allocate 2N/A * NULL - calloc() failure 2N/A * void * - pointer to allocated structure 2N/A * Alloc 'size' bytes from heap using malloc() 2N/A * size - number of bytes to malloc 2N/A * NULL - malloc() failure 2N/A * void * - pointer to allocated structure 2N/A * Calls realloc() with the specfied parameters. _z_realloc() 2N/A * checks for realloc failures and adjusts the return value 2N/A * ptr - pointer to existing data block 2N/A * size - number of bytes additional 2N/A * NULL - realloc() failed 2N/A * void * - pointer to realloc'd structured 2N/A * Allocate space for the string from the heap, copy 'str' into it, 2N/A * and return a pointer to it. 2N/A * str - string to duplicate 2N/A * NULL - duplication failed or 'str' was NULL