FreeBSD/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa_config.c
/*
 * Called when the module is first loaded, this routine loads the configuration
 * file into the SPA namespace.  It does not actually open or load the pools; it
 * only populates the namespace.
 */
Called when the module is first loaded, this routine loads the configuration
file into the SPA namespace.  It does not actually open or load the pools; it
only populates the namespace.
Called when the module is first loaded this routine loads the configuration file into the SPA namespace . It does not actually open or load the pools ; it only populates the namespace .
void
spa_config_load(void)
{
	void *buf = NULL;
	nvlist_t *nvlist, *child;
	nvpair_t *nvpair;
	char *pathname;
	struct _buf *file;
	uint64_t fsize;
	pathname = kmem_alloc(MAXPATHLEN, KM_SLEEP);
	(void) snprintf(pathname, MAXPATHLEN, "%s", spa_config_path);
	file = kobj_open_file(pathname);
	kmem_free(pathname, MAXPATHLEN);
	if (file == (struct _buf *)-1)
		return;
	if (kobj_get_filesize(file, &fsize) != 0)
		goto out;
	buf = kmem_alloc(fsize, KM_SLEEP);
	if (kobj_read_file(file, buf, fsize, 0) < 0)
		goto out;
	if (nvlist_unpack(buf, fsize, &nvlist, KM_SLEEP) != 0)
		goto out;
	mutex_enter(&spa_namespace_lock);
	nvpair = NULL;
	while ((nvpair = nvlist_next_nvpair(nvlist, nvpair)) != NULL) {
		if (nvpair_type(nvpair) != DATA_TYPE_NVLIST)
			continue;
		child = fnvpair_value_nvlist(nvpair);
		if (spa_lookup(nvpair_name(nvpair)) != NULL)
			continue;
		(void) spa_add(nvpair_name(nvpair), child, NULL);
	}
	mutex_exit(&spa_namespace_lock);
	nvlist_free(nvlist);
out:
	if (buf != NULL)
		kmem_free(buf, fsize);
	kobj_close_file(file);
}
void spa_config_load ( void ) { void * buf = NULL ; nvlist_t * nvlist , * child ; nvpair_t * nvpair ; char * pathname ; struct _buf * file ; uint64_t fsize ; pathname = kmem_alloc ( MAXPATHLEN , KM_SLEEP ) ; ( void ) snprintf ( pathname , MAXPATHLEN , " " , spa_config_path ) ; file = kobj_open_file ( pathname ) ; kmem_free ( pathname , MAXPATHLEN ) ; if ( file == ( struct _buf * ) -1 ) return ; if ( kobj_get_filesize ( file , & fsize ) != 0 ) goto out ; buf = kmem_alloc ( fsize , KM_SLEEP ) ; if ( kobj_read_file ( file , buf , fsize , 0 ) < 0 ) goto out ; if ( nvlist_unpack ( buf , fsize , & nvlist , KM_SLEEP ) != 0 ) goto out ; mutex_enter ( & spa_namespace_lock ) ; nvpair = NULL ; while ( ( nvpair = nvlist_next_nvpair ( nvlist , nvpair ) ) != NULL ) { if ( nvpair_type ( nvpair ) != DATA_TYPE_NVLIST ) continue ; child = fnvpair_value_nvlist ( nvpair ) ; if ( spa_lookup ( nvpair_name ( nvpair ) ) != NULL ) continue ; ( void ) spa_add ( nvpair_name ( nvpair ) , child , NULL ) ; } mutex_exit ( & spa_namespace_lock ) ; nvlist_free ( nvlist ) ; out : if ( buf != NULL ) kmem_free ( buf , fsize ) ; kobj_close_file ( file ) ; }
Called when the module is first loaded, this routine loads the configuration
 file into the SPA namespace.
Called when the module is first loaded this routine loads the configuration file into the SPA namespace .
/*
	 * Open the configuration file.
	 */ /*
	 * Read the nvlist from the file.
	 */ /*
	 * Unpack the nvlist.
	 */ /*
	 * Iterate over all elements in the nvlist, creating a new spa_t for
	 * each one with the specified configuration.
	 */