usr/src/cmd/zpool/zpool_iter.c
/*
 * Create a list of pools based on the given arguments.  If we're given no
 * arguments, then iterate over all pools in the system and add them to the AVL
 * tree.  Otherwise, add only those pool explicitly specified on the command
 * line.
 */
Create a list of pools based on the given arguments.  If we're given no
arguments, then iterate over all pools in the system and add them to the AVL
tree.  Otherwise, add only those pool explicitly specified on the command
line.
Create a list of pools based on the given arguments . If we ' re given no arguments then iterate over all pools in the system and add them to the AVL tree . Otherwise add only those pool explicitly specified on the command line .
zpool_list_t *
pool_list_get(int argc, char **argv, zprop_list_t **proplist, int *err)
{
	zpool_list_t *zlp;
	zlp = safe_malloc(sizeof (zpool_list_t));
	zlp->zl_pool = uu_avl_pool_create("zfs_pool", sizeof (zpool_node_t),
	    offsetof(zpool_node_t, zn_avlnode), zpool_compare, UU_DEFAULT);
	if (zlp->zl_pool == NULL)
		zpool_no_memory();
	if ((zlp->zl_avl = uu_avl_create(zlp->zl_pool, NULL,
	    UU_DEFAULT)) == NULL)
		zpool_no_memory();
	zlp->zl_proplist = proplist;
	if (argc == 0) {
		(void) zpool_iter(g_zfs, add_pool, zlp);
		zlp->zl_findall = B_TRUE;
	} else {
		int i;
		for (i = 0; i < argc; i++) {
			zpool_handle_t *zhp;
			if ((zhp = zpool_open_canfail(g_zfs, argv[i])) !=
			    NULL) {
				if (add_pool(zhp, zlp) != 0)
					*err = B_TRUE;
			} else {
				*err = B_TRUE;
			}
		}
	}
	return (zlp);
}
zpool_list_t * pool_list_get ( int argc , char * * argv , zprop_list_t * * proplist , int * err ) { zpool_list_t * zlp ; zlp = safe_malloc ( sizeof ( zpool_list_t ) ) ; zlp -> zl_pool = uu_avl_pool_create ( " " , sizeof ( zpool_node_t ) , offsetof ( zpool_node_t , zn_avlnode ) , zpool_compare , UU_DEFAULT ) ; if ( zlp -> zl_pool == NULL ) zpool_no_memory ( ) ; if ( ( zlp -> zl_avl = uu_avl_create ( zlp -> zl_pool , NULL , UU_DEFAULT ) ) == NULL ) zpool_no_memory ( ) ; zlp -> zl_proplist = proplist ; if ( argc == 0 ) { ( void ) zpool_iter ( g_zfs , add_pool , zlp ) ; zlp -> zl_findall = B_TRUE ; } else { int i ; for ( i = 0 ; i < argc ; i ++ ) { zpool_handle_t * zhp ; if ( ( zhp = zpool_open_canfail ( g_zfs , argv [ i ] ) ) != NULL ) { if ( add_pool ( zhp , zlp ) != 0 ) * err = B_TRUE ; } else { * err = B_TRUE ; } } } return ( zlp ) ; }
Create a list of pools based on the given arguments.
Create a list of pools based on the given arguments .