Print this page
patch zone-auto-create-be

*** 19,28 **** --- 19,29 ---- * CDDL HEADER END */ /* * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright 2015 Josef 'Jeff' Sipek <jeffpc@josefsipek.net> */ /* * Module: zones.c
*** 35,44 **** --- 36,47 ---- * administration file that can be used to perform "non-interactive" * operations in a non-global zone. * z_free_zone_list - free contents of zoneList_t object * z_get_nonglobal_zone_list - return zoneList_t object describing all * non-global native zones + * z_get_nonglobal_branded_zone_list - return zoneList_t object describing + * all branded non-global zones * 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.
*** 428,451 **** 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; --- 431,443 ---- free(blist); return (head); } ! static zoneList_t ! i_get_nonglobal_branded_zone_list(boolean_t (*include)(struct zoneent *, ! void *), void *arg) { FILE *zoneIndexFP; int numzones = 0; struct zoneent *ze; zoneList_t zlst = NULL;
*** 478,490 **** 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; } /* --- 470,482 ---- free(ze); continue; } /* ! * skip any zones the filter function doesn't like */ ! if (include != NULL && !include(ze, arg)) { free(ze); continue; } /*
*** 564,573 **** --- 556,607 ---- return (zlst); } /* + * Name: z_get_nonglobal_branded_zone_list + * Description: return zoneList_t object describing all non-global + * 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_branded_zone_list(void) + { + return (i_get_nonglobal_branded_zone_list(NULL, NULL)); + } + + static boolean_t + X(struct zoneent *ze, void *arg) + { + zoneBrandList_t *brands = arg; + + return (z_is_zone_brand_in_list(ze->zone_name, brands)); + } + + /* + * 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) + { + return (i_get_nonglobal_branded_zone_list(X, brands)); + } + + /* * 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
*** 1892,1901 **** --- 1926,1956 ---- /* return selected zone's zonepath */ return (a_zlst[i]._zlPath); } + int + z_zlist_is_zone_auto_create_be(zoneList_t zlst, int idx, boolean_t *ret) + { + char brandname[MAXNAMELEN]; + brand_handle_t bh; + + if (zone_get_brand(z_zlist_get_zonename(zlst, idx), brandname, + sizeof (brandname)) != Z_OK) + return (-1); + + bh = brand_open(brandname); + if (bh == NULL) + return (-1); + + *ret = brand_auto_create_be(bh); + + brand_close(bh); + + return (0); + } + boolean_t z_zlist_is_zone_runnable(zoneList_t a_zlst, int a_zoneIndex) { int i;