summaryrefslogtreecommitdiffstats
path: root/cmd/zhack/zhack.c
diff options
context:
space:
mode:
authorDon Brady <[email protected]>2018-11-05 12:22:33 -0700
committerBrian Behlendorf <[email protected]>2018-11-05 11:22:33 -0800
commite89f1295d4faa88bb05a62c8dd5f781657db5955 (patch)
tree8e39dfe33c6849e00813e54ec95c09a24448a43a /cmd/zhack/zhack.c
parent6644e5bb6e1a6c25c5006c819abf93c7bb662e80 (diff)
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 <[email protected]> Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Don Brady <[email protected]> Closes #8050
Diffstat (limited to 'cmd/zhack/zhack.c')
-rw-r--r--cmd/zhack/zhack.c13
1 files changed, 4 insertions, 9 deletions
diff --git a/cmd/zhack/zhack.c b/cmd/zhack/zhack.c
index 296a7fe75..57e497f62 100644
--- a/cmd/zhack/zhack.c
+++ b/cmd/zhack/zhack.c
@@ -48,12 +48,11 @@
#include <sys/zio_compress.h>
#include <sys/zfeature.h>
#include <sys/dmu_tx.h>
-#include <libzfs.h>
+#include <libzutil.h>
extern boolean_t zfeature_checks_disable;
const char cmdname[] = "zhack";
-libzfs_handle_t *g_zfs;
static importargs_t g_importargs;
static char *g_pool;
static boolean_t g_readonly;
@@ -128,20 +127,17 @@ zhack_import(char *target, boolean_t readonly)
int error;
kernel_init(readonly ? FREAD : (FREAD | FWRITE));
- g_zfs = libzfs_init();
- ASSERT(g_zfs != NULL);
dmu_objset_register_type(DMU_OST_ZFS, space_delta_cb);
g_readonly = readonly;
- g_importargs.unique = B_TRUE;
g_importargs.can_be_active = readonly;
g_pool = strdup(target);
- error = zpool_tryimport(g_zfs, target, &config, &g_importargs);
+ error = zpool_find_config(NULL, target, &config, &g_importargs,
+ &libzpool_config_ops);
if (error)
- fatal(NULL, FTAG, "cannot import '%s': %s", target,
- libzfs_error_description(g_zfs));
+ fatal(NULL, FTAG, "cannot import '%s'", target);
props = NULL;
if (readonly) {
@@ -529,7 +525,6 @@ main(int argc, char **argv)
"changes may not be committed to disk\n");
}
- libzfs_fini(g_zfs);
kernel_fini();
return (rv);