FreeBSD/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa_config.c
/*
 * Sigh.  Inside a local zone, we don't have access to /etc/zfs/zpool.cache,
 * and we don't want to allow the local zone to see all the pools anyway.
 * So we have to invent the ZFS_IOC_CONFIG ioctl to grab the configuration
 * information for all pool visible within the zone.
 */
Sigh.  Inside a local zone, we don't have access to /etc/zfs/zpool.cache,
and we don't want to allow the local zone to see all the pools anyway.
So we have to invent the ZFS_IOC_CONFIG ioctl to grab the configuration
information for all pool visible within the zone.
Sigh . Inside a local zone we don ' t have access to / etc / zfs / zpool . cache and we don ' t want to allow the local zone to see all the pools anyway . So we have to invent the ZFS_IOC_CONFIG ioctl to grab the configuration information for all pool visible within the zone .
nvlist_t *
spa_all_configs(uint64_t *generation)
{
	nvlist_t *pools;
	spa_t *spa = NULL;
	if (*generation == spa_config_generation)
		return (NULL);
	pools = fnvlist_alloc();
	mutex_enter(&spa_namespace_lock);
	while ((spa = spa_next(spa)) != NULL) {
		if (INGLOBALZONE(curthread) ||
		    zone_dataset_visible(spa_name(spa), NULL)) {
			mutex_enter(&spa->spa_props_lock);
			fnvlist_add_nvlist(pools, spa_name(spa),
			    spa->spa_config);
			mutex_exit(&spa->spa_props_lock);
		}
	}
	*generation = spa_config_generation;
	mutex_exit(&spa_namespace_lock);
	return (pools);
}
nvlist_t * spa_all_configs ( uint64_t * generation ) { nvlist_t * pools ; spa_t * spa = NULL ; if ( * generation == spa_config_generation ) return ( NULL ) ; pools = fnvlist_alloc ( ) ; mutex_enter ( & spa_namespace_lock ) ; while ( ( spa = spa_next ( spa ) ) != NULL ) { if ( INGLOBALZONE ( curthread ) || zone_dataset_visible ( spa_name ( spa ) , NULL ) ) { mutex_enter ( & spa -> spa_props_lock ) ; fnvlist_add_nvlist ( pools , spa_name ( spa ) , spa -> spa_config ) ; mutex_exit ( & spa -> spa_props_lock ) ; } } * generation = spa_config_generation ; mutex_exit ( & spa_namespace_lock ) ; return ( pools ) ; }
Sigh.
Sigh .