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