Add libzutil for libzfs or libzpool consumers

Adds a libzutil for utility functions that are common to libzfs and
libzpool consumers (most of what was in libzfs_import.c).  This
removes the need for utilities to link against both libzpool and
libzfs.

Reviewed-by: Matthew Ahrens <mahrens@delphix.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Don Brady <don.brady@delphix.com>
Closes #8050
This commit is contained in:
Don Brady
2018-11-05 12:22:33 -07:00
committed by Brian Behlendorf
parent 6644e5bb6e
commit e89f1295d4
39 changed files with 3725 additions and 3396 deletions
-1
View File
@@ -20,7 +20,6 @@ ztest_SOURCES = \
ztest_LDADD = \
$(top_builddir)/lib/libnvpair/libnvpair.la \
$(top_builddir)/lib/libzfs/libzfs.la \
$(top_builddir)/lib/libzpool/libzpool.la
ztest_LDADD += -lm
+3 -5
View File
@@ -128,7 +128,7 @@
#include <sys/fs/zfs.h>
#include <zfs_fletcher.h>
#include <libnvpair.h>
#include <libzfs.h>
#include <libzutil.h>
#include <sys/crypto/icp.h>
#ifdef __GLIBC__
#include <execinfo.h> /* for backtrace() */
@@ -7065,7 +7065,6 @@ make_random_props(void)
static void
ztest_import(ztest_shared_t *zs)
{
libzfs_handle_t *hdl;
importargs_t args = { 0 };
spa_t *spa;
nvlist_t *cfg = NULL;
@@ -7080,14 +7079,14 @@ ztest_import(ztest_shared_t *zs)
VERIFY0(pthread_rwlock_init(&ztest_name_lock, NULL));
kernel_init(FREAD | FWRITE);
hdl = libzfs_init();
searchdirs[0] = ztest_opts.zo_dir;
args.paths = nsearch;
args.path = searchdirs;
args.can_be_active = B_FALSE;
error = zpool_tryimport(hdl, name, &cfg, &args);
error = zpool_find_config(NULL, name, &cfg, &args,
&libzpool_config_ops);
if (error)
(void) fatal(0, "No pools found\n");
@@ -7097,7 +7096,6 @@ ztest_import(ztest_shared_t *zs)
1ULL << spa->spa_root_vdev->vdev_child[0]->vdev_ms_shift;
spa_close(spa, FTAG);
libzfs_fini(hdl);
kernel_fini();
if (!ztest_opts.zo_mmp_test) {