From e89f1295d4faa88bb05a62c8dd5f781657db5955 Mon Sep 17 00:00:00 2001 From: Don Brady Date: Mon, 5 Nov 2018 12:22:33 -0700 Subject: 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 Reviewed-by: Brian Behlendorf Signed-off-by: Don Brady Closes #8050 --- cmd/zdb/Makefile.am | 1 - cmd/zdb/zdb.c | 13 +++++-------- 2 files changed, 5 insertions(+), 9 deletions(-) (limited to 'cmd/zdb') diff --git a/cmd/zdb/Makefile.am b/cmd/zdb/Makefile.am index 70b60bfaf..1fa7ec651 100644 --- a/cmd/zdb/Makefile.am +++ b/cmd/zdb/Makefile.am @@ -16,5 +16,4 @@ zdb_SOURCES = \ zdb_LDADD = \ $(top_builddir)/lib/libnvpair/libnvpair.la \ - $(top_builddir)/lib/libzfs/libzfs.la \ $(top_builddir)/lib/libzpool/libzpool.la diff --git a/cmd/zdb/zdb.c b/cmd/zdb/zdb.c index 737217538..52a671557 100644 --- a/cmd/zdb/zdb.c +++ b/cmd/zdb/zdb.c @@ -67,7 +67,9 @@ #include #include #include -#include + +#include +#include #include "zdb.h" @@ -106,7 +108,6 @@ typedef void object_viewer_t(objset_t *, uint64_t, void *data, size_t size); uint64_t *zopt_object = NULL; static unsigned zopt_objects = 0; -libzfs_handle_t *g_zfs; uint64_t max_inflight = 1000; static int leaked_objects = 0; static range_tree_t *mos_refd_objs; @@ -5996,10 +5997,6 @@ main(int argc, char **argv) spa_load_verify_dryrun = B_TRUE; kernel_init(FREAD); - if ((g_zfs = libzfs_init()) == NULL) { - (void) fprintf(stderr, "%s", libzfs_error_init(errno)); - return (1); - } if (dump_all) verbose = MAX(verbose, 1); @@ -6078,7 +6075,8 @@ main(int argc, char **argv) args.path = searchdirs; args.can_be_active = B_TRUE; - error = zpool_tryimport(g_zfs, target_pool, &cfg, &args); + error = zpool_find_config(NULL, target_pool, &cfg, &args, + &libzpool_config_ops); if (error == 0) { @@ -6228,7 +6226,6 @@ main(int argc, char **argv) dump_debug_buffer(); - libzfs_fini(g_zfs); kernel_fini(); return (error); -- cgit v1.2.3