- Fix PoolImportSearch not listing pools that are not explicitly exported

This commit is contained in:
Faruk Kasumovic 2018-04-10 13:45:02 +02:00
parent f5a73ad14f
commit b1b9ae5efc
3 changed files with 13 additions and 4 deletions

10
zpool.c
View File

@ -486,4 +486,14 @@ nvlist_ptr get_zpool_vdev_tree(nvlist_ptr nv) {
return NULL;
}
return vdev_tree;
}
nvlist_ptr go_zpool_search_import(libzfs_handle_ptr zfsh, int paths, char **path, boolean_t do_scan) {
importargs_t idata = { 0 };
idata.path = path;
idata.paths = paths;
// idata.scan = 0;
return zpool_search_import(zfsh, &idata);
}

View File

@ -307,7 +307,7 @@ func PoolImportSearch(searchpaths []string) (epools []ExportedPool, err error) {
C.strings_setat(cpaths, C.int(i), csPath)
}
pools := C.zpool_find_import(C.libzfsHandle, C.int(numofp), cpaths)
pools := C.go_zpool_search_import(C.libzfsHandle, C.int(numofp), cpaths, C.B_FALSE)
defer C.nvlist_free(pools)
elem = C.nvlist_next_nvpair(pools, elem)
epools = make([]ExportedPool, 0, 1)
@ -319,9 +319,6 @@ func PoolImportSearch(searchpaths []string) (epools []ExportedPool, err error) {
}
ep.State = PoolState(C.get_zpool_state(config))
if ep.State != PoolStateExported {
continue
}
if cname = C.get_zpool_name(config); cname == nil {
err = fmt.Errorf("Failed to fetch %s", C.ZPOOL_CONFIG_POOL_NAME)

View File

@ -68,6 +68,8 @@ const char *get_zpool_comment(nvlist_ptr nv);
nvlist_ptr get_zpool_vdev_tree(nvlist_ptr nv);
nvlist_ptr go_zpool_search_import(libzfs_handle_ptr zfsh, int paths, char **path, boolean_t do_scan);
extern char *sZPOOL_CONFIG_VERSION;
extern char *sZPOOL_CONFIG_POOL_NAME;